BDO
- type produced by factorypublic abstract class DataObjectFactory<BDO extends DataObject> extends java.lang.Object implements Tagged, ContextCached, Owner<BDO>, IndexedProducer<BDO>, DataObjectSelector<BDO>, FormCreatorProducer, FormUpdateProducer<BDO>, FilterMatcher<BDO>
The advantage of using a Factory class rather than static Factory methods is that we can inherit the methods in a equivalent Factory hierarchy rather than having to re-implement them in the static factory methods of each DataObject.
There is a single abstract methods that need to be implemented in the derived Factories:
makeBDO(Record)
Which constructs an object of the target type.
getTarget()
method should also be overridden to improve run-time type checking.
This is so simple that in principle we could have a
genericFactory class that implements them using reflection from a Class object
passed to the constructor but this is probably overkill for the moment. Note
that Factory is only concerned with retrieving records from the database. It
can therefore be used with read-only tables populated from elsewhere.
Before a DataObjectFactory can be used the AppContext and database table name needs to be
initialised using the setContext
method. To avoid the possibility of having invalid
instances non-abstract sub-classes should implement constructors that invoke setContext.
Normally each class has its own database table. It is possible to implement several tables mapped using the same class by specifying a table name to the Factory constructor. If a class is only to be used with a single hard-wired table the table name can be set to a constant within the constructor.
It is also be possible to implement a class hierarchy that shares a
single table with different classes identified by a table field. In this case
we use a single factory class that produces the base class of the
hierarchy. However the makeBDO(Record)
method will have to know about all of the
sub-classes so as to be able to call the correct constructor.
This works best with classes that are always created from the Factory (e.g. inner classes
of the Factory) as it is not possible to have similar behaviour when objects are created
directly from a constructor without passing the table name throughout the code.
DataObjectFactory
is generic, parameterised by the type of the DataObject
sub-class
it produces. This reduces the need to introduce casting when using inherited factory methods.
Casting may still be required if the Factory can produce multiple target types as the generic parameter will only specify the common
superclass.
If a sub-classes are going to be extended further they should also be generic:
public class ThingFactory<T extends Thing> extends DataObjectFactory<T>{
...
}
public class Thing extends DataObject{
...
}
In this case avoid making the DataObject a true inner class of the Factory. This would make the DataObject
generic parameterised by itself and can lead to subtle implementation issues.
Instead make is a pseudo-inner class where we add an explicit reference to the Factory (set via the constructor) and define
makeBDO(uk.ac.ed.epcc.webapp.model.data.Repository.Record)
to set this reference.
DataObjectFactories can be used to retrieve individual
DataObjects (using the various find
methods) but
are normally used to return sets of DataObjects.
These sets are normally specified using a filter (see the interfaces in
uk.ac.ed.epcc.webapp.jdbc.filter). These sets may be very large,
too large to all fit in memory at the same time.
The DataObjectFactory.FilterIterator
class (an inner class of DataObjectFactory)
is therefore used to iterate through the values.
The DataObjectFactory.FilterSet
class is a simple wrapper round a DataObjectFactory.FilterIterator
that implements Iterable
and is therefore more compatible
with the java-5 extended for-loop syntax. The getResult(BaseFilter)
method returns a
FilterSet
corresponding to a filter.
This class also implements Selector
which means that it can provide a default form Input
for the type of object it creates.
A DataObjectFactory
can provide a TableSpecification
that is used to create the database table if the table is missing when the factory is created.
This allows code to bootstrap into an empty database. This behaviour is controlled by the auto_create.tables feature.
In general DataObjectFactory
adapts to the existing structure of the database table. Missing fields will be ignored. Additional fields will be handled
using default behaviour. If the table editing transitions are enabled missing fields from the default table specification can be created via the forms.
The Composite
class is used to extend DataObjectFactory
s by composition rather than extension. Use this class where the sets of fields in the same table
implement unrelated functionality or when a required behaviour has multiple possible implementations.
All Composite
s take the factory as a constructor argument. This then calls a register method to register them with the factory.
A Composite
may be registered in one of two ways.
Composite
. As these are initialised before the AppContext
is set
the Composite
constructor is unable to use the AppContext
.Composite
names can be specified in the configuration parameter table-tab.composites.
These can be either classdef. or class. definitions. If a constructor with the signature
(factory, String) exists then the Composite
tag name will be passed to the constructor. In this case the AppContext
is available to
the constructor.Modifier and Type | Class and Description |
---|---|
class |
DataObjectFactory.AbstractDataObjectInput
A form Input used to select objects produced by the owning factory.
|
protected class |
DataObjectFactory.AbstractFinder<X> |
protected class |
DataObjectFactory.DataObjectAcceptFilter
abstract sub-class for implementing
AcceptFilter for this factory. |
class |
DataObjectFactory.DataObjectInput
A form Input used to select objects produced by the owning factory using the record id
|
class |
DataObjectFactory.DataObjectIntegerInput
A basic form Input for selecting objects using their ID value as text.
|
class |
DataObjectFactory.DestAcceptFilter<T extends DataObject>
An
AcceptFilter version of DestFilter |
class |
DataObjectFactory.FilterAdapter
A
ResultMapper for generating target DataObject s |
class |
DataObjectFactory.FilterCounter |
class |
DataObjectFactory.FilterExists |
class |
DataObjectFactory.FilterIterator
Iterate over BasicDataObjects generated by a filter.
|
class |
DataObjectFactory.FilterSelector |
protected class |
DataObjectFactory.FilterSet
Simple wrapper round a Filter that implements
Iterable
This makes it easy to re-create a DataObjectFactory.FilterIterator or to
use a Filter in a for-each loop. |
class |
DataObjectFactory.Finder |
class |
DataObjectFactory.MakeRemoteFilterVisitor<R extends DataObject>
A
FilterVisitor for making a local filter from a filter on a referenced table. |
protected class |
DataObjectFactory.MatchFilter
Filter to select Objects that match against a field of a peer object
|
class |
DataObjectFactory.ReferencedAdapter<I extends Indexed>
ResultMapper that generates the set of objects referenced from
the targets selected by the filter
|
class |
DataObjectFactory.ReferenceIterator<I extends Indexed>
Iterator that iterates over the set of objects referenced by the
targets selected by the filter.
|
class |
DataObjectFactory.SortingDataObjectInput |
static class |
DataObjectFactory.TimeAcceptFilter<T extends DataObject> |
protected class |
DataObjectFactory.TimeFilter |
Modifier and Type | Field and Description |
---|---|
static Feature |
AUTO_CREATE_TABLES_FEATURE |
static java.lang.String |
COMPOSITES_SUFFIX |
static Feature |
REJECT_MULTIPLE_RESULT_FEATURE |
protected Repository |
res |
Modifier | Constructor and Description |
---|---|
protected |
DataObjectFactory()
Construct an uninitialised DataObjectFactory
The object will not be usable until setContext is called.
|
Modifier and Type | Method and Description |
---|---|
FilterResult<BDO> |
all()
Get an Iterable over all contents of a table
|
protected boolean |
allowPreSelect()
return the default pre-select behaviour for inputs generated by this class.
|
boolean |
canCreate(SessionService c)
Can the producer provide a FormUpdate for the current user.
|
boolean |
canUpdate(SessionService c)
Can the producer provide a FormUpdate for the current user.
|
<X extends Composite> |
checkComposite(java.lang.Class<? super X> clazz) |
protected <T extends DataObject> |
convertToDestinationFilter(DataObjectFactory<T> remote_fac,
java.lang.String link_field,
BaseFilter<BDO> fil)
Convert a BDO
BaseFilter into a BaseFilter on a referenced factory. |
void |
customiseForm(Form f)
Extension hook to allow additional Form customisation generic to all
types of Form For example adding a FormValidator or adding min, max
values to NumberInputs.
|
boolean |
equals(java.lang.Object obj) |
boolean |
exists(BaseFilter<BDO> s) |
BDO |
find(BaseFilter<BDO> f)
find an object based on a filter
|
BDO |
find(BaseFilter<BDO> f,
boolean allow_null)
Find an object based on a Filter
|
BDO |
find(int id)
Get a single object via its unique id.
|
BDO |
find(java.lang.Integer id)
get a single Object via its unique id as a number.
|
BDO |
find(java.lang.Number id)
Find the required object.
|
CloseableIterator<BDO> |
getAllIterator()
get an Iterator over all contents of a table
|
<X extends Composite> |
getComposite(java.lang.Class<? super X> clazz)
get a specific
Composite based on its registration type. |
java.util.Collection<Composite<BDO,?>> |
getComposites()
get all
Composite s for this factory. |
<Y> java.util.Collection<Y> |
getComposites(java.lang.Class<Y> template)
Get all composites that are assignable to a particular type.
|
java.lang.String |
getConfigTag()
Return the tag used to qualify configuration parameters
|
AppContext |
getContext() |
long |
getCount(BaseFilter<BDO> s)
count the number of records selected by a Filter
|
SQLFilter<BDO> |
getDefaultRelationshipFilter()
Get a
SQLFilter to use as the default target for relationship filters. |
protected java.util.Map<java.lang.String,java.lang.Object> |
getDefaults()
Generate a set of default property values.
|
protected TableSpecification |
getDefaultTableSpecification(AppContext c,
java.lang.String table)
Get the default table specification if the table is to be created.
|
<T extends DataObject> |
getDestFilter(SQLFilter<BDO> fil,
java.lang.String join_field,
DataObjectFactory<T> join_fac)
Default filter for use when we want to select remote objects referenced from this table
with a select clause on this table.
|
SQLFilter<BDO> |
getExcludeFilter(BDO obj) |
protected java.util.Map<java.lang.String,FieldConstraint> |
getFieldConstraints()
get the
FieldConstraint s to apply in creation/update forms |
protected java.util.Map<java.lang.String,java.lang.String> |
getFieldHelp()
return a class-default set of help-text for form fields.
|
SQLFilter<BDO> |
getFilter(BDO target)
get a filter that selects a particular target object.
|
SQLFilter<BDO> |
getFilter(BDO target,
boolean exclude)
get a filter that selects/excludes a particular target object.
|
AcceptFilter<BDO> |
getFilter(java.util.function.Predicate<BDO> p)
convert a
Predicate into an AcceptFilter
In general SQLFilter s are preferable as they filter at the SQL level. |
BaseFilter<BDO> |
getFinalSelectFilter() |
TableSpecification |
getFinalTableSpecification(AppContext ctx,
java.lang.String homeTable) |
SQLFilter<BDO> |
getFindFilter(int id)
Make a filter from an integer reference
|
FormCreator |
getFormCreator(AppContext c)
Create a default FormCreator for the target object
The form may be customised according to the requesting AppUser
|
FormUpdate<BDO> |
getFormUpdate(AppContext c)
produce a FormUpdate for the target type appropriate for
the requesting user
|
java.lang.String |
getID(BDO obj)
Generate the default text identifier of the client object.
|
java.lang.Integer |
getIndex(BDO value)
Get the underlying data representation corresponding to the value
|
DataObjectItemInput<BDO> |
getInput()
get the default
Input for this Factory
Default behaviour is to use the getSelectFilter() method to generate a DataObjectFactory.DataObjectInput
but not to restrict the parse values (default value of restrictDefaultInput() so existing values that don't
match the select filter are still valid. |
DataObjectItemInput<BDO> |
getInput(BaseFilter<BDO> fil)
Create an
Input from a filter. |
DataObjectItemInput<BDO> |
getInput(BaseFilter<BDO> fil,
boolean restrict)
Generate the default input type.
|
protected Logger |
getLogger()
get the default
Logger |
protected int |
getMaxIdentifierLength() |
protected java.util.Set<java.lang.String> |
getNullable()
get the set of fields that can be null in the database.
|
protected java.util.Set<java.lang.String> |
getOptional()
generate the set of optional fields to be used to provide class specific defaults
in form creation/update.
|
protected java.util.List<OrderClause> |
getOrder() |
protected <F,D> F |
getProperty(BDO o,
TypeProducer<F,D> prod,
F def)
Allow factories to get properties via the TypeProducer
|
protected <I extends Indexed> |
getReferenced(IndexedTypeProducer<I,? extends IndexedProducer<I>> producer,
SQLFilter<BDO> fil) |
ReferenceFieldType |
getReferenceFieldType()
Get a
ReferenceFieldType for this factory. |
ReferenceFieldType |
getReferenceFieldType(boolean allow_null)
Get a
ReferenceFieldType for this factory. |
<R extends DataObject> |
getRemoteFilter(DataObjectFactory<R> remote_fac,
java.lang.String link_field,
BaseFilter<R> fil)
Create a BDO
BaseFilter from a BaseFilter on a referenced factory. |
<R extends DataObject> |
getRemoteSQLFilter(DataObjectFactory<R> remote_fac,
java.lang.String link_field,
SQLFilter<R> fil) |
FilterResult<BDO> |
getResult(BaseFilter<BDO> fil)
Create a
FilterResult from a filter |
FilterResult<BDO> |
getResult(SQLFilter<BDO> fil,
int start,
int max)
Create a
FilterResult from a filter |
BaseFilter<BDO> |
getSelectFilter()
Get a filter corresponding to the set of DataObjects that can be used in
the default Input for this class.
|
DataObjectSelector<BDO> |
getSelector(BaseFilter<BDO> fil)
create a
Selector from a filter. |
Selector<DataObjectItemInput<BDO>> |
getSelector(BaseFilter<BDO> fil,
boolean restrict)
create a
Selector from a filter. |
protected java.util.Map<java.lang.String,Selector> |
getSelectors()
Get a Map of selectors to use for forms of this type.
|
protected java.util.Set<java.lang.String> |
getSupress()
generate the class specific set of suppressed fields to be used in form creation/update
The individual forms can override these so you usually use this method to define fields that should
be suppressed in all forms.
|
TableSpecification |
getTableSpecification()
Get the default
TableSpecification from a fully constructed factory. |
java.util.Collection<TableStructureContributer<BDO>> |
getTableStructureContributers()
get all
TableStructureContributer s for this factory. |
java.lang.String |
getTag()
Return the identifying tag for this instance.
|
java.lang.Class<BDO> |
getTarget()
Get a bound on the type of object produced by this factory for run-time checking.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getTranslations()
return a default set of translation between field names and text labels.
|
protected java.lang.String |
getUniqueIdName()
Get the unique ID field name for the target object.
|
<X extends Composite> |
hasComposite(java.lang.Class<X> clazz) |
int |
hashCode() |
boolean |
isMine(DataObject o)
Check a Object to see if it is a DataObject from the same Repository as
used by this Factory.
|
boolean |
isMine(java.lang.Object ob)
Does the specified target belong to this factory.
|
boolean |
isMyReference(IndexedReference ref)
Test if an IndexedReference belongs to this producer.
|
boolean |
isValid()
Check that this is a valid DataObjectFactory connected to a valid database table
|
BDO |
makeBDO()
Create a new DataObject of the correct Class
|
protected abstract BDO |
makeBDO(Repository.Record res)
Construct a new Blank DataObject of the correct Class
This method takes a Record as an argument.
|
protected BDO |
makeObject(java.sql.ResultSet rs,
boolean qualify)
generate the DataObject from the ResultSet as part of a join
|
protected Repository.Record |
makeRecord()
Create an initial record for the embedded repository
|
IndexedReference<BDO> |
makeReference(BDO obj)
Make a IndexedReference from a target object
|
IndexedReference<BDO> |
makeReference(int id)
Make and IndexedReferencce from an integer id.
|
boolean |
matches(BaseFilter<? super BDO> fil,
BDO o) |
DataObjectSelector<BDO> |
narrowSelector(BaseFilter<BDO> fil)
Generate a new selector with the valid selection further restricted by an additional filter.
|
DataObjectSelector<BDO> |
narrowSelector(BaseFilter<BDO> fil,
boolean new_restrict)
Generate a new selector with the valid selection further restricted by an additional filter.
|
protected void |
observeComposite(Composite c)
Observer
Composite s as they are registered. |
protected java.lang.String |
OrderBy(boolean qualify)
method to return a default ORDER by clause used.
|
protected void |
postCreateTableSetup(AppContext c,
java.lang.String table) |
protected void |
postSetContext() |
void |
release()
use like a destructor.
|
protected boolean |
restrictDefaultInput()
Should the default input restrict parse values based on
getSelectFilter() . |
protected void |
setComposites(AppContext ctx,
java.lang.String homeTable)
Set
Composite s
This is called early in the construction process so should not assume fields are initialised
This method can be extended to initialise sub-class specific compositions. |
protected void |
setContext(AppContext ctx,
java.lang.String homeTable)
Initialise Repository
Call this from within a sub-class constructor.
|
protected boolean |
setContext(AppContext ctx,
java.lang.String homeTable,
boolean create) |
protected boolean |
setContextWithMake(AppContext ctx,
java.lang.String homeTable,
TableSpecification spec)
Initialise Repository with customised table creation.
|
protected <F,D> void |
setProperty(BDO o,
TypeProducer<F,D> prod,
F dat)
Allow factories to set properties via the TypeProducer
|
java.lang.String |
toString() |
void |
updateTable()
update table schema to add any missing fields from the table specification
|
public static final java.lang.String COMPOSITES_SUFFIX
public static final Feature AUTO_CREATE_TABLES_FEATURE
public static final Feature REJECT_MULTIPLE_RESULT_FEATURE
protected Repository res
protected DataObjectFactory()
protected void observeComposite(Composite c)
Composite
s as they are registered.
Note that as this can be called during factory construction no assumptions can be made about
factory attribute state. The Composite.preRegister()
method needs to be used to set attribute state that is going to be used by this method.c
- public java.util.Collection<TableStructureContributer<BDO>> getTableStructureContributers()
TableStructureContributer
s for this factory.
This includes the Composite
s by default but can be extended to add others.Collection
public java.util.Collection<Composite<BDO,?>> getComposites()
Composite
s for this factory.Collection
public <X extends Composite> X getComposite(java.lang.Class<? super X> clazz)
Composite
based on its registration type.public <X extends Composite> boolean checkComposite(java.lang.Class<? super X> clazz)
public <X extends Composite> boolean hasComposite(java.lang.Class<X> clazz)
public <Y> java.util.Collection<Y> getComposites(java.lang.Class<Y> template)
template
- public void release()
public FormCreator getFormCreator(AppContext c)
FormCreatorProducer
getFormCreator
in interface FormCreatorProducer
c
- AppContextpublic FormUpdate<BDO> getFormUpdate(AppContext c)
FormUpdateProducer
getFormUpdate
in interface FormUpdateProducer<BDO extends DataObject>
c
- AppContextpublic SQLFilter<BDO> getFindFilter(int id)
id
- SelfReferenceFilter
public boolean canUpdate(SessionService c)
FormUpdateProducer
FormPolicy
canUpdate
in interface FormUpdateProducer<BDO extends DataObject>
public boolean canCreate(SessionService c)
FormCreatorProducer
FormPolicy
canCreate
in interface FormCreatorProducer
public void customiseForm(Form f)
f
- Form to modifypublic BDO find(int id) throws DataException
find
in interface IndexedProducer<BDO extends DataObject>
id
- Id of the objectDataException
public java.lang.Class<BDO> getTarget()
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<BDO extends DataObject>
getTarget
in interface Targetted<BDO extends DataObject>
public final BDO find(java.lang.Integer id)
id
- Number identifying object or nullpublic final BDO find(java.lang.Number id)
TypeConverter
find
in interface TypeConverter<BDO extends DataObject,java.lang.Number>
id
- Value of the database fieldpublic java.lang.Integer getIndex(BDO value)
TypeConverter
getIndex
in interface TypeConverter<BDO extends DataObject,java.lang.Number>
public BDO find(BaseFilter<BDO> f) throws DataException
f
- DataException
public BDO find(BaseFilter<BDO> f, boolean allow_null) throws DataException
f
- BaseFilter
to select objectallow_null
- return null if not foundDataException
public final long getCount(BaseFilter<BDO> s) throws DataException
s
- filter to useDataException
public final boolean exists(BaseFilter<BDO> s) throws DataException
DataException
public final boolean matches(BaseFilter<? super BDO> fil, BDO o)
matches
in interface FilterMatcher<BDO extends DataObject>
protected <I extends Indexed> java.util.Set<I> getReferenced(IndexedTypeProducer<I,? extends IndexedProducer<I>> producer, SQLFilter<BDO> fil) throws DataFault
DataFault
public final CloseableIterator<BDO> getAllIterator() throws DataFault
DataFault
public final FilterResult<BDO> all() throws DataFault
DataFault
public final AppContext getContext()
getContext
in interface Contexed
protected java.util.Map<java.lang.String,java.lang.Object> getDefaults()
protected boolean restrictDefaultInput()
getSelectFilter()
. Normally the default input
is more relaxed and accepts other values because the default input is
usually only based on status not access control rules.public final BaseFilter<BDO> getFinalSelectFilter()
public DataObjectItemInput<BDO> getInput()
Input
for this Factory
Default behaviour is to use the getSelectFilter()
method to generate a DataObjectFactory.DataObjectInput
but not to restrict the parse values (default value of restrictDefaultInput()
so existing values that don't
match the select filter are still valid.getInput
in interface Selector<DataObjectItemInput<BDO extends DataObject>>
public final DataObjectItemInput<BDO> getInput(BaseFilter<BDO> fil)
Input
from a filter.
This will restrict valid results as well as offered choices.fil
- DataObjectItemInput
public DataObjectItemInput<BDO> getInput(BaseFilter<BDO> fil, boolean restrict)
ListInput
but can be overidden to return an auto-complete input.
Note that the error message when afil
- BaseFilter
for suggested valuesrestrict
- boolean should filter restrict resultspublic final DataObjectSelector<BDO> getSelector(BaseFilter<BDO> fil)
Selector
from a filter.
Input will be restricted to the filterfil
- BaseFilter
for selectionSelector
public final DataObjectSelector<BDO> narrowSelector(BaseFilter<BDO> fil)
DataObjectSelector
narrowSelector
in interface DataObjectSelector<BDO extends DataObject>
public final DataObjectSelector<BDO> narrowSelector(BaseFilter<BDO> fil, boolean new_restrict)
DataObjectSelector
narrowSelector
in interface DataObjectSelector<BDO extends DataObject>
public final Selector<DataObjectItemInput<BDO>> getSelector(BaseFilter<BDO> fil, boolean restrict)
Selector
from a filter.fil
- BaseFilter
for selectionrestrict
- should validation fail if filter does not matchSelector
public final FilterResult<BDO> getResult(BaseFilter<BDO> fil) throws DataFault
FilterResult
from a filterfil
- BaseFilter
to select object set.FilterResult
DataFault
public final FilterResult<BDO> getResult(SQLFilter<BDO> fil, int start, int max) throws DataFault
FilterResult
from a filterfil
- SQLFilter
to select object set.start
- max
- FilterResult
DataFault
protected boolean allowPreSelect()
public BaseFilter<BDO> getSelectFilter()
getInput()
only uses this to control the presented options not
which options are valid unless the value of restrictDefaultInput()
is also changed.public SQLFilter<BDO> getDefaultRelationshipFilter()
SQLFilter
to use as the default target for relationship filters.
This should exclude targets that should not be used as relationship targets such as retired objects.protected final java.util.Set<java.lang.String> getNullable()
protected java.util.Set<java.lang.String> getOptional()
getNullable()
and remove any fields that should be forced to be mandatory.
Alternatively you can start with an empty set (defaulting to all fields mandatory) and add exceptions
Note that for legacy reasons a non-nullable String field CAN be made optional (the Repository
will map null values to the empty string)getNullable()
public ReferenceFieldType getReferenceFieldType()
ReferenceFieldType
for this factory.public ReferenceFieldType getReferenceFieldType(boolean allow_null)
ReferenceFieldType
for this factory.allow_null
- protected java.util.Map<java.lang.String,Selector> getSelectors()
DataObjectFormFactory
protected java.util.Set<java.lang.String> getSupress()
DataObjectFormFactory
protected java.util.Map<java.lang.String,FieldConstraint> getFieldConstraints()
FieldConstraint
s to apply in creation/update formspublic java.lang.String getID(BDO obj)
ParseFactory
in a complementary way.getID
in interface IndexedProducer<BDO extends DataObject>
obj
- public final java.lang.String getTag()
public final java.lang.String getConfigTag()
protected java.util.Map<java.lang.String,java.lang.String> getTranslations()
DataObjectFormFactory
protected java.util.Map<java.lang.String,java.lang.String> getFieldHelp()
protected final java.lang.String getUniqueIdName()
public final boolean isMine(DataObject o)
o
- DataObject to checkpublic final boolean isMine(java.lang.Object ob)
Owner
isMine
in interface Owner<BDO extends DataObject>
public boolean isValid()
public final BDO makeBDO() throws DataFault
DataFault
protected final Repository.Record makeRecord()
protected abstract BDO makeBDO(Repository.Record res) throws DataFault
res
- Record to create object fromDataFault
protected BDO makeObject(java.sql.ResultSet rs, boolean qualify) throws DataException
rs
- DataException
public IndexedReference<BDO> makeReference(BDO obj)
IndexedProducer
makeReference
in interface IndexedProducer<BDO extends DataObject>
public IndexedReference<BDO> makeReference(int id)
IndexedProducer
makeReference
in interface IndexedProducer<BDO extends DataObject>
public boolean isMyReference(IndexedReference ref)
IndexedProducer
isMyReference
in interface IndexedProducer<BDO extends DataObject>
public void updateTable() throws DataFault
DataFault
protected final java.lang.String OrderBy(boolean qualify)
protected java.util.List<OrderClause> getOrder()
protected final void setContext(AppContext ctx, java.lang.String homeTable)
ctx
- homeTable
- protected void postSetContext()
protected final boolean setContext(AppContext ctx, java.lang.String homeTable, boolean create)
protected void setComposites(AppContext ctx, java.lang.String homeTable)
Composite
s
This is called early in the construction process so should not assume fields are initialised
This method can be extended to initialise sub-class specific compositions.ctx
- homeTable
- public final TableSpecification getFinalTableSpecification(AppContext ctx, java.lang.String homeTable)
ctx
- homeTable
- public TableSpecification getTableSpecification()
TableSpecification
from a fully constructed factory.
This can only be called after auto-table generation.protected TableSpecification getDefaultTableSpecification(AppContext c, java.lang.String table)
c
- AppContexttable
- String table name.protected final boolean setContextWithMake(AppContext ctx, java.lang.String homeTable, TableSpecification spec)
ctx
- homeTable
- spec
- protected void postCreateTableSetup(AppContext c, java.lang.String table)
protected <F,D> void setProperty(BDO o, TypeProducer<F,D> prod, F dat)
F
- type of dataD
- database typeo
- target objectprod
- TypeProducerdat
- valueprotected <F,D> F getProperty(BDO o, TypeProducer<F,D> prod, F def)
F
- type of dataD
- database typeo
- target objectprod
- TypeProducerdef
- default valuepublic SQLFilter<BDO> getFilter(BDO target)
target
- public SQLFilter<BDO> getFilter(BDO target, boolean exclude)
target
- public java.lang.String toString()
toString
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
protected int getMaxIdentifierLength()
protected <T extends DataObject> BaseFilter<T> convertToDestinationFilter(DataObjectFactory<T> remote_fac, java.lang.String link_field, BaseFilter<BDO> fil)
BaseFilter
into a BaseFilter
on a referenced factory.fil
- public <R extends DataObject> BaseFilter<BDO> getRemoteFilter(DataObjectFactory<R> remote_fac, java.lang.String link_field, BaseFilter<R> fil)
BaseFilter
from a BaseFilter
on a referenced factory.
If you have more than one field that references the same table and want to combine remote filters for them
register the remote factory under multiple tags (one per reference field) and set table_alias.tag properties
to specify aliases to use in the SQL.fil
- public <R extends DataObject> SQLFilter<BDO> getRemoteSQLFilter(DataObjectFactory<R> remote_fac, java.lang.String link_field, SQLFilter<R> fil)
public <T extends DataObject> SQLFilter<T> getDestFilter(SQLFilter<BDO> fil, java.lang.String join_field, DataObjectFactory<T> join_fac)
fil
- SQLFilter
on local objectjoin_field
- field pointing to remote objectjoin_fac
- DataObjectFactory
for remote object.public final AcceptFilter<BDO> getFilter(java.util.function.Predicate<BDO> p)
Predicate
into an AcceptFilter
In general SQLFilter
s are preferable as they filter at the SQL level.
However this gives an easy way of adding additional restrictions to a selection using lambdas.
These should really only be used as a final level of filtering as many of the query optimisations will be prevented by the presence
of an AcceptFilter
p
-