Package org.intermine.dataloader
Class DataLoaderHelper
- java.lang.Object
-
- org.intermine.dataloader.DataLoaderHelper
-
public final class DataLoaderHelper extends java.lang.Object
Class providing utility methods to help with primary key and data source priority configuration- Author:
- Andrew Varley, Mark Woodbridge, Richard Smith, Matthew Wakeling
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<Model,java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
modelDescriptors
protected static java.util.Map<Source,java.util.Properties>
sourceKeys
protected static java.util.Set<Source>
verifiedSources
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
fieldIsPrimaryKey(Model model, java.lang.Class<?> clazz, java.lang.String fieldName, Source source)
Returns true if the given field is a member of any primary key on the given class, for the given source.protected static java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getDescriptors(Model model)
Build a map from class and field names to a priority-ordered List of source name Strings.protected static java.util.Properties
getKeyProperties(Source source)
Return the Properties that enumerate the keys for this Sourcestatic java.util.Set<PrimaryKey>
getPrimaryKeys(ClassDescriptor cld, Source source, ObjectStore os)
Return a Set of PrimaryKeys relevant to a given Source for a ClassDescriptor.static java.util.Set<PrimaryKey>
getSourcePrimaryKeys(Source source, Model model)
Fetch all primary keys for the given source.static boolean
objectPrimaryKeyNotNull(Model model, InterMineObject obj, ClassDescriptor cld, PrimaryKey pk, Source source, IntToIntMap idMap)
Look a the values of the given primary key in the object and return true if and only if some part of the primary key is null.
-
-
-
Field Detail
-
sourceKeys
protected static java.util.Map<Source,java.util.Properties> sourceKeys
-
modelDescriptors
protected static java.util.Map<Model,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> modelDescriptors
-
verifiedSources
protected static java.util.Set<Source> verifiedSources
-
-
Method Detail
-
getDescriptors
protected static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getDescriptors(Model model)
Build a map from class and field names to a priority-ordered List of source name Strings.- Parameters:
model
- the Model- Returns:
- the Map
-
getPrimaryKeys
public static java.util.Set<PrimaryKey> getPrimaryKeys(ClassDescriptor cld, Source source, ObjectStore os)
Return a Set of PrimaryKeys relevant to a given Source for a ClassDescriptor. The Set contains all the primary keys that exist on a particular class that are used by the source, without performing any recursion. The Model.getClassDescriptorsForClass() method is recommended if you wish for all the primary keys of the class' parents as well.- Parameters:
cld
- the ClassDescriptorsource
- the Sourceos
- the ObjectStore that these PrimaryKeys are used in, for creating indexes- Returns:
- a Set of PrimaryKeys
-
getSourcePrimaryKeys
public static java.util.Set<PrimaryKey> getSourcePrimaryKeys(Source source, Model model)
Fetch all primary keys for the given source. Parses source keys properties file, can handle both 'old style' key definitions (key name used in source, details found in keyDefs file) and 'new style' where whole key is defined in the source properties file.- Parameters:
source
- name of source to fetch keys formodel
- the data model- Returns:
- a set of primary key objects
-
getKeyProperties
protected static java.util.Properties getKeyProperties(Source source)
Return the Properties that enumerate the keys for this Source- Parameters:
source
- the Source- Returns:
- the relevant Properties
-
objectPrimaryKeyNotNull
public static boolean objectPrimaryKeyNotNull(Model model, InterMineObject obj, ClassDescriptor cld, PrimaryKey pk, Source source, IntToIntMap idMap) throws MetaDataException
Look a the values of the given primary key in the object and return true if and only if some part of the primary key is null. If the primary key contains a reference it is sufficient for any of the primary keys of the referenced object to be non-null (ie objectPrimaryKeyIsNull() returning true).- Parameters:
model
- the Model in which to find ClassDescriptorsobj
- the Object to checkcld
- one of the classes that obj is. Only primary keys for this classes will be checkedpk
- the primary key to checksource
- the Source databaseidMap
- an IntToIntMap from source IDs to destination IDs- Returns:
- true if the the given primary key is non-null for the given object
- Throws:
MetaDataException
- if anything goes wrong
-
fieldIsPrimaryKey
public static boolean fieldIsPrimaryKey(Model model, java.lang.Class<?> clazz, java.lang.String fieldName, Source source)
Returns true if the given field is a member of any primary key on the given class, for the given source.- Parameters:
model
- the Model in which to find ClassDescriptorsclazz
- the Class in which to lookfieldName
- the name of the field to checksource
- the Source that the keys belong to- Returns:
- true if the field is a primary key
-
-