ome.tools.hibernate
Class ExtendedMetadata.Impl

java.lang.Object
  extended by ome.tools.spring.OnContextRefreshedEventListener
      extended by ome.tools.hibernate.ExtendedMetadata.Impl
All Implemented Interfaces:
EventListener, ExtendedMetadata, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Enclosing interface:
ExtendedMetadata

public static class ExtendedMetadata.Impl
extends OnContextRefreshedEventListener
implements ExtendedMetadata

Sole implementatino of ExtendedMetadata. The separation is intended to make unit testing without a full ExtendedMetadata possible.


Nested Class Summary
 
Nested classes/interfaces inherited from interface ome.tools.hibernate.ExtendedMetadata
ExtendedMetadata.Immutables, ExtendedMetadata.Impl, ExtendedMetadata.Locks
 
Constructor Summary
ExtendedMetadata.Impl()
           
 
Method Summary
 Set<Class<ome.model.IAnnotated>> getAnnotatableTypes()
          Returns all the classes which implement IAnnotated
 Set<Class<ome.model.annotations.Annotation>> getAnnotationTypes()
          Returns all the classes which subclass Annotation
 Set<String> getClasses()
           
 String getCountQuery(String field)
          Returns the query for obtaining the number of collection items to a particular instance.
 Class<ome.model.IObject> getHibernateClass(String table)
          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.
 String[] getImmutableFields(Class<? extends ome.model.IObject> klass)
           
 ome.model.IObject[] getLockCandidates(ome.model.IObject iObject)
          walks the IObject argument non-recursively and gathers all IObject instances which will be linkd to by the creation or updating of the argument.
 String[][] getLockChecks(Class<? extends ome.model.IObject> klass)
          returns all class/field name pairs which may possibly link to an object of type klass.
 String getRelationship(String from, String to)
          Walks both the locksHolder and the lockedByHolder data for "from" argument to see if there is any direct relationship to th "to" argument.
 Class<ome.model.IObject> getTargetType(String field)
          Returns the IObject type which a given field points to.
 void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent cre)
          Listener method which waits for a ContextRefreshedEvent and then extracts the SessionFactory from the ApplicationContext and pases it to setSessionFactory(SessionFactory).
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Initializes the metadata needed by this instance.
 
Methods inherited from class ome.tools.spring.OnContextRefreshedEventListener
onApplicationEvent, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedMetadata.Impl

public ExtendedMetadata.Impl()
Method Detail

handleContextRefreshedEvent

public void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent cre)
Listener method which waits for a ContextRefreshedEvent and then extracts the SessionFactory from the ApplicationContext and pases it to setSessionFactory(SessionFactory).

Specified by:
handleContextRefreshedEvent in class OnContextRefreshedEventListener

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Initializes the metadata needed by this instance.

Parameters:
sessionFactory -
See Also:
SessionFactory#getAllClassMetadata()

getClasses

public Set<String> getClasses()
Specified by:
getClasses in interface ExtendedMetadata

getHibernateClass

public Class<ome.model.IObject> getHibernateClass(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

getRelationship

public String getRelationship(String from,
                              String to)
Walks both the locksHolder and the lockedByHolder data for "from" argument to see if there is any direct relationship to th "to" argument. If there is, the name will be returned. Otherwise, null.

Specified by:
getRelationship in interface ExtendedMetadata

getAnnotatableTypes

public Set<Class<ome.model.IAnnotated>> getAnnotatableTypes()
Description copied from interface: ExtendedMetadata
Returns all the classes which implement IAnnotated

Specified by:
getAnnotatableTypes in interface ExtendedMetadata

getAnnotationTypes

public Set<Class<ome.model.annotations.Annotation>> getAnnotationTypes()
Description copied from interface: ExtendedMetadata
Returns all the classes which subclass Annotation

Specified by:
getAnnotationTypes 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 linkd 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 String[][] getLockChecks(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.
See Also:
Permissions.Flag#LOCKED

getImmutableFields

public String[] getImmutableFields(Class<? extends ome.model.IObject> klass)

getCountQuery

public String getCountQuery(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.

getTargetType

public Class<ome.model.IObject> getTargetType(String field)
                                       throws ome.conditions.ApiUsageException
Returns the IObject type which a given field points to. E.g. getTargetType(ImageAnnotation.IMAGE) returns Image.class.

Throws:
ome.conditions.ApiUsageException


OmeroJava Api

Version: 4.3.3-00d1137e-b2894

Copyright © 2009 The University of Dundee. All Rights Reserved.