ome.tools.hibernate
Class ExtendedMetadata

java.lang.Object
  extended by ome.tools.hibernate.ExtendedMetadata
All Implemented Interfaces:
EventListener, org.springframework.context.ApplicationListener

public class ExtendedMetadata
extends Object
implements org.springframework.context.ApplicationListener

extension of the model metadata provided by SessionFactory. During construction, the metadata is created and cached for later use.

Since:
3.0-M3
Version:
$Revision: 2997 $, $Date: 2008-10-24 20:54:20 +0100 (Fri, 24 Oct 2008) $
Author:
Josh Moore, josh.moore at gmx.de
See Also:
SessionFactory

Constructor Summary
ExtendedMetadata()
           
 
Method Summary
 Set<Class<ome.model.IAnnotated>> getAnnotationTypes()
          Returns all the classes which implement IAnnotated
 String getCountQuery(String field)
          Returns the query for obtaining the number of collection items to a particular instance.
 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 attached IObject instances which may need to be locked by the creation or updating of the argument.
 String[][] getLockChecks(Class<? extends ome.model.IObject> klass)
          returns all class/field name pairs which may possible link to an object of type klass.
 Class<ome.model.IObject> getTargetType(String field)
          Returns the IObject type which a given field points to.
 void onApplicationEvent(org.springframework.context.ApplicationEvent event)
          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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedMetadata

public ExtendedMetadata()
Method Detail

onApplicationEvent

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

Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener

setSessionFactory

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

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

getAnnotationTypes

public Set<Class<ome.model.IAnnotated>> getAnnotationTypes()
Returns all the classes which implement IAnnotated


getLockCandidates

public ome.model.IObject[] getLockCandidates(ome.model.IObject iObject)
walks the IObject argument non-recursively and gathers all attached IObject instances which may need to be locked by the creation or updating of the argument.

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 may need to be locked.
See Also:
Permissions.Flag#LOCKED

getLockChecks

public String[][] getLockChecks(Class<? extends ome.model.IObject> klass)
returns all class/field name pairs which may possible link to an object of type klass.

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

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: Beta-4.1.1-r5927-b91

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