public class BaseGraphSpec extends Object implements GraphSpec, org.springframework.beans.factory.BeanNameAware
GraphSpec
which takes the id of some id as the root of action.IGraph
Modifier and Type | Class and Description |
---|---|
static class |
BaseGraphSpec.SubSpecIterator
|
Modifier and Type | Field and Description |
---|---|
protected List<GraphEntry> |
entries
The paths which make up this graph specification.
|
protected long |
id
The id of the root type which will be processed.
|
protected Map<String,String> |
options
Options passed to the
#initialize(long, Map) method, which may be
used during GraphState.execute(int) to alter behavior. |
protected String |
superspec
Path of the superspec.
|
Constructor and Description |
---|
BaseGraphSpec(List<String> entries) |
BaseGraphSpec(String name,
String... entries)
Simplified constructor, primarily used for testing.
|
Modifier and Type | Method and Description |
---|---|
QueryBuilder |
chgrpQuery(EventContext ec,
String table,
GraphOpts opts)
Return a
QueryBuilder which has been properly initialized to take the parameters "id"
and "grp" and then have QueryBuilder.query(Session) called. |
QueryBuilder |
chmodQuery(EventContext ec,
String table,
GraphOpts opts) |
QueryBuilder |
deleteQuery(EventContext ec,
String table,
GraphOpts opts) |
List<GraphEntry> |
entries()
Returns a copy of the list of
GraphEntry instances contained in
this GraphSpec |
Class<ome.model.IObject> |
getHibernateClass(String table)
Return the Hibernate type (ome.model.*) for the given table.
|
String |
getName()
The name of this specification.
|
String |
getSuperSpec()
Specification of where this
GraphSpec is attached under another
. |
ome.model.meta.ExperimenterGroup |
groupInfo(ome.util.SqlAction sql)
Like
GraphSpec.load(Session) uses the current table and id information
to look up information on the given target. |
int |
initialize(long id,
String superspec,
Map<String,String> options)
Called as each action is started.
|
protected void |
join(QueryBuilder qb,
String from,
String fromAlias,
String to,
String toAlias)
Used to generate a join statement on the
QueryBuilder making use
of {@link ExtendedMetadata#getRelationship(String, String). |
ome.model.IObject |
load(org.hibernate.Session session)
Loads the object that this spec points to.
|
boolean |
overrideKeep()
Always returns false.
|
void |
permissionsClause(EventContext ec,
QueryBuilder qb,
boolean sqlQuery)
Appends a clause to the
QueryBuilder based on the current user. |
void |
postProcess(org.springframework.beans.factory.ListableBeanFactory factory)
Gives all specs a chance to reference subspecs.
|
long[][] |
queryBackupIds(org.hibernate.Session session,
int step,
GraphEntry subpath,
QueryBuilder and)
If a given path is processed before its sub-path, this points to a
one-to-one relationship.
|
void |
setBeanName(String beanName)
Set the name of the bean in the bean factory that created this bean.
|
void |
setExtendedMetadata(ExtendedMetadata em) |
String |
toString() |
Iterator<GraphSpec> |
walk()
Returns an iterator over all subspecs and their subspecs, depth-first.
|
protected final List<GraphEntry> entries
GraphState.execute(int)
protected long id
protected String superspec
protected Map<String,String> options
#initialize(long, Map)
method, which may be
used during GraphState.execute(int)
to alter behavior.public BaseGraphSpec(String name, String... entries)
public void setBeanName(String beanName)
org.springframework.beans.factory.BeanNameAware
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
beanName
- the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String)
method to extract the original bean name (without suffix), if desired.public void setExtendedMetadata(ExtendedMetadata em)
public String getName()
GraphSpec
public String getSuperSpec()
GraphSpec
GraphSpec
is attached under another
. The reverse of
GraphEntry.getSubSpec()
.getSuperSpec
in interface GraphSpec
public Class<ome.model.IObject> getHibernateClass(String table)
GraphSpec
getHibernateClass
in interface GraphSpec
public void postProcess(org.springframework.beans.factory.ListableBeanFactory factory)
GraphSpec
postProcess
in interface GraphSpec
public int initialize(long id, String superspec, Map<String,String> options) throws GraphException
GraphSpec
GraphState.execute(int)
can take clean up actions.initialize
in interface GraphSpec
id
- identifier of the root object which defines the graph to be
processed.superspec
- points to the relationship between the root object and the
current graph. In many cases, this value will be null so that
the current object is taken to be the root, but if this is a
subspec, or a non-standard naming is being used, then the
supersec will be used.options
- possibly null or empty map of options which can override the
operations provided in the definition of the specification.
For example, if the spec "/Image" defines "/Image/Annotation"
as "HARD" (the default), then the options map could contain
{"/Image/Annotation":"ORPHAN"}to modify that setting.
GraphException
public Iterator<GraphSpec> walk()
GraphSpec
public List<GraphEntry> entries()
GraphSpec
GraphEntry
instances contained in
this GraphSpec
public boolean overrideKeep()
overrideKeep
in interface GraphSpec
public ome.model.IObject load(org.hibernate.Session session) throws GraphException
GraphSpec
GraphSpec.queryBackupIds(Session, int, GraphEntry, QueryBuilder)
but only returns the last element.load
in interface GraphSpec
GraphException
public ome.model.meta.ExperimenterGroup groupInfo(ome.util.SqlAction sql)
GraphSpec
GraphSpec.load(Session)
uses the current table and id information
to look up information on the given target.public long[][] queryBackupIds(org.hibernate.Session session, int step, GraphEntry subpath, QueryBuilder and) throws GraphException
GraphSpec
#initialize(long, Map)
so that foreign key
constraints which require a higher level object to be processed first, can
be processed.
For example,
/Channel /Channel/StatsInforequires the Channel to be processed first, but without the Channel, there's no way to detect which StatsInfo should be removed. Therefore,
#backupIds
in this case would contain:
[ null, # Nothing for Channel. [1,2,3], # The ids of all StatsInfo object which should be removed. ]
queryBackupIds
in interface GraphSpec
GraphException
public QueryBuilder chgrpQuery(EventContext ec, String table, GraphOpts opts)
GraphSpec
QueryBuilder
which has been properly initialized to take the parameters "id"
and "grp" and then have QueryBuilder.query(Session)
called.chgrpQuery
in interface GraphSpec
public QueryBuilder chmodQuery(EventContext ec, String table, GraphOpts opts)
chmodQuery
in interface GraphSpec
public QueryBuilder deleteQuery(EventContext ec, String table, GraphOpts opts)
deleteQuery
in interface GraphSpec
public void permissionsClause(EventContext ec, QueryBuilder qb, boolean sqlQuery)
QueryBuilder
based on the current user.
If the user is an admin like root, then nothing is appended, and any
action is permissible. If the user is a leader of the current group, then
the object must be in the current group. Otherwise, the object must
belong to the current user.protected void join(QueryBuilder qb, String from, String fromAlias, String to, String toAlias) throws GraphException
QueryBuilder
making use
of ExtendedMetadata#getRelationship(String, String). If the value
returned by that value is null, a {@link GraphException} will be thrown.
Otherwise something of the form:
join FROM.rel as TOwill be added to the {@link QueryBuilder}
GraphException
Version: 4.4.12-ice34-b116
Copyright © 2014 The University of Dundee & Open Microscopy Environment. All Rights Reserved.