org.intermine.api.bag
Class TypeConverter

java.lang.Object
  extended by org.intermine.api.bag.TypeConverter

public final class TypeConverter
extends java.lang.Object

Static helper routines to convert bags between different types.


Method Summary
static PathQuery getConversionMapQuery(java.util.List<TemplateQuery> conversionTemplates, java.lang.Class typeA, java.lang.Class typeB, java.lang.Object bagOrIds)
          Get conversion query for the types provided, edited so that the first type is constrained to be in the bag.
static PathQuery getConversionQuery(java.util.List<TemplateQuery> conversionTemplates, java.lang.Class<?> typeA, java.lang.Class<?> typeB, java.lang.Object bagOrIds)
          Get conversion query for the types provided, edited so that the first type is constrained to be in the bag and the first type is removed from the view list so that the query only returns the converted type.
static java.util.Map<java.lang.Class,TemplateQuery> getConversionTemplates(java.util.List<TemplateQuery> conversionTemplates, java.lang.Class typeA)
          Return a Map from typeB to a TemplateQuery that will convert from typeA to typeB.
static java.util.Map<InterMineObject,java.util.List<InterMineObject>> getConvertedObjectMap(java.util.List<TemplateQuery> conversionTemplates, java.lang.Class<?> typeA, java.lang.Class<?> typeB, java.lang.Object bagOrIds, ObjectStore os)
          Converts a List of objects from one type to another type using a TemplateQuery, returns a map from an original object to the converted object(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConvertedObjectMap

public static java.util.Map<InterMineObject,java.util.List<InterMineObject>> getConvertedObjectMap(java.util.List<TemplateQuery> conversionTemplates,
                                                                                                   java.lang.Class<?> typeA,
                                                                                                   java.lang.Class<?> typeB,
                                                                                                   java.lang.Object bagOrIds,
                                                                                                   ObjectStore os)
                                                                                            throws InterMineException
Converts a List of objects from one type to another type using a TemplateQuery, returns a map from an original object to the converted object(s).

Parameters:
conversionTemplates - a list of templates to be used for conversion
typeA - the type to convert from
typeB - the type to convert to
bagOrIds - an InterMineBag or Collection of Integer object ids
os - the ObjectStore to execute queries in
Returns:
a Map from original object to a List of converted objects, or null if conversion is possible (because no suitable template is available)
Throws:
InterMineException - if an error occurs

getConversionMapQuery

public static PathQuery getConversionMapQuery(java.util.List<TemplateQuery> conversionTemplates,
                                              java.lang.Class typeA,
                                              java.lang.Class typeB,
                                              java.lang.Object bagOrIds)
Get conversion query for the types provided, edited so that the first type is constrained to be in the bag.

Parameters:
conversionTemplates - a list of templates to be used for conversion
typeA - the type to convert from
typeB - the type to convert to
bagOrIds - an InterMineBag or Collection of Integer object ids
Returns:
a PathQuery that finds a conversion mapping for the given bag

getConversionQuery

public static PathQuery getConversionQuery(java.util.List<TemplateQuery> conversionTemplates,
                                           java.lang.Class<?> typeA,
                                           java.lang.Class<?> typeB,
                                           java.lang.Object bagOrIds)
Get conversion query for the types provided, edited so that the first type is constrained to be in the bag and the first type is removed from the view list so that the query only returns the converted type.

Parameters:
conversionTemplates - a list of templates to be used for conversion
typeA - the type to convert from
typeB - the type to convert to
bagOrIds - an InterMineBag or Collection of Integer object identifiers
Returns:
a PathQuery that finds converted objects for the given bag

getConversionTemplates

public static java.util.Map<java.lang.Class,TemplateQuery> getConversionTemplates(java.util.List<TemplateQuery> conversionTemplates,
                                                                                  java.lang.Class typeA)
Return a Map from typeB to a TemplateQuery that will convert from typeA to typeB.

Parameters:
conversionTemplates - a list of templates to be used for conversion
typeA - the type to convert from
Returns:
a Map from Class to TemplateQuery