Class PojoMapper


  • public class PojoMapper
    extends java.lang.Object
    Helper methods to convert IObjects into their corresponding DataObjects.
    Since:
    OME2.2
    • Constructor Summary

      Constructors 
      Constructor Description
      PojoMapper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends DataObject>
      java.util.Collection<T>
      asCastedDataObjects​(java.util.List objects)
      Converts each element of the collection into its corresponding DataObject.
      static DataObject asDataObject​(omero.model.IObject object)
      Converts the specified IObject into its corresponding DataObject.
      static <K,​V extends DataObject>
      java.util.Map<K,​V>
      asDataObjectMap​(java.lang.Class<K> keyKlass, java.lang.Class<V> valueKlass, java.lang.String method, java.util.List objects)
      Converts each element of the list to a pair (key, value) in the map.
      static java.util.Map asDataObjects​(java.util.Map objects)
      Converts each pair (key, value) of the map.
      static <T extends DataObject>
      java.util.Collection<T>
      convertToDataObjects​(java.util.Collection objects)
      Converts each element of the collection into its corresponding DataObject.
      static java.lang.String convertTypeForSearch​(java.lang.Class nodeType)
      Converts the specified type to its corresponding type for search.
      static java.lang.String getGraphType​(java.lang.Class<? extends DataObject> dataType)
      Returns the name of the data type which has to used for Graph actions, see Requests
      static java.lang.String getHQLEntityName​(java.lang.Class<? extends omero.model.IObject> clazz)
      Gets the type of an IObject class as String which can be used in HQL queries.
      static java.lang.Class<? extends omero.model.IObject> getModelType​(java.lang.Class<? extends DataObject> pojoType)
      Converts the specified POJO into the corresponding model class.
      static java.lang.Class<? extends omero.model.IObject> getModelType​(java.lang.String pojoType)
      Converts the specified POJO into the corresponding model class, see getModelType(Class)
      static java.lang.Class<? extends DataObject> getPojoType​(java.lang.Class<? extends omero.model.IObject> modelType)
      Get the pojo type for a an IObject class (Reverse of getModelType(Class))
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PojoMapper

        public PojoMapper()
    • Method Detail

      • asDataObject

        public static DataObject asDataObject​(omero.model.IObject object)
        Converts the specified IObject into its corresponding DataObject.
        Parameters:
        object - The object to convert.
        Returns:
        See above.
        Throws:
        java.lang.IllegalArgumentException - If the object is null or if the type IObject is unknown.
      • convertToDataObjects

        public static <T extends DataObject> java.util.Collection<T> convertToDataObjects​(java.util.Collection objects)
        Converts each element of the collection into its corresponding DataObject.
        Parameters:
        objects - The set of objects to convert.
        Returns:
        A set of DataObjects.
        Throws:
        java.lang.IllegalArgumentException - If the set is null, doesn't contain IObject or if the type IObject is unknown.
      • asCastedDataObjects

        public static <T extends DataObject> java.util.Collection<T> asCastedDataObjects​(java.util.List objects)
        Converts each element of the collection into its corresponding DataObject.
        Parameters:
        objects - The set of objects to convert.
        Returns:
        A set of DataObjects.
        Throws:
        java.lang.IllegalArgumentException - If the set is null, doesn't contain IObject or if the type IObject is unknown.
      • asDataObjectMap

        public static <K,​V extends DataObject> java.util.Map<K,​V> asDataObjectMap​(java.lang.Class<K> keyKlass,
                                                                                              java.lang.Class<V> valueKlass,
                                                                                              java.lang.String method,
                                                                                              java.util.List objects)
                                                                                       throws java.lang.SecurityException,
                                                                                              java.lang.NoSuchMethodException,
                                                                                              java.lang.IllegalArgumentException,
                                                                                              java.lang.IllegalAccessException,
                                                                                              java.lang.reflect.InvocationTargetException
        Converts each element of the list to a pair (key, value) in the map. The object in the list must be a IObject subclass and the key is the ID of the object.
        Parameters:
        keyKlass - The class that will be the key for the map
        valueKlass - The class that will be the value for the map
        method - The method name as a string that, using reflection, will be used to get the key from the object.
        objects - The map of objects to convert.
        Returns:
        A map of converted objects.
        Throws:
        java.lang.NoSuchMethodException
        java.lang.SecurityException
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException
        java.lang.IllegalArgumentException - If the map is null or if the type IObject is unknown.
      • asDataObjects

        public static java.util.Map asDataObjects​(java.util.Map objects)
        Converts each pair (key, value) of the map. If the key (resp. value) is an IObject, the element is converted into its corresponding DataObject.
        Parameters:
        objects - The map of objects to convert.
        Returns:
        A map of converted objects.
        Throws:
        java.lang.IllegalArgumentException - If the map is null or if the type IObject is unknown.
      • getPojoType

        public static java.lang.Class<? extends DataObject> getPojoType​(java.lang.Class<? extends omero.model.IObject> modelType)
        Get the pojo type for a an IObject class (Reverse of getModelType(Class))
        Parameters:
        modelType - The IObject
        Returns:
        See above
      • getModelType

        public static java.lang.Class<? extends omero.model.IObject> getModelType​(java.lang.String pojoType)
        Converts the specified POJO into the corresponding model class, see getModelType(Class)
        Parameters:
        pojoType - The POJO class (Either the simple or the full class name, e. g. omero.gateway.model.DatasetData or DatasetData)
        Returns:
        The corresponding IObject class.
      • getModelType

        public static java.lang.Class<? extends omero.model.IObject> getModelType​(java.lang.Class<? extends DataObject> pojoType)
        Converts the specified POJO into the corresponding model class. (Reverse of getPojoType(Class))
        Parameters:
        pojoType - The POJO class.
        Returns:
        The corresponding IObject class.
      • getGraphType

        public static java.lang.String getGraphType​(java.lang.Class<? extends DataObject> dataType)
        Returns the name of the data type which has to used for Graph actions, see Requests
        Parameters:
        dataType - The pojo type
        Returns:
        See above
      • convertTypeForSearch

        public static java.lang.String convertTypeForSearch​(java.lang.Class nodeType)
        Converts the specified type to its corresponding type for search.
        Parameters:
        nodeType - The type to convert.
        Returns:
        See above.
      • getHQLEntityName

        public static java.lang.String getHQLEntityName​(java.lang.Class<? extends omero.model.IObject> clazz)
        Gets the type of an IObject class as String which can be used in HQL queries.
        Parameters:
        clazz - The IObject
        Returns:
        See above