Package ome.api

Interface IContainer

  • All Superinterfaces:
    ServiceInterface

    public interface IContainer
    extends ServiceInterface
    Provides methods for dealing with the core "Pojos" of OME. Included are: Projects, Datasets, Images.

    Read API

    The names of the methods correlate to how the function operates:

    • load: start at container objects and work down toward the leaves, returning hierarchy (Project->Dataset->Image
    • find: start at leaf objects and work up to containers, returning hierarchy
    • get: retrieves only leaves in the hierarchy (currently only Images)

    Options Mechanism

    The options are used to add some constraints to the generic method e.g. load hierarchy trees images for a given user. This mechanism should give us enough flexibility to extend the API if necessary, e.g. in some cases we might want to retrieve the images with or without annotations

    Most methods take such an options map which is built on the client-side using the Parameters class. The currently supported options are:

    • annotator(Integer): If key exists but value null, annotations are retrieved for all objects in the hierarchy where they exist; if a valid experimenterID, annotations are only retrieved for that user. May not be used be all methods. Default: all annotations
    • leaves(Boolean): if FALSE omits images from the returned hierarchy. May not be used by all methods. Default: true
    • experimenter(Integer): enables filtering on a per-experimenter basis. This option has a method-specific (and possibly context-specific) meaning. Please see the individual methods.
    • group(Integer): enables filtering on a per-group basis. The experimenter value is ignored if present and instead a similar filtering is done using all experimenters in the given group.

      Write API

      As outlined in TODO, the semantics of the Omero write API are based on three rules:

      1. IObject-valued fields for which isLoaded() returns false are assumed filtered
      2. Collection-valued fields that are null are assumed filtered
      3. Collection-valued fields for which getDetails().isFiltered(String collectionName) returns true are assumed filtered. TODO: should we accept isFiltered for all fields?
      In each of these cases, the server will reload that given field before attempting to save the graph.

      For all write calls, the options map (see below) must contain the userId and the userGroupId for the newly created objects. TODO umask.

    Since:
    OME1.0 TODO possibly move optionBuilder to the common code. ome.common.utils TODO possibly move map description to marker interface with a see also link TODO add throws statements where necessary (IllegalArgument, ...)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T extends ome.model.IObject>
      T
      createDataObject​(T object, ome.parameters.Parameters options)
      Creates the specified data object.
      ome.model.IObject[] createDataObjects​(ome.model.IObject[] dataObjects, ome.parameters.Parameters options)
      convenience method to save network calls.
      <T extends ome.model.IObject>
      java.util.Set<ome.model.IObject>
      findContainerHierarchies​(java.lang.Class<T> rootNodeType, java.util.Set<java.lang.Long> imagesIds, ome.parameters.Parameters options)
      Retrieves hierarchy trees in various hierarchies that contain the specified Images.
      java.util.Map getCollectionCount​(java.lang.String type, java.lang.String property, java.util.Set<java.lang.Long> ids, ome.parameters.Parameters options)
      Counts the number of members in a collection for a given object.
      <T extends ome.model.IObject>
      java.util.Set<ome.model.core.Image>
      getImages​(java.lang.Class<T> rootNodeType, java.util.Set<java.lang.Long> rootNodeIds, ome.parameters.Parameters options)
      Retrieve a user's (or all users') images within any given container.
      java.util.Set<ome.model.core.Image> getImagesByOptions​(ome.parameters.Parameters options)
      Retrieve images by options.
      java.util.Map<java.lang.Long,​java.util.Map<java.lang.Boolean,​java.util.List<java.lang.Long>>> getImagesBySplitFilesets​(java.util.Map<java.lang.Class<? extends ome.model.IObject>,​java.util.List<java.lang.Long>> included, ome.parameters.Parameters options)
      Given a list of IDs of certain entity types, calculates which filesets are split such that a non-empty proper subset of their images are referenced, directly or indirectly, as being included.
      java.util.Set<ome.model.core.Image> getUserImages​(ome.parameters.Parameters options)
      Retrieve a user's images.
      ome.model.ILink[] link​(ome.model.ILink[] dataObjectLinks, ome.parameters.Parameters options)
      Convenience method for creating links.
      <T extends ome.model.IObject>
      java.util.Set<ome.model.IObject>
      loadContainerHierarchy​(java.lang.Class<T> rootNodeType, java.util.Set<java.lang.Long> rootNodeIds, ome.parameters.Parameters options)
      Retrieves hierarchy trees rooted by a given node (unless orphan is specified -- See below)
      java.util.Collection retrieveCollection​(ome.model.IObject dataObject, java.lang.String collectionName, ome.parameters.Parameters options)
      Retrieves a collection with all members initialized ("loaded").
      void unlink​(ome.model.ILink[] dataObjectLinks, ome.parameters.Parameters options)
      Removes links between OmeroDataObjects e.g Project-Dataset, Dataset-Image Note that the objects themselves aren't deleted, only the Link objects.
      <T extends ome.model.IObject>
      T
      updateDataObject​(T dataObject, ome.parameters.Parameters options)
      Updates a data object.
      ome.model.IObject[] updateDataObjects​(ome.model.IObject[] dataObjects, ome.parameters.Parameters options)
      convenience method to save network calls.
    • Method Detail

      • loadContainerHierarchy

        <T extends ome.model.IObject> java.util.Set<ome.model.IObject> loadContainerHierarchy​(java.lang.Class<T> rootNodeType,
                                                                                              java.util.Set<java.lang.Long> rootNodeIds,
                                                                                              ome.parameters.Parameters options)
        Retrieves hierarchy trees rooted by a given node (unless orphan is specified -- See below)

        This method also retrieves the Experimenters linked to the objects in the tree. Similarly, all Images will be linked to their Pixel objects if included.

        Note that objects are never duplicated. For example, if an Experimenter owns all the objects in the retrieved tree, then those objects will be linked to the same instance of Experimenter. Or if an Image is contained in more than one Dataset in the retrieved tree, then all enclosing Dataset objects will point to the same Image object. And so on.

        Parameters:
        rootNodeType - The type of the root node. Can be Project, Dataset, Screen or Plate. Cannot be null.
        rootNodeIds - The ids of the root nodes. Can be null if an Experimenter is specified in options, otherwise an Exception is thrown to prevent all images in the entire database from being downloaded.
        options - Parameters as above. annotator, leaves, orphan, acquisition data used. acquisition data is only relevant for images and taken into account if the images are loaded. If rootNodeIds==null, experimenter|group must be set and filtering will be applied at the Class-level; e.g. to retrieve a user's Projects, or user's Datasets. If rootNodeIds!=null, the result will be filtered by the experimenter|group at the Image and intermediate levels if available. Due to the amount of data potentially linked a Screen/Plate, the leaves option is not taken into account. when the root node is a Screen. orphan implies that objects which are not contained in an object of rootNodeType should also be returned. TODO should it be applied at all levels?
        Returns:
        a set of hierarchy trees. The requested node as root and all of its descendants. The type of the returned value will be rootNodeType, unless orphan is specified in which case objects of type rootNodeType and below may be returned.
      • findContainerHierarchies

        <T extends ome.model.IObject> java.util.Set<ome.model.IObject> findContainerHierarchies​(java.lang.Class<T> rootNodeType,
                                                                                                java.util.Set<java.lang.Long> imagesIds,
                                                                                                ome.parameters.Parameters options)
        Retrieves hierarchy trees in various hierarchies that contain the specified Images.

        This method will look for all the containers containing the specified Images and then for all containers containing those containers and on up the container hierarchy.

        This method returns a Set with all root nodes that were found. Every root node is linked to the found objects and so on until the leaf nodes, which are Image objects. Note that the type of any root node in the returned set can be the given rootNodeType, any of its containees or an image.

        For example, say that you pass in the ids of six Images: i1, i2, i3, i4, i5, i6. If the P/D/I hierarchy in the DB looks like this:

                           __p1__
                          /      \    
                        _d1_    _d2_      d3
                       /    \  /    \     |
                      i1     i2     i3    i4    i5  i6
         

        Then the returned set will contain p1, d3, i5, i6. All objects will be properly linked up.

        Finally, this method will only retrieve the nodes that are connected in a tree to the specified leaf image nodes. Back to the previous example, if d1 contained image img500, then the returned object would not contain img500. In a similar way, if p1 contained ds300 and this dataset weren't linked to any of the i1, i2, i3, i4, i5, i6 images, then ds300 would not be part of the returned tree rooted by p1.

        Parameters:
        rootNodeType - top-most type which will be searched for Can be Project. Not null.
        imagesIds - Contains the ids of the Images that sit at the bottom of the trees. Not null.
        options - Parameters as above. annotator used. experimenter|group may be applied at the top-level only or at each level in the hierarchy, but will not apply to the leaf (Image) level.
        Returns:
        A Set with all root nodes that were found. TODO decide on use of experimenter option
      • getImages

        <T extends ome.model.IObject> java.util.Set<ome.model.core.Image> getImages​(java.lang.Class<T> rootNodeType,
                                                                                    java.util.Set<java.lang.Long> rootNodeIds,
                                                                                    ome.parameters.Parameters options)
        Retrieve a user's (or all users') images within any given container. For example, all images in project, applying temporal filtering or pagination.
        Parameters:
        rootNodeType - A Class which will have its hierarchy searched for Images. Not null. TODO types?
        rootNodeIds - A set of ids of type rootNodeType Not null.
        options - Parameters as above. No notion of leaves. experimenter|group apply at the Image level. OPTIONS: - startTime and/or endTime should be Timestamp.valueOf("YYYY-MM-DD hh:mm:ss.ms");

        limit and offset are applied at the Image-level. That is, calling with Dataset.class, limit == 10 and offset == 0 will first perform one query to get an effective set of rootNodeIds, then getImages will be called with an effective rootNodeType of Image.class and the new ids.

        . acquisition data is only relevant for images.
        Returns:
        A set of images.
        See Also:
        Parameters.paginate(Integer, Integer), Parameters.startTime(java.sql.Timestamp), Parameters.endTime(java.sql.Timestamp)
      • getImagesByOptions

        java.util.Set<ome.model.core.Image> getImagesByOptions​(ome.parameters.Parameters options)
        Retrieve images by options.
        Parameters:
        options - Parameters as above. No notion of leaves. experimenter|group apply at the Image level and must be present. OPTIONS: - startTime and/or endTime should be Timestamp.valueOf("YYYY-MM-DD hh:mm:ss.ms"). acquisition data is only relevant for images.
        Returns:
        A set of images.
      • getUserImages

        java.util.Set<ome.model.core.Image> getUserImages​(ome.parameters.Parameters options)
        Retrieve a user's images.
        Parameters:
        options - Parameters as above. No notion of leaves. experimenter|group apply at the Image level and must be present.
        Returns:
        A set of images.
      • getCollectionCount

        java.util.Map getCollectionCount​(java.lang.String type,
                                         java.lang.String property,
                                         java.util.Set<java.lang.Long> ids,
                                         ome.parameters.Parameters options)
        Counts the number of members in a collection for a given object. For example, if you wanted to retrieve the number of Images contained in a Dataset you would pass TODO.
        Parameters:
        type - The fully-qualified classname of the object to be tested
        property - Name of the property on that class, omitting getters and setters.
        ids - Set of Longs, the ids of the objects to test
        options - Parameters. Unused.
        Returns:
        A map from id integer to count integer
      • getImagesBySplitFilesets

        java.util.Map<java.lang.Long,​java.util.Map<java.lang.Boolean,​java.util.List<java.lang.Long>>> getImagesBySplitFilesets​(java.util.Map<java.lang.Class<? extends ome.model.IObject>,​java.util.List<java.lang.Long>> included,
                                                                                                                                           ome.parameters.Parameters options)
        Given a list of IDs of certain entity types, calculates which filesets are split such that a non-empty proper subset of their images are referenced, directly or indirectly, as being included. The return value lists both the fileset IDs and the image IDs in ascending order, the image ID lists separated by if they were included. Warning: following discussion in trac ticket 11019 the return type may be changed.
        Parameters:
        included - the entities included
        options - parameters, presently ignored
        Returns:
        the partially included filesets
      • retrieveCollection

        java.util.Collection retrieveCollection​(ome.model.IObject dataObject,
                                                java.lang.String collectionName,
                                                ome.parameters.Parameters options)
        Retrieves a collection with all members initialized ("loaded"). This is useful when a collection has been nulled in a previous query.
        Parameters:
        dataObject - Can be "unloaded".
        collectionName - public final static String from the IObject.class
        options - Parameters. Unused.
        Returns:
        An initialized collection.
      • createDataObject

        <T extends ome.model.IObject> T createDataObject​(T object,
                                                         ome.parameters.Parameters options)
        Creates the specified data object.

        A placeholder parent object is created if the data object is to be put in a collection.

        For example, if the object is a Dataset, we first create a Project as parent then we set the Dataset parent as follows: //pseudo-code TODO Project p = new Project(id,false); dataset.addProject(p); then for each parent relationship a DataObject ILink is created.

        Parameters:
        object - IObject. Supported: Project, Dataset, Annotation, Group, Experimenter. Not null.
        options - Parameters as above.
        Returns:
        the created object
      • createDataObjects

        ome.model.IObject[] createDataObjects​(ome.model.IObject[] dataObjects,
                                              ome.parameters.Parameters options)
        convenience method to save network calls. Loops over the array of IObjects calling createDataObject.
        Parameters:
        dataObjects - Array of Omero IObjects
        options - Parameters as above.
        See Also:
        createDataObject(IObject, Parameters)
      • unlink

        void unlink​(ome.model.ILink[] dataObjectLinks,
                    ome.parameters.Parameters options)
        Removes links between OmeroDataObjects e.g Project-Dataset, Dataset-Image Note that the objects themselves aren't deleted, only the Link objects.
        Parameters:
        dataObjectLinks - Not null.
        options - Parameters as above.
      • link

        ome.model.ILink[] link​(ome.model.ILink[] dataObjectLinks,
                               ome.parameters.Parameters options)
        Convenience method for creating links. Functionality also availeble from createDataObject(IObject, Parameters)
        Parameters:
        dataObjectLinks - Array of links to be created.
        options - Parameters as above.
        Returns:
        the created links
      • updateDataObject

        <T extends ome.model.IObject> T updateDataObject​(T dataObject,
                                                         ome.parameters.Parameters options)
        Updates a data object.

        To link or unlink objects to the specified object, we should call the methods link or unlink. TODO Or do we use for example dataset.setProjects(set of projects) to add. Link has to be set as follows dataset to project and project to dataset. Alternatively, you can make sure that the collection is exactly how it should be in the database. If you can't guarantee this, it's best to send all your collections back as null

        Parameters:
        dataObject - Pojos-based IObject. Supported: supported: Project, Dataset, Annotation, Group, Experimenter.
        options - Parameters as above.
        Returns:
        created data object
      • updateDataObjects

        ome.model.IObject[] updateDataObjects​(ome.model.IObject[] dataObjects,
                                              ome.parameters.Parameters options)
        convenience method to save network calls. Loops over the array of IObjects calling updateDataObject.
        Parameters:
        dataObjects -
        options - Parameters as above.
        Returns:
        created data objects.
        See Also:
        updateDataObject(IObject, Parameters)