org.intermine.dataloader
Class IntegrationWriterDataTrackingImpl

java.lang.Object
  extended by org.intermine.dataloader.IntegrationWriterAbstractImpl
      extended by org.intermine.dataloader.IntegrationWriterDataTrackingImpl
All Implemented Interfaces:
IntegrationWriter, ObjectStore, ObjectStoreWriter

public class IntegrationWriterDataTrackingImpl
extends IntegrationWriterAbstractImpl

Priority-based implementation of IntegrationWriter. Allows field values to be chosen according to the relative priorities of the data sources that originated them.


Field Summary
protected  DataTracker dataTracker
           
protected  IntPresentSet duplicateObjects
          This is a list of the objects in the destination database that we have written to as a non-skeleton more than once.
protected  boolean isDuplicates
           
protected  PriorityConfig priorityConfig
           
protected  IntPresentSet pureObjects
          This is a list of the objects that did not merge with anything from a previous data source
protected  IntPresentSet skeletons
           
protected  java.util.Set<java.lang.Class<?>> trackerMissingClasses
           
protected  IntPresentSet writtenObjects
          This is a list of the objects in the destination database that we have written to as a non-skeleton.
 
Fields inherited from class org.intermine.dataloader.IntegrationWriterAbstractImpl
beof, dbIdsStored, eof, FROM_DB, idMap, idMapOps, ignoreDuplicates, lastSource, osw, seenBrokenOneToMany, SKELETON, SOURCE, timeSpentRecursing
 
Fields inherited from interface org.intermine.objectstore.ObjectStore
SEQUENCE_IGNORE
 
Constructor Summary
IntegrationWriterDataTrackingImpl(ObjectStoreWriter osw, DataTracker dataTracker)
          Constructs a new instance of IntegrationWriterDataTrackingImpl.
IntegrationWriterDataTrackingImpl(ObjectStoreWriter osw, DataTracker dataTracker, java.util.Set<java.lang.Class<?>> trackerMissingClasses)
          Constructs a new instance of IntegrationWriterDataTrackingImpl.
 
Method Summary
 void close()
          Closes the connection associated with this ObjectStoreWriter
 boolean doTrackerFor(java.lang.Class<?> c)
          Returns true if the given class is NOT a subclass of any of the classes in trackerMissingClasses.
protected  DataTracker getDataTracker()
          Returns the data tracker being used.
static IntegrationWriterDataTrackingImpl getInstance(java.lang.String osAlias, java.util.Properties props)
          Creates a new instance of this class, given the properties defining it.
protected static IntegrationWriterDataTrackingImpl getInstance(java.lang.String osAlias, java.util.Properties props, java.lang.Class<? extends IntegrationWriterDataTrackingImpl> iwClass, java.lang.Class<? extends DataTracker> trackerClass)
          Creates a new IntegrationWriter instance of the specified class and with a specified DataTracker class plus properties.
 Source getMainSource(java.lang.String name, java.lang.String type)
          Converts a string describing the data source into a Source object suitable for passing to the store method as the main source.
 Source getSkeletonSource(java.lang.String name, java.lang.String type)
          Converts a string describing the data source into a Source object suitable for passing to the store method as the skeleton source.
 void reset()
          Resets the IntegrationWriter, clearing the id map and the hints
protected  InterMineObject store(FastPathObject nimo, Source source, Source skelSource, int type)
          Stores the given object in the objectstore.
 
Methods inherited from class org.intermine.dataloader.IntegrationWriterAbstractImpl
abortTransaction, addAllToBag, addToBag, addToBagFromQuery, addToCollection, assignMapping, batchCommitTransaction, beginTransaction, cacheObjectById, commitTransaction, copyField, count, createClob, createObjectStoreBag, delete, delete, estimate, execute, execute, execute, executeSingleton, executeSingleton, flushObjectById, getBaseEof, getComponentsForQuery, getEquivalentObjects, getMaxLimit, getMaxOffset, getMaxTime, getModel, getNewWriter, getObjectByExample, getObjectById, getObjectById, getObjectsByIds, getObjectStore, getObjectStoreWriter, getSequence, getSerial, invalidateObjectById, isInTransaction, isMultiConnection, pilferObjectById, prefetchObjectById, removeAllFromBag, removeFromBag, replaceClob, setEof, setIgnoreDuplicates, store, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataTracker

protected DataTracker dataTracker

trackerMissingClasses

protected java.util.Set<java.lang.Class<?>> trackerMissingClasses

skeletons

protected IntPresentSet skeletons

pureObjects

