public static class ExtendedMetadata.Impl extends OnContextRefreshedEventListener implements ExtendedMetadata
ExtendedMetadata possible.ExtendedMetadata.Immutables, ExtendedMetadata.Impl, ExtendedMetadata.Locks, ExtendedMetadata.Relationship| Constructor and Description |
|---|
Impl() |
| Modifier and Type | Method and Description |
|---|---|
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)
Takes the lock checks returned by
ExtendedMetadata.getLockChecks(Class) and
performs the actual check returning a map from class to total number
of locks. |
java.util.Set<java.lang.Class<ome.model.IAnnotated>> |
getAnnotatableTypes()
Returns all the classes which implement
IAnnotated |
java.util.Set<java.lang.Class<ome.model.annotations.Annotation>> |
getAnnotationTypes()
Returns all the classes which subclass
Annotation |
java.util.Set<java.lang.String> |
getClasses() |
java.lang.String |
getCountQuery(java.lang.String field)
Returns the query for obtaining the number of collection items to a
particular instance.
|
java.lang.Class<ome.model.IObject> |
getHibernateClass(java.lang.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.
|
java.lang.String[] |
getImmutableFields(java.lang.Class<? extends ome.model.IObject> klass) |
java.lang.String[][] |
getLockCandidateChecks(java.lang.Class<? extends ome.model.IObject> k,
boolean onlyWithGroups)
Rather than iterating over an
IObject like
ExtendedMetadata.getLockCandidates(IObject) this method returns type/field name
pairs (like ExtendedMetadata.getLockChecks(Class)) to allow performing the
queries manually. |
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. |
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. |
java.util.Set<java.lang.String> |
getMapProperties(java.lang.String className)
Get the names of any String→RString map properties this class has, otherwise an empty set if none.
|
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.
|
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.
|
java.lang.Class<ome.model.IObject> |
getTargetType(java.lang.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). |
boolean |
mayHaveMapProperties(java.lang.Class<? extends ome.model.IObject> iObjectClass)
Check if an object of this class may have map properties.
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Initializes the metadata needed by this instance.
|
onApplicationEvent, setApplicationContextpublic void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent cre)
ContextRefreshedEvent and then
extracts the SessionFactory from the ApplicationContext
and pases it to setSessionFactory(SessionFactory).handleContextRefreshedEvent in class OnContextRefreshedEventListenerpublic void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory - the Hibernate session factorySessionFactory.getAllClassMetadata()public java.util.Set<java.lang.String> getClasses()
getClasses in interface ExtendedMetadatapublic java.lang.Class<ome.model.IObject> getHibernateClass(java.lang.String table)
ExtendedMetadatagetHibernateClass in interface ExtendedMetadatatable - a database table name, or simple class name of a model objectpublic java.lang.String getRelationship(java.lang.String from,
java.lang.String to)
getRelationship in interface ExtendedMetadatapublic java.lang.String getSQLJoin(java.lang.String fromType,
java.lang.String fromAlias,
java.lang.String toType,
java.lang.String toAlias)
getSQLJoin in interface ExtendedMetadatapublic java.util.Set<java.lang.Class<ome.model.IAnnotated>> getAnnotatableTypes()
ExtendedMetadataIAnnotatedgetAnnotatableTypes in interface ExtendedMetadatapublic java.util.Set<java.lang.Class<ome.model.annotations.Annotation>> getAnnotationTypes()
ExtendedMetadataAnnotationgetAnnotationTypes in interface ExtendedMetadatapublic ome.model.IObject[] getLockCandidates(ome.model.IObject iObject)
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)getLockCandidates in interface ExtendedMetadataiObject - A newly created or updated IObject instance which
might possibly lock other IObjects. A null
argument will return an empty array to be checked.IObjects which will be linked to.public java.lang.String[][] getLockCandidateChecks(java.lang.Class<? extends ome.model.IObject> k,
boolean onlyWithGroups)
ExtendedMetadataIObject like
ExtendedMetadata.getLockCandidates(IObject) this method returns type/field name
pairs (like ExtendedMetadata.getLockChecks(Class)) to allow performing the
queries manually.
If onlyWithGroups is true, then only checks which point to non-IGlobal
objects will be returned.getLockCandidateChecks in interface ExtendedMetadatak - Not null.onlyWithGroups - if should omit checks that point to IGlobalspublic java.lang.String[][] getLockChecks(java.lang.Class<? extends ome.model.IObject> klass)
klass.getLockChecks in interface ExtendedMetadataklass - Non-null subclass of IObjectString queries which can be used to
determine if an IObject instance can be unlocked.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)
ExtendedMetadataExtendedMetadata.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.
countLocks in interface ExtendedMetadatapublic java.lang.String[] getImmutableFields(java.lang.Class<? extends ome.model.IObject> klass)
public java.lang.String getCountQuery(java.lang.String field)
throws ome.conditions.ApiUsageException
getCountQuery in interface ExtendedMetadatafield - Field name as specified in the class.ome.conditions.ApiUsageException - if return value would be null.public java.lang.Class<ome.model.IObject> getTargetType(java.lang.String field)
throws ome.conditions.ApiUsageException
IObject type which a given field points to. E.g.
getTargetType(ImageAnnotation.IMAGE) returns Image.class.ome.conditions.ApiUsageExceptionpublic boolean mayHaveMapProperties(java.lang.Class<? extends ome.model.IObject> iObjectClass)
ExtendedMetadatamayHaveMapProperties in interface ExtendedMetadataiObjectClass - a classpublic java.util.Set<java.lang.String> getMapProperties(java.lang.String className)
ExtendedMetadatagetMapProperties in interface ExtendedMetadataclassName - the name of a class, as from Class.getName()