org.intermine.objectstore.intermine
Class DatabaseSchema

java.lang.Object
  extended by org.intermine.objectstore.intermine.DatabaseSchema

public class DatabaseSchema
extends java.lang.Object

An object that represents the mapping of a Model onto a relational database. This handles the complications of truncated class trees.


Nested Class Summary
static class DatabaseSchema.Fields
          Inner class to hold information on Attributes and References.
 
Constructor Summary
DatabaseSchema(Model model, java.util.List<ClassDescriptor> truncated, boolean noNotXml, java.util.Set<java.lang.String> missingTables, int version, boolean hasBioSeg)
          Returns an instance of DatabaseSchema, for the given Model and and List of truncated classes.
 
Method Summary
 java.util.Set<java.lang.String> getMissingTables()
          Returns the Set of table names which are tables missing from the database.
 Model getModel()
          Returns the model.
 DatabaseSchema.Fields getTableFields(ClassDescriptor cld)
          Returns a Fields object of FieldDescriptors in the given table-mastering ClassDescriptor.
 ClassDescriptor getTableMaster(ClassDescriptor cld)
          Returns the name of the table in which to store a row for the given ClassDescriptor.
 int getVersion()
          Returns the database format version.
 boolean hasBioSeg()
          Returns true if the database has the bioseg type installed.
 boolean isFetchFromInterMineObject()
          Returns true if ProxyReferences can be fetched from the InterMineObject table.
 boolean isFlatMode(java.lang.Class<?> c)
          Returns true if the ObjectStore needs to run in flat mode for this Class - if notXml is missing and the InterMineObject table is missing (or if the class is not a subclass of InterMineObject).
 boolean isMissingNotXml()
          Returns true if NotXML should be omitted from all tables except the InterMineObject table, and the InterMineObject table is present.
 boolean isTruncated(ClassDescriptor cld)
          Returns true if a query using the given table-mastering ClassDescriptor would require a constraint on the className field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseSchema

public DatabaseSchema(Model model,
                      java.util.List<ClassDescriptor> truncated,
                      boolean noNotXml,
                      java.util.Set<java.lang.String> missingTables,
                      int version,
                      boolean hasBioSeg)
Returns an instance of DatabaseSchema, for the given Model and and List of truncated classes.

Parameters:
model - a Model
truncated - a List of ClassDescriptors representing the truncated classes, in order of decreasing priority.
noNotXml - true if NotXML data should be omitted from every table except InterMineObject
missingTables - a Set of lowercase table names which are missing
version - the version number in the database
hasBioSeg - true if the database has the bioseg type installed
Throws:
java.lang.IllegalArgumentException - if the truncated class list does not make sense
Method Detail

getTableMaster

public ClassDescriptor getTableMaster(ClassDescriptor cld)
Returns the name of the table in which to store a row for the given ClassDescriptor.

Parameters:
cld - the ClassDescriptor from the Model
Returns:
the ClassDescriptor that masters the table

isTruncated

public boolean isTruncated(ClassDescriptor cld)
Returns true if a query using the given table-mastering ClassDescriptor would require a constraint on the className field. It is assumed that the ClassDescriptor passed in here is a ClassDescriptor that could be returned by the getTableMaster() method.

Parameters:
cld - the ClassDescriptor
Returns:
a boolean

getModel

public Model getModel()
Returns the model.

Returns:
the model

isMissingNotXml

public boolean isMissingNotXml()
Returns true if NotXML should be omitted from all tables except the InterMineObject table, and the InterMineObject table is present.

Returns:
a boolean

isFlatMode

public boolean isFlatMode(java.lang.Class<?> c)
Returns true if the ObjectStore needs to run in flat mode for this Class - if notXml is missing and the InterMineObject table is missing (or if the class is not a subclass of InterMineObject).

Parameters:
c - a Class
Returns:
a boolean

isFetchFromInterMineObject

public boolean isFetchFromInterMineObject()
Returns true if ProxyReferences can be fetched from the InterMineObject table.

Returns:
a boolean

getVersion

public int getVersion()
Returns the database format version.

Returns:
an int

getMissingTables

public java.util.Set<java.lang.String> getMissingTables()
Returns the Set of table names which are tables missing from the database.

Returns:
a Set of lowercase Strings

hasBioSeg

public boolean hasBioSeg()
Returns true if the database has the bioseg type installed.

Returns:
a boolean

getTableFields

public DatabaseSchema.Fields getTableFields(ClassDescriptor cld)
                                     throws ObjectStoreException
Returns a Fields object of FieldDescriptors in the given table-mastering ClassDescriptor. It is assumed that the ClassDescriptor passed in here is a ClassDescriptor that could be returned as a of the getTableMaster() method. Where multiple subclasses of a truncated class have a similarly-named field with the same type, one of the FieldDescriptors will be chosen at random. CollectionDescriptors are not included in the result of this method.

Parameters:
cld - the ClassDescriptor
Returns:
a Fields object containing AttributeDescriptors and ReferenceDescriptors
Throws:
ObjectStoreException - if two similar-named fields are found of different types