Class ExtendedMetadata.Impl

    • Constructor Detail

      • Impl

        public Impl()
    • Method Detail

      • setSessionFactory

        public void setSessionFactory​(org.hibernate.SessionFactory sessionFactory)
        Initializes the metadata needed by this instance.
        Parameters:
        sessionFactory - the Hibernate session factory
        See Also:
        SessionFactory.getAllClassMetadata()
      • getHibernateClass

        public java.lang.Class<ome.model.IObject> getHibernateClass​(java.lang.String table)
        Description copied from interface: ExtendedMetadata
        Given the name of a database table or alternatively the simple class name (non-fully qualified) of an IObject, this method returns the class which Hibernate will map that table to.
        Specified by:
        getHibernateClass in interface ExtendedMetadata
        Parameters:
        table - a database table name, or simple class name of a model object
        Returns:
        the corresponding mapped class
      • getRelationship

        public java.lang.String getRelationship​(java.lang.String from,
                                                java.lang.String to)
        Walks the data on what locks what for "from" argument to see if there is any direct relationship to the "to" argument. If there is, the name will be returned. Otherwise, null.
        Specified by:
        getRelationship in interface ExtendedMetadata
      • getSQLJoin

        public java.lang.String getSQLJoin​(java.lang.String fromType,
                                           java.lang.String fromAlias,
                                           java.lang.String toType,
                                           java.lang.String toAlias)
        Note: this implementation does not yet take into account the mapping of joined subclasses like Job -> UpdateJob.
        Specified by:
        getSQLJoin in interface ExtendedMetadata
      • getLockCandidates

        public ome.model.IObject[] getLockCandidates​(ome.model.IObject iObject)
        walks the IObject argument non-recursively and gathers all IObject instances which will be linked to by the creation or updating of the argument. (Previously this was called "locking" since a flag was set on the object to mark it as linked, but this was removed in 4.2)
        Specified by:
        getLockCandidates in interface ExtendedMetadata
        Parameters:
        iObject - A newly created or updated IObject instance which might possibly lock other IObjects. A null argument will return an empty array to be checked.
        Returns:
        A non-null array of IObjects which will be linked to.
      • getLockChecks

        public java.lang.String[][] getLockChecks​(java.lang.Class<? extends ome.model.IObject> klass)
        returns all class/field name pairs which may possibly link to an object of type klass.
        Specified by:
        getLockChecks in interface ExtendedMetadata
        Parameters:
        klass - Non-null subclass of IObject
        Returns:
        A non-null array of String queries which can be used to determine if an IObject instance can be unlocked.
      • countLocks

        public java.util.Map<java.lang.String,​java.lang.Long> countLocks​(org.hibernate.Session session,
                                                                               java.lang.Long id,
                                                                               java.lang.String[][] checks,
                                                                               java.lang.String clause)
        Description copied from interface: ExtendedMetadata
        Takes the lock checks returned by ExtendedMetadata.getLockChecks(Class) and performs the actual check returning a map from class to total number of locks. The key "*" contains the total value. If the id argument is null, then checks will be against all rows rather than individual objects, e.g.
         select count(x) from Linker x, Linked y where x.$FIELD.id = y.id $CLAUSE;
         
        otherwise
         select count(x) from Linker x where x.$FIELD.id = :id $CLAUSE'
         
        If the clause argument is null or empty it will be omitted.
        Specified by:
        countLocks in interface ExtendedMetadata
      • getImmutableFields

        public java.lang.String[] getImmutableFields​(java.lang.Class<? extends ome.model.IObject> klass)
      • getCountQuery

        public java.lang.String getCountQuery​(java.lang.String field)
                                       throws ome.conditions.ApiUsageException
        Returns the query for obtaining the number of collection items to a particular instance. All such queries will return a ResultSet with rows of the form: 0 (Long) id of the locked class 1 (Long) count of the instances locking that class
        Specified by:
        getCountQuery in interface ExtendedMetadata
        Parameters:
        field - Field name as specified in the class.
        Returns:
        String query. Never null.
        Throws:
        ome.conditions.ApiUsageException - if return value would be null.
      • mayHaveMapProperties

        public boolean mayHaveMapProperties​(java.lang.Class<? extends ome.model.IObject> iObjectClass)
        Description copied from interface: ExtendedMetadata
        Check if an object of this class may have map properties.
        Specified by:
        mayHaveMapProperties in interface ExtendedMetadata
        Parameters:
        iObjectClass - a class
        Returns:
        if this object or any of its mapped subclasses have any map properties
      • getMapProperties

        public java.util.Set<java.lang.String> getMapProperties​(java.lang.String className)
        Description copied from interface: ExtendedMetadata
        Get the names of any String→RString map properties this class has, otherwise an empty set if none.
        Specified by:
        getMapProperties in interface ExtendedMetadata
        Parameters:
        className - the name of a class, as from Class.getName()
        Returns:
        the class' map property names