public static class ExtendedMetadata.Impl extends OnContextRefreshedEventListener implements ExtendedMetadata
ExtendedMetadata
possible.ExtendedMetadata.Immutables, ExtendedMetadata.Impl, ExtendedMetadata.Locks, ExtendedMetadata.Relationship
Constructor and Description |
---|
ExtendedMetadata.Impl() |
Modifier and Type | Method and Description |
---|---|
Map<String,Long> |
countLocks(org.hibernate.Session session,
Long id,
String[][] checks,
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. |
Set<Class<IAnnotated>> |
getAnnotatableTypes()
Returns all the classes which implement
IAnnotated |
Set<Class<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<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 IObject> klass) |
String[][] |
getLockCandidateChecks(Class<? extends 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. |
IObject[] |
getLockCandidates(IObject iObject)
|
String[][] |
getLockChecks(Class<? extends IObject> klass)
returns all class/field name pairs which may possibly link to an object
of type
klass . |
Set<String> |
getMapProperties(String className)
Get the names of any String→RString map properties this class has, otherwise an empty set if none.
|
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 the
"to" argument. |
String |
getSQLJoin(String fromType,
String fromAlias,
String toType,
String toAlias)
Note: this implementation does not yet take into account the mapping
of joined subclasses like Job->UpdateJob.
|
Class<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) . |
boolean |
mayHaveMapProperties(Class<? extends 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, setApplicationContext
public 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 OnContextRefreshedEventListener
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- SessionFactory#getAllClassMetadata()
public Set<String> getClasses()
getClasses
in interface ExtendedMetadata
public Class<IObject> getHibernateClass(String table)
ExtendedMetadata
getHibernateClass
in interface ExtendedMetadata
public String getRelationship(String from, String to)
locksHolder
and the lockedByHolder
data
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.getRelationship
in interface ExtendedMetadata
public String getSQLJoin(String fromType, String fromAlias, String toType, String toAlias)
getSQLJoin
in interface ExtendedMetadata
public Set<Class<IAnnotated>> getAnnotatableTypes()
ExtendedMetadata
IAnnotated
getAnnotatableTypes
in interface ExtendedMetadata
public Set<Class<Annotation>> getAnnotationTypes()
ExtendedMetadata
Annotation
getAnnotationTypes
in interface ExtendedMetadata
public IObject[] getLockCandidates(IObject iObject)
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)getLockCandidates
in interface ExtendedMetadata
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.IObjects
which will be linked to.public String[][] getLockCandidateChecks(Class<? extends IObject> k, boolean onlyWithGroups)
ExtendedMetadata
IObject
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 ExtendedMetadata
k
- Not null.public String[][] getLockChecks(Class<? extends IObject> klass)
klass
.getLockChecks
in interface ExtendedMetadata
klass
- Non-null subclass
of IObject
String
queries which can be used to
determine if an IObject
instance can be unlocked.Permissions.Flag#LOCKED
public Map<String,Long> countLocks(org.hibernate.Session session, Long id, String[][] checks, String clause)
ExtendedMetadata
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.
countLocks
in interface ExtendedMetadata
public String getCountQuery(String field) throws ApiUsageException
getCountQuery
in interface ExtendedMetadata
field
- Field name as specified in the class.ApiUsageException
- if return value would be null.public Class<IObject> getTargetType(String field) throws ApiUsageException
IObject
type which a given field points to. E.g.
getTargetType(ImageAnnotation.IMAGE) returns Image.class.ApiUsageException
public boolean mayHaveMapProperties(Class<? extends IObject> iObjectClass)
ExtendedMetadata
mayHaveMapProperties
in interface ExtendedMetadata
iObjectClass
- a classpublic Set<String> getMapProperties(String className)
ExtendedMetadata
getMapProperties
in interface ExtendedMetadata
className
- the name of a class, as from Class.getName()
Version: 5.1.4-ice35-b55
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.