X - type of DataObjectpublic class AccessorMap<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget> extends java.lang.Object implements uk.ac.ed.epcc.webapp.Contexed, ExpressionFilterTarget<X>, uk.ac.ed.epcc.webapp.Targetted<X>
PropExpression logic that can be incorporated (by composition) into factory classes for DataObjects that implement ExpressionTarget.
Contains maps from properties to the Accessor/SQLValue/SQLExpression needed to extract
data from the record/query.
Also contains a PropExpressionMap allowing properties to be defined in terms of PropExpressions.
Special extended PropExpressionVisitors are used when creating an SQLValue/SQLExpression or evaluating
an expression so these derived properties can be consulted when processing a PropertyTag.
While it is legal for two properties to map to the same accessor this means that the properties are aliases and
updating one will update the other. This can cause problems if a parser generates both properties so the default
logic that populates the AccessorMap from the Repository avoids this. Where parsing is not required a class can add duplicate mapping explicitly.
Composite Accessors are not created as evaluating the expression directly with a visitor takes the same amount of
recursive calls as a required by the Accessor.
SQLValue. This is true in the standard accouning classes
but it is possible to install a custom Accessor for a value that can only be evaluated in java.| Modifier and Type | Class and Description |
|---|---|
class |
AccessorMap.ExpressionTargetProxy
Class to evaluate a PropExpression on a record.
|
class |
AccessorMap.ImplementationVisitor |
class |
AccessorMap.ResolveChecker |
class |
AccessorMap.SQLExpressionVisitor |
class |
AccessorMap.SQLValueVisitor |
| Modifier and Type | Field and Description |
|---|---|
static uk.ac.ed.epcc.webapp.Feature |
EVALUATE_CACHE_FEATURE |
static TagFilter |
NumberFilter
Encodes the rules for which kind of fields can
be implemented as a numberif database field.
|
| Constructor and Description |
|---|
AccessorMap(java.lang.Class<? super X> target,
uk.ac.ed.epcc.webapp.model.data.Repository res,
java.lang.String config_tag)
create an empty AccessorMap
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDerived(uk.ac.ed.epcc.webapp.AppContext conn,
PropExpressionMap input)
Add definitions from a PropExpressionMap
This will not override explicit accessors
|
PropertyContainer |
addFormContents(PropertyContainer map,
uk.ac.ed.epcc.webapp.forms.Form f)
Try to read an update
Form (keyed by field names)
into a property container. |
protected void |
addSource(java.lang.StringBuilder sb) |
void |
clearUnresolvableDefinitions()
clear any PropExpression definitions that cannot be resolved
|
protected <T> uk.ac.ed.epcc.webapp.jdbc.expr.CaseExpression<X,T> |
getCaseExpression(CasePropExpression<T> expr) |
uk.ac.ed.epcc.webapp.AppContext |
getContext() |
protected java.lang.String |
getDBTag() |
PropExpressionMap |
getDerivedProperties() |
java.lang.String |
getField(PropertyTag t)
Return the field name a PropertyTag maps to.
|
<R> java.util.Map<java.lang.String,R> |
getFieldMap(java.util.Map<PropertyTag,R> input)
Extract the entries from a map that are keyed by PropertyTags corresponding
to database fields and return a new map re-keyed by the field names.
|
java.util.Set<java.lang.String> |
getFieldSet(java.util.Set<PropertyTag> input)
Map a set of PropertyTags to their corresponding database fields.
|
<I> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> |
getFilter(PropExpression<I> expr,
uk.ac.ed.epcc.webapp.jdbc.filter.MatchCondition match,
I data)
get a filter based on comparing a PropExpression to a value.
|
java.lang.String |
getImplemenationInfo(PropertyTag<?> tag) |
<I> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> |
getNullFilter(PropExpression<I> expr,
boolean is_null)
get a filter that checks null status of an expression.
|
<I> uk.ac.ed.epcc.webapp.jdbc.filter.OrderFilter<X> |
getOrderFilter(boolean descending,
PropExpression<I> expr) |
uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> |
getPeriodFilter(uk.ac.ed.epcc.webapp.time.Period period,
PropExpression<java.util.Date> start_prop,
PropExpression<java.util.Date> end_prop,
OverlapType type,
long cutoff)
Generate an overlap filter
|
java.util.Set<PropertyTag> |
getProperties()
Get the set of Defined properties.
|
java.util.Set<PropertyTag> |
getProperties(java.lang.Class<?> c)
Get the set of defines properties whose resutls may be assigned to the
specified target type
|
ExpressionTargetContainer |
getProxy(X record) |
<R> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> |
getRelationFilter(PropExpression<R> left,
uk.ac.ed.epcc.webapp.jdbc.filter.MatchCondition match,
PropExpression<R> right)
get a filter that compares two expressions.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSelectors()
Generate default set of form selectors
|
<T> uk.ac.ed.epcc.webapp.jdbc.expr.SQLExpression<T> |
getSQLExpression(PropExpression<T> expr) |
<T> uk.ac.ed.epcc.webapp.jdbc.expr.SQLValue<T> |
getSQLValue(PropExpression<T> expr)
Get a SQLValue corresponding to the expression.
|
java.lang.Class<? super X> |
getTarget() |
<P> boolean |
hasProperty(PropertyTag<P> tag)
Is this a defined property
|
void |
makeReferences(ReferencePropertyRegistry reference_registry)
Register references from the
ReferencePropertyRegistry
This generates properties named after the target table. |
void |
populate(PropertyFinder finder,
PropertyRegistry orphan_registy,
boolean warn_orphan)
Populate this AccessorMap for the specified repository using the best
match to the field name from the PropertyFinder.
|
boolean |
possibleCompatible(java.lang.Class a,
java.lang.Class b)
Test to see if it is possible to have an object that can be assigned to
both of two specified types.
|
<T> void |
put(PropertyTag<? extends T> tag,
uk.ac.ed.epcc.webapp.Targetted<T> obj) |
void |
release() |
<T> java.lang.Boolean |
resolves(PropExpression<T> e,
boolean require_sql)
Does this property Expression resolve
|
PropertyFinder |
setRelationshipProperties(java.lang.String tag)
Add properties defined as a
Relationship between the object and the
current user. |
boolean |
writable(PropertyTag t) |
public static final uk.ac.ed.epcc.webapp.Feature EVALUATE_CACHE_FEATURE
public static final TagFilter NumberFilter
public AccessorMap(java.lang.Class<? super X> target, uk.ac.ed.epcc.webapp.model.data.Repository res, java.lang.String config_tag)
target - type of enclosing factoryres - config_tag - public <T> void put(PropertyTag<? extends T> tag, uk.ac.ed.epcc.webapp.Targetted<T> obj)
public boolean possibleCompatible(java.lang.Class a,
java.lang.Class b)
a - b - public <T> uk.ac.ed.epcc.webapp.jdbc.expr.SQLExpression<T> getSQLExpression(PropExpression<T> expr) throws InvalidSQLPropertyException
InvalidSQLPropertyExceptionpublic <T> uk.ac.ed.epcc.webapp.jdbc.expr.SQLValue<T> getSQLValue(PropExpression<T> expr) throws InvalidSQLPropertyException
InvalidSQLPropertyExceptionT - expr - public boolean writable(PropertyTag t)
public java.util.Set<PropertyTag> getProperties()
public ExpressionTargetContainer getProxy(X record)
public java.util.Set<PropertyTag> getProperties(java.lang.Class<?> c)
c - Class of target typepublic <P> boolean hasProperty(PropertyTag<P> tag)
tag - public <T> java.lang.Boolean resolves(PropExpression<T> e, boolean require_sql)
T - e - require_sql - public void populate(PropertyFinder finder, PropertyRegistry orphan_registy, boolean warn_orphan)
makeReferences(uk.ac.ed.epcc.safe.accounting.reference.ReferencePropertyRegistry) so these can be safely ignored. However if there
is a matching reference property then this is processed in case it is a static Property from
a policy.finder - PropertyFinderorphan_registy - Optional registry to create tags without bindingwarn_orphan - boolean set to true to make unmatched fields an error.public PropertyFinder setRelationshipProperties(java.lang.String tag)
Relationship between the object and the
current user.tag - public void makeReferences(ReferencePropertyRegistry reference_registry)
ReferencePropertyRegistry
This generates properties named after the target table.reference_registry - public java.lang.String getImplemenationInfo(PropertyTag<?> tag)
public void addDerived(uk.ac.ed.epcc.webapp.AppContext conn,
PropExpressionMap input)
conn - input - public PropExpressionMap getDerivedProperties()
public void clearUnresolvableDefinitions()
public java.lang.String getField(PropertyTag t)
t - PropertyTagpublic java.util.Set<java.lang.String> getFieldSet(java.util.Set<PropertyTag> input)
input - public <R> java.util.Map<java.lang.String,R> getFieldMap(java.util.Map<PropertyTag,R> input)
R - input - Mappublic PropertyContainer addFormContents(PropertyContainer map, uk.ac.ed.epcc.webapp.forms.Form f) throws InvalidPropertyException
Form (keyed by field names)
into a property container.InvalidPropertyExceptionmap - PropertyContainer to modifyf - Form to readPropertyContainerpublic final <I> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> getFilter(PropExpression<I> expr, uk.ac.ed.epcc.webapp.jdbc.filter.MatchCondition match, I data) throws uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterException
ExpressionFilterTargetgetFilter in interface ExpressionFilterTarget<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterExceptionI - type of prop-expressionexpr - expression to matchmatch - kind of matchdata - to math againstpublic <R> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> getRelationFilter(PropExpression<R> left, uk.ac.ed.epcc.webapp.jdbc.filter.MatchCondition match, PropExpression<R> right) throws uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterException
ExpressionFilterTargetgetRelationFilter in interface ExpressionFilterTarget<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterExceptionpublic final <I> uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> getNullFilter(PropExpression<I> expr, boolean is_null) throws uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterException
ExpressionFilterTargetgetNullFilter in interface ExpressionFilterTarget<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterExceptionI - type of prop-expressionexpr - expression to matchis_null - match if null when truepublic java.util.Map<java.lang.String,java.lang.Object> getSelectors()
public uk.ac.ed.epcc.webapp.AppContext getContext()
getContext in interface uk.ac.ed.epcc.webapp.Contexedpublic uk.ac.ed.epcc.webapp.jdbc.filter.BaseFilter<X> getPeriodFilter(uk.ac.ed.epcc.webapp.time.Period period, PropExpression<java.util.Date> start_prop, PropExpression<java.util.Date> end_prop, OverlapType type, long cutoff) throws uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterException
getPeriodFilter in interface ExpressionFilterTarget<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterExceptionperiod - Period to overlapstart_prop - start property may be nullend_prop - end propertytype - OverlapTypecutoff - maximum record length for cutoff calculation, zero for unknownpublic <I> uk.ac.ed.epcc.webapp.jdbc.filter.OrderFilter<X> getOrderFilter(boolean descending, PropExpression<I> expr) throws uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterException
getOrderFilter in interface ExpressionFilterTarget<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>uk.ac.ed.epcc.webapp.jdbc.expr.CannotFilterExceptionprotected void addSource(java.lang.StringBuilder sb)
protected java.lang.String getDBTag()
protected <T> uk.ac.ed.epcc.webapp.jdbc.expr.CaseExpression<X,T> getCaseExpression(CasePropExpression<T> expr) throws uk.ac.ed.epcc.webapp.jdbc.filter.NoSQLFilterException, InvalidSQLPropertyException, java.lang.Exception
uk.ac.ed.epcc.webapp.jdbc.filter.NoSQLFilterExceptionInvalidSQLPropertyExceptionjava.lang.Exceptionpublic java.lang.Class<? super X> getTarget()
getTarget in interface uk.ac.ed.epcc.webapp.Targetted<X extends uk.ac.ed.epcc.webapp.model.data.DataObject & ExpressionTarget>public void release()