Package org.intermine.dataloader
Class BaseEquivalentObjectFetcher
- java.lang.Object
-
- org.intermine.dataloader.BaseEquivalentObjectFetcher
-
- All Implemented Interfaces:
EquivalentObjectFetcher
- Direct Known Subclasses:
HintingFetcher
public class BaseEquivalentObjectFetcher extends java.lang.Object implements EquivalentObjectFetcher
Class providing methods to look up equivalent objects by primary key in a production objectstore.- Author:
- Matthew Wakeling
-
-
Field Summary
Fields Modifier and Type Field Description protected IntToIntMap
idMap
protected ObjectStore
lookupOs
protected Model
model
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Integer>
summaryCallCounts
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Integer>
summaryCounts
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Long>
summaryTimes
-
Constructor Summary
Constructors Constructor Description BaseEquivalentObjectFetcher(Model model, IntToIntMap idMap, ObjectStore lookupOs)
Constructor for this EquivalentObjectFetcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(Source source)
Close method - prints out summary data.java.util.Set<Query>
createPKQueriesForClass(InterMineObject obj, Source source, boolean queryNulls, ClassDescriptor cld)
Generates a query that searches for all objects in the database equivalent to a given example object, considering only one of it's classes.Query
createPKQuery(InterMineObject obj, Source source, boolean queryNulls)
Generates a query that searches for all objects in the database equivalent to a given example object according to the primary keys defined for the given source.void
createPKQueryForPK(InterMineObject obj, boolean queryNulls, ClassDescriptor cld, PrimaryKey pk, Source source, java.util.Set<Query> returnSet)
Adds a Query to handle a primary key to a Set.IntToIntMap
getIdMap()
Returns the IdMap used.ObjectStore
getLookupOs()
Returns the objectstore that contains the equivalent objects.Model
getModel()
Returns the Model used.protected java.lang.StringBuffer
getSummary(Source source)
Returns a StringBuffer containing summary information.java.util.Set<InterMineObject>
queryEquivalentObjects(InterMineObject obj, Source source)
Returns a Set of objects that are equivalent to the given object, according to the primary keys defined by the given Source.
-
-
-
Field Detail
-
model
protected Model model
-
idMap
protected IntToIntMap idMap
-
lookupOs
protected ObjectStore lookupOs
-
summaryTimes
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Long> summaryTimes
-
summaryCounts
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Integer> summaryCounts
-
summaryCallCounts
protected java.util.Map<java.lang.Class<? extends InterMineObject>,java.lang.Integer> summaryCallCounts
-
-
Constructor Detail
-
BaseEquivalentObjectFetcher
public BaseEquivalentObjectFetcher(Model model, IntToIntMap idMap, ObjectStore lookupOs)
Constructor for this EquivalentObjectFetcher.- Parameters:
model
- a ModelidMap
- an IntToIntMap from source IDs to destination IDslookupOs
- an ObjectStore for the production database
-
-
Method Detail
-
getModel
public Model getModel()
Returns the Model used.- Returns:
- a Model
-
getIdMap
public IntToIntMap getIdMap()
Returns the IdMap used.- Returns:
- an IntToIntMap
-
getLookupOs
public ObjectStore getLookupOs()
Returns the objectstore that contains the equivalent objects.- Returns:
- an ObjectStore
-
close
public void close(Source source)
Close method - prints out summary data.- Parameters:
source
- the Source used
-
getSummary
protected java.lang.StringBuffer getSummary(Source source)
Returns a StringBuffer containing summary information.- Parameters:
source
- the Source used- Returns:
- a StringBuffer
-
queryEquivalentObjects
public java.util.Set<InterMineObject> queryEquivalentObjects(InterMineObject obj, Source source) throws ObjectStoreException
Returns a Set of objects that are equivalent to the given object, according to the primary keys defined by the given Source.- Specified by:
queryEquivalentObjects
in interfaceEquivalentObjectFetcher
- Parameters:
obj
- the Object to look forsource
- the data Source- Returns:
- a Set of InterMineObjects
- Throws:
ObjectStoreException
- if an error occurs
-
createPKQuery
public Query createPKQuery(InterMineObject obj, Source source, boolean queryNulls) throws MetaDataException
Generates a query that searches for all objects in the database equivalent to a given example object according to the primary keys defined for the given source.- Specified by:
createPKQuery
in interfaceEquivalentObjectFetcher
- Parameters:
obj
- the Object to take as an examplesource
- the Source databasequeryNulls
- if true allow primary keys to contain null values if the template obj has nulls. If false the Query will constrain only those keys that have a value in the template obj- Returns:
- a new Query (or null if all the primary keys from obj contain a null)
- Throws:
MetaDataException
- if anything goes wrong
-
createPKQueriesForClass
public java.util.Set<Query> createPKQueriesForClass(InterMineObject obj, Source source, boolean queryNulls, ClassDescriptor cld) throws MetaDataException
Generates a query that searches for all objects in the database equivalent to a given example object, considering only one of it's classes.- Specified by:
createPKQueriesForClass
in interfaceEquivalentObjectFetcher
- Parameters:
obj
- the Object to take as an examplesource
- the Source databasequeryNulls
- if true allow primary keys to contain null values if the template obj has nulls. If false the Query will constrain only those keys that have a value in the template objcld
- one of the classes that obj is. Only primary keys for this classes will be considered- Returns:
- a new Query (or null if all the primary keys from obj contain a null)
- Throws:
MetaDataException
- if anything goes wrong
-
createPKQueryForPK
public void createPKQueryForPK(InterMineObject obj, boolean queryNulls, ClassDescriptor cld, PrimaryKey pk, Source source, java.util.Set<Query> returnSet) throws MetaDataException
Adds a Query to handle a primary key to a Set.- Parameters:
obj
- an InterMineObjectqueryNulls
- true to make null a valid value, false to make null ignore the keycld
- the ClassDescriptor for the keypk
- the PrimaryKeysource
- the Source of the objectreturnSet
- the Set to which the Query will be added- Throws:
MetaDataException
- if something goes wrong
-
-