T
- Type of link objectL
- type of left endR
- type of right endpublic abstract class IndexedLinkManager<T extends IndexedLinkManager.Link<L,R>,L extends Indexed,R extends Indexed> extends DataObjectFactory<T>
IndexedLinkManager
class calls these the Indexed
. If both ends of the
link are DataObject
classes then the LinkManager
sub-class should be used as this
provides additional features.
The actual Link
DataObjects are pseudo inner classes of the IndexedLinkManager
Often the Link objects will remain hidden inside the IndexedLinkManager
sub-class and only be
manipulated via an external interface. If we want to track the history of a Link object needs a status
field that marks if the link is valid. This way the same object is used to record the link between two peer objects
even if the link is broken and remade several times. Link
can be selected based on the objects at the
end on the link. e.g.
// get a link
Link l = manager.getLink(left_peer,right_peer); // null if link does not exist
// or
Link l2 = manager.makeLink(left_peer,right_peer); // make link if it does not already exist
IndexedLinkManager can navigate the links in either direction the subclass may
choose only to expose one direction of navigation. Internally this is implemented using the
LinkFilter
and LinkFilterIterator
classes which select a set a Link
objects
based on the value of one or other end.
// links joining left_peer to something
Iterator<Link> it = manager.getLinkIterator(left_peer,null,filter);
// or go straight to the referenced object
Iterator<Right> right_it = manager.getRightIterator(left_peer,null,filter);
The Link class can cache references to the objects it points to, these cached values are retrieved using
the getLeft()
and getRight()
methods.
Modifier and Type | Class and Description |
---|---|
static class |
IndexedLinkManager.Link<L extends Indexed,R extends Indexed>
Link is an object representing an entry in a linkage table.
|
protected class |
IndexedLinkManager.LinkFilter
Filter for link objects This class handles filtering by the end points
and can be extended by composition for example to select objects with a
particular status.
|
protected static interface |
IndexedLinkManager.LinkProvider<T extends IndexedLinkManager.Link<L,R>,L extends Indexed,R extends Indexed> |
class |
IndexedLinkManager.LinkUpdater |
protected class |
IndexedLinkManager.SQLLinkFilter
Filter for link objects This class handles filtering by the end points
and can be extended by composition for example to select objects with a
particular status.
|
DataObjectFactory.AbstractDataObjectInput, DataObjectFactory.AbstractFinder<X>, DataObjectFactory.DataObjectAcceptFilter, DataObjectFactory.DataObjectInput, DataObjectFactory.DataObjectIntegerInput, DataObjectFactory.DestAcceptFilter<T extends DataObject>, DataObjectFactory.FilterAdapter, DataObjectFactory.FilterCounter, DataObjectFactory.FilterExists, DataObjectFactory.FilterIterator, DataObjectFactory.FilterSelector, DataObjectFactory.FilterSet, DataObjectFactory.Finder, DataObjectFactory.MakeRemoteFilterVisitor<R extends DataObject>, DataObjectFactory.MatchFilter, DataObjectFactory.ReferencedAdapter<I extends Indexed>, DataObjectFactory.ReferenceIterator<I extends Indexed>, DataObjectFactory.SortingDataObjectInput, DataObjectFactory.TimeAcceptFilter<T extends DataObject>, DataObjectFactory.TimeFilter
AUTO_CREATE_TABLES_FEATURE, COMPOSITES_SUFFIX, REJECT_MULTIPLE_RESULT_FEATURE, res
Modifier | Constructor and Description |
---|---|
protected |
IndexedLinkManager() |
protected |
IndexedLinkManager(AppContext c,
java.lang.String table,
IndexedProducer<L> left_fac,
java.lang.String left_field,
IndexedProducer<R> right_fac,
java.lang.String right_field) |
Modifier and Type | Method and Description |
---|---|
java.util.Set<L> |
addLeftSet(java.util.Set<L> res,
R r,
BaseFilter<T> f)
Add to a set of Left Objects
|
java.util.Set<R> |
addRightSet(java.util.Set<R> res,
L l,
BaseFilter<T> f)
Add to a set of Right objects
|
TableSpecification |
getDefaultTableSpecification(AppContext c,
java.lang.String table)
Get the default table specification if the table is to be created.
|
protected TableSpecification |
getDefaultTableSpecification(AppContext c,
java.lang.String table,
IndexedProducer<L> leftFac,
java.lang.String leftField,
IndexedProducer<R> rightFac,
java.lang.String rightField) |
FilterResult<T> |
getFilterResult(L l,
R r,
BaseFilter<T> fil)
create a
FilterResult of Link objects |
TableSpecification |
getFinalTableSpecification(AppContext c,
java.lang.String table,
IndexedProducer<L> leftFac,
java.lang.String leftField,
IndexedProducer<R> rightFac,
java.lang.String rightField) |
FormUpdate<T> |
getFormUpdate(AppContext c)
produce a FormUpdate for the target type appropriate for
the requesting user
|
HistoryHandler<T> |
getHistoryHandler() |
java.lang.String |
getLeftField() |
SQLFilter<T> |
getLeftFilter(L l) |
IndexedProducer<L> |
getLeftProducer() |
java.util.Set<L> |
getLeftSet(R r,
BaseFilter<T> f)
Get a Set of Left objects
|
T |
getLink(L left_end,
R right_end)
get the Link object connecting the specified end objects
|
java.lang.String |
getRightField() |
SQLFilter<T> |
getRightFilter(R r) |
IndexedProducer<R> |
getRightProducer() |
java.util.Set<R> |
getRightSet(L l,
BaseFilter<T> f)
Get a Set of Right objects
|
TableSpecification |
getTableSpecification()
Get the default
TableSpecification from a fully constructed factory. |
java.lang.Class<T> |
getTarget()
Get a bound on the type of object produced by this factory for run-time checking.
|
protected boolean |
isLeft(java.lang.Object o) |
protected boolean |
isRight(java.lang.Object o) |
protected HistoryHandler<T> |
makeHistoryHandler()
create a new HistoryFactory suitable for the Link objects produced by
this class.
|
protected T |
makeLink(L left_end,
R right_end)
Return a link creating one and calling setup if it does not exist.
|
void |
modifyHistoryTable(TableSpecification spec)
Add Tracking fields to the history table default specification
|
protected T |
selectLink(L left_end,
R right_end)
method to call when from selector code normally the same as getLink but
may need to be overridden to automatically create objects (beware of
unwanted side effects in this case).
|
protected void |
setContext(AppContext c,
java.lang.String table,
IndexedProducer<L> left_fac,
java.lang.String left_field,
IndexedProducer<R> right_fac,
java.lang.String right_field) |
void |
setHistoryHandler(HistoryHandler<T> handler)
Set the
HistoryHandler explicitly. |
protected void |
updateHistory(T val) |
protected boolean |
useAutoHistory()
Do we automatically update the history as part of commit.
|
all, allowPreSelect, canCreate, canUpdate, checkComposite, convertToDestinationFilter, customiseForm, equals, exists, find, find, find, find, find, getAllIterator, getComposite, getComposites, getComposites, getConfigTag, getContext, getCount, getDefaultRelationshipFilter, getDefaults, getDestFilter, getExcludeFilter, getFieldConstraints, getFieldHelp, getFilter, getFilter, getFilter, getFinalSelectFilter, getFinalTableSpecification, getFindFilter, getFormCreator, getID, getIndex, getInput, getInput, getInput, getLogger, getMaxIdentifierLength, getNullable, getOptional, getOrder, getProperty, getReferenced, getReferenceFieldType, getReferenceFieldType, getRemoteFilter, getRemoteSQLFilter, getResult, getResult, getSelectFilter, getSelector, getSelector, getSelectors, getSupress, getTableStructureContributers, getTag, getTranslations, getUniqueIdName, hasComposite, hashCode, isMine, isMine, isMyReference, isValid, makeBDO, makeBDO, makeObject, makeRecord, makeReference, makeReference, matches, narrowSelector, narrowSelector, observeComposite, OrderBy, postCreateTableSetup, postSetContext, release, restrictDefaultInput, setComposites, setContext, setContext, setContextWithMake, setProperty, toString, updateTable
protected IndexedLinkManager(AppContext c, java.lang.String table, IndexedProducer<L> left_fac, java.lang.String left_field, IndexedProducer<R> right_fac, java.lang.String right_field)
protected IndexedLinkManager()
protected void setContext(AppContext c, java.lang.String table, IndexedProducer<L> left_fac, java.lang.String left_field, IndexedProducer<R> right_fac, java.lang.String right_field)
public final TableSpecification getDefaultTableSpecification(AppContext c, java.lang.String table)
DataObjectFactory
getDefaultTableSpecification
in class DataObjectFactory<T extends IndexedLinkManager.Link<L,R>>
c
- AppContexttable
- String table name.protected TableSpecification getDefaultTableSpecification(AppContext c, java.lang.String table, IndexedProducer<L> leftFac, java.lang.String leftField, IndexedProducer<R> rightFac, java.lang.String rightField)
public final TableSpecification getFinalTableSpecification(AppContext c, java.lang.String table, IndexedProducer<L> leftFac, java.lang.String leftField, IndexedProducer<R> rightFac, java.lang.String rightField)
public final TableSpecification getTableSpecification()
DataObjectFactory
TableSpecification
from a fully constructed factory.
This can only be called after auto-table generation.getTableSpecification
in class DataObjectFactory<T extends IndexedLinkManager.Link<L,R>>
public final HistoryHandler<T> getHistoryHandler()
public final void setHistoryHandler(HistoryHandler<T> handler)
HistoryHandler
explicitly.
Normally this is created using makeHistoryHandler()
but this allows us to set the reference when a handler is created
directly.handler
- public IndexedProducer<L> getLeftProducer()
public java.lang.String getLeftField()
public java.util.Set<L> getLeftSet(R r, BaseFilter<T> f) throws DataException
r
- Right Indexed
required null for anyf
- extension FilterDataException
public java.util.Set<L> addLeftSet(java.util.Set<L> res, R r, BaseFilter<T> f) throws DataException
res
- Set
to add toor
- Right Indexed
required null for anyf
- extension FilterDataException
public final T getLink(L left_end, R right_end) throws DataException
left_end
- Left Indexed
right_end
- Right Indexed
DataException
public FilterResult<T> getFilterResult(L l, R r, BaseFilter<T> fil) throws DataFault
FilterResult
of Link objectspublic IndexedProducer<R> getRightProducer()
public java.lang.String getRightField()
public java.util.Set<R> getRightSet(L l, BaseFilter<T> f) throws DataException
l
- Left DataObject required null for anyf
- extension FilterDataException
public java.util.Set<R> addRightSet(java.util.Set<R> res, L l, BaseFilter<T> f) throws DataException
res
- Set
to add tool
- Left DataObject required null for anyf
- extension FilterDataException
protected boolean isLeft(java.lang.Object o)
protected boolean isRight(java.lang.Object o)
protected HistoryHandler<T> makeHistoryHandler()
public void modifyHistoryTable(TableSpecification spec)
spec
- protected final T makeLink(L left_end, R right_end) throws java.lang.Exception
left_end
- Left Indexed
right_end
- Right Indexed
DataException
java.lang.Exception
protected T selectLink(L left_end, R right_end) throws java.lang.Exception
#canCreate(uk.ac.ed.epcc.webapp.SessionService)
in that case.left_end
- right_end
- DataException
java.lang.Exception
public FormUpdate<T> getFormUpdate(AppContext c)
FormUpdateProducer
getFormUpdate
in interface FormUpdateProducer<T extends IndexedLinkManager.Link<L,R>>
getFormUpdate
in class DataObjectFactory<T extends IndexedLinkManager.Link<L,R>>
c
- AppContextprotected boolean useAutoHistory()
protected void updateHistory(T val)
public java.lang.Class<T> getTarget()
DataObjectFactory
IndexedProducer.getTarget()
. Normally this method should be overridden
each time we make a sub-class that narrows the produced type. However
checks should still pass if the super-type method is retained.getTarget
in interface IndexedProducer<T extends IndexedLinkManager.Link<L,R>>
getTarget
in interface Targetted<T extends IndexedLinkManager.Link<L,R>>
getTarget
in class DataObjectFactory<T extends IndexedLinkManager.Link<L,R>>