protected IntPresentSet pureObjects
This is a list of the objects that did not merge with anything from a previous data source


writtenObjects

protected IntPresentSet writtenObjects
This is a list of the objects in the destination database that we have written to as a non-skeleton. This is so that we can notice if we write to a given object twice, given ignoreDuplicates, so we can tell the user if ignoreDuplicates is necessary.


duplicateObjects

protected IntPresentSet duplicateObjects
This is a list of the objects in the destination database that we have written to as a non-skeleton more than once.


isDuplicates

protected boolean isDuplicates

priorityConfig

protected PriorityConfig priorityConfig
Constructor Detail

IntegrationWriterDataTrackingImpl

public IntegrationWriterDataTrackingImpl(ObjectStoreWriter osw,
                                         DataTracker dataTracker)
Constructs a new instance of IntegrationWriterDataTrackingImpl.

Parameters:
osw - an instance of an ObjectStoreWriter, which we can use to access the database
dataTracker - an instance of DataTracker, which we can use to store data tracking information

IntegrationWriterDataTrackingImpl

public IntegrationWriterDataTrackingImpl(ObjectStoreWriter osw,
                                         DataTracker dataTracker,
                                         java.util.Set<java.lang.Class<?>> trackerMissingClasses)
Constructs a new instance of IntegrationWriterDataTrackingImpl.

Parameters:
osw - an instance of an ObjectStoreWriter, which we can use to access the database
dataTracker - an instance of DataTracker, which we can use to store data tracking information
trackerMissingClasses - a Set of classes for which DataTracker data is useless
Method Detail

getInstance

public static IntegrationWriterDataTrackingImpl getInstance(java.lang.String osAlias,
                                                            java.util.Properties props)
                                                     throws ObjectStoreException
Creates a new instance of this class, given the properties defining it.

Parameters:
osAlias - the alias of this objectstore
props - the Properties
Returns:
an instance of this class
Throws:
ObjectStoreException - sometimes

getInstance

protected static IntegrationWriterDataTrackingImpl getInstance(java.lang.String osAlias,
                                                               java.util.Properties props,
                                                               java.lang.Class<? extends IntegrationWriterDataTrackingImpl> iwClass,
                                                               java.lang.Class<? extends DataTracker> trackerClass)
                                                        throws ObjectStoreException
Creates a new IntegrationWriter instance of the specified class and with a specified DataTracker class plus properties.

Parameters:
osAlias - the alias of this objectstore
props - the Properties
iwClass - Class of IntegrationWriter to create - IntegrationWriterDataTrackingImpl or a subclass.
trackerClass - Class of DataTracker to use with IntegrationWriter
Returns:
an instance of this class
Throws:
ObjectStoreException - sometimes

reset

public void reset()
Resets the IntegrationWriter, clearing the id map and the hints

Overrides:
reset in class IntegrationWriterAbstractImpl

getMainSource

public Source getMainSource(java.lang.String name,
                            java.lang.String type)
Converts a string describing the data source into a Source object suitable for passing to the store method as the main source.

Parameters:
name - the name of the data source
type - the source type
Returns:
a Source

getSkeletonSource

public Source getSkeletonSource(java.lang.String name,
                                java.lang.String type)
Converts a string describing the data source into a Source object suitable for passing to the store method as the skeleton source.

Parameters:
name - the name of the data source
type - the source type
Returns:
a skeleton Source

getDataTracker

protected DataTracker getDataTracker()
Returns the data tracker being used.

Returns:
dataTracker

doTrackerFor

public boolean doTrackerFor(java.lang.Class<?> c)
Returns true if the given class is NOT a subclass of any of the classes in trackerMissingClasses.

Parameters:
c - a Class
Returns:
a boolean

store

protected InterMineObject store(FastPathObject nimo,
                                Source source,
                                Source skelSource,
                                int type)
                         throws ObjectStoreException
Stores the given object in the objectstore. This method recurses into the object's fields according to the type variable.

Specified by:
store in class IntegrationWriterAbstractImpl
Parameters:
nimo - the object to store
source - the data Source to which to attribute the data
skelSource - the data Source to which to attribute skeleton data
type - the type of action required, from SOURCE, SKELETON, or FROM_DB
Returns:
the InterMineObject that was written to the database
Throws:
ObjectStoreException - if an error occurs in the underlying objectstore

close

public void close()
           throws ObjectStoreException
Closes the connection associated with this ObjectStoreWriter

Specified by:
close in interface ObjectStoreWriter
Overrides:
close in class IntegrationWriterAbstractImpl
Throws:
ObjectStoreException - if something goes wrong