P
- type of peerH
- public class HistoryFactory<P extends DataObject,H extends HistoryFactory.HistoryRecord<P>> extends DataObjectFactory<H> implements HistoryHandler<P>, TableStructureListener, TimePurgeFactory
Every entry in a History table contains some fields from the tracked object (any field without a corresponding field in the history table is not tracked. There is also a field giving the ID of the peer object. This defaults to PeerID but can be changed by overriding the getPeerName() method. There are also 2 time fields giving the period over which the data is valid. These can be either SQL time-type fields or numeric fields
Modifier and Type | Class and Description |
---|---|
class |
HistoryFactory.HistoryFilter
Filter for History objects selecting by peer object and date range
|
static class |
HistoryFactory.HistoryRecord<P extends DataObject>
Class Representing time history of and object.
|
class |
HistoryFactory.Mapper
Maps history objects to display classes for Timechart graphs.
|
class |
HistoryFactory.PeerIterator
Converts History objects into Peer object representation
|
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
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
END_TIME_FIELD |
protected static long |
ENDTIME |
static Feature |
HISTORY_CACHE_FEATURE |
static Feature |
HISTORY_STATUS_FEATURE |
static java.lang.String |
START_TIME_FIELD |
AUTO_CREATE_TABLES_FEATURE, COMPOSITES_SUFFIX, REJECT_MULTIPLE_RESULT_FEATURE, res
Modifier | Constructor and Description |
---|---|
|
HistoryFactory(AppContext c,
java.lang.String table)
Constructor for Stand alone history factories.
|
protected |
HistoryFactory(DataObjectFactory<P> fac)
Constructor to allow sub-classes to set factory before calling
DataObjectFactory.setContext(AppContext, String) |
|
HistoryFactory(DataObjectFactory<P> fac,
java.lang.String table)
Standard Constructor for HistoryFactory HistoryFactory contains a ref to
its peer factory.
|
Modifier and Type | Method and Description |
---|---|
SetPlot |
addChart(LabelledSetRangeMapper<H> gm,
java.util.Iterator<H> iter,
TimeChart tc,
float other_thresh) |
SetPlot |
addChart(LabelledSetRangeMapper<H> gm,
java.util.Iterator<H> iter,
TimeChart tc,
float other_thresh,
int max_plot) |
void |
closeGaps(P peer,
java.util.Date start,
java.util.Date end)
close gaps in history sequence over a time range.
|
protected java.util.Date |
expireTime(P peer,
java.util.Date start)
calculates the time the current data should expire.
|
H |
find(P peer,
java.util.Date time)
Find History by peer and date
|
protected H |
find(P peer,
java.util.Date time,
boolean want_tail) |
void |
fixSeries(P peer,
java.util.Date start,
java.util.Date end)
fix a corrupt history sequence, ensure there are no overlapping
records and fix and reversed timestamps and spurious splits.
|
protected void |
fixSeries(P peer,
java.util.Iterator<H> it)
fix a corrupt history sequence, ensure there are no overlapping
records and fix and reversed timestamps and spurious splits.
|
TableSpecification |
getDefaultTableSpecification(AppContext c,
java.lang.String homeTable)
Get the default table specification if the table is to be created.
|
java.util.Iterator<H> |
getIterator(java.util.Date start,
java.util.Date end) |
java.util.Iterator<H> |
getIterator(P peer,
java.util.Date start,
java.util.Date end) |
java.util.Iterator<H> |
getIterator(SQLFilter<P> peer,
java.util.Date start,
java.util.Date end) |
protected java.util.List<OrderClause> |
getOrder() |
DataObjectFactory<P> |
getPeerFactory() |
java.lang.String |
getPeerName()
Name of the field containing the peer id This must match the equivalent
methid in the History type.
|
IndexedProducer<P> |
getPeerProducer() |
protected IndexedTypeProducer |
getPeerReference() |
java.lang.Class<H> |
getTarget()
Get a bound on the type of object produced by this factory for run-time checking.
|
boolean |
isPeerType(DataObject peer)
is peer of right type
|
protected H |
makeBDO(Repository.Record res)
Construct a new Blank DataObject of the correct Class
This method takes a Record as an argument.
|
protected HistoryFactory.HistoryRecord<P> |
makeHistory(java.util.Date now,
P peer)
make History object from peer
|
protected void |
postCreateTableSetup(AppContext c,
java.lang.String table) |
void |
purge(P o)
Delete all history records corresponding to a specified peer object.
|
void |
purgeOldData(java.util.Date epoch) |
void |
resetStructure()
Table structure has changed
|
protected void |
setPeerFactory(DataObjectFactory<P> fac) |
boolean |
skipUpdate(P peer)
extension point to allow history to be skipped based on peer state
|
void |
terminate(P peer)
Terminates the history for a given peer object
updates the quota history to reflect the current status of the quota.
|
HistoryFactory.HistoryRecord<P> |
update(P peer)
Updates quota history.
|
int |
wipe(P peer,
java.util.Set<java.lang.String> fields)
wipe data from entire sequence of a record
|
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, getFormUpdate, getID, getIndex, getInput, getInput, getInput, getLogger, getMaxIdentifierLength, getNullable, getOptional, getProperty, getReferenced, getReferenceFieldType, getReferenceFieldType, getRemoteFilter, getRemoteSQLFilter, getResult, getResult, getSelectFilter, getSelector, getSelector, getSelectors, getSupress, getTableSpecification, getTableStructureContributers, getTag, getTranslations, getUniqueIdName, hasComposite, hashCode, isMine, isMine, isMyReference, isValid, makeBDO, makeObject, makeRecord, makeReference, makeReference, matches, narrowSelector, narrowSelector, observeComposite, OrderBy, postSetContext, release, restrictDefaultInput, setComposites, setContext, setContext, setContextWithMake, setProperty, toString, updateTable
public static final Feature HISTORY_CACHE_FEATURE
public static final Feature HISTORY_STATUS_FEATURE
protected static long ENDTIME
public static final java.lang.String START_TIME_FIELD
public static final java.lang.String END_TIME_FIELD
public HistoryFactory(DataObjectFactory<P> fac, java.lang.String table)
LinkManager
fac
- table
- table to store dataprotected HistoryFactory(DataObjectFactory<P> fac)
DataObjectFactory.setContext(AppContext, String)
fac
- public HistoryFactory(AppContext c, java.lang.String table)
c
- table
- protected IndexedTypeProducer getPeerReference()
public DataObjectFactory<P> getPeerFactory()
public IndexedProducer<P> getPeerProducer()
protected void setPeerFactory(DataObjectFactory<P> fac)
public TableSpecification getDefaultTableSpecification(AppContext c, java.lang.String homeTable)
DataObjectFactory
getDefaultTableSpecification
in class DataObjectFactory<H extends HistoryFactory.HistoryRecord<P>>
c
- AppContexthomeTable
- String table name.public SetPlot addChart(LabelledSetRangeMapper<H> gm, java.util.Iterator<H> iter, TimeChart tc, float other_thresh) throws java.lang.Exception
gm
- iter
- tc
- other_thresh
- java.lang.Exception
public SetPlot addChart(LabelledSetRangeMapper<H> gm, java.util.Iterator<H> iter, TimeChart tc, float other_thresh, int max_plot) throws java.lang.Exception
java.lang.Exception
protected java.util.Date expireTime(P peer, java.util.Date start)
peer
- start
- public final H find(P peer, java.util.Date time) throws DataException, java.lang.IllegalArgumentException
HistoryHandler
find
in interface HistoryHandler<P extends DataObject>
DataException
java.lang.IllegalArgumentException
protected final H find(P peer, java.util.Date time, boolean want_tail) throws DataException, java.lang.IllegalArgumentException
DataException
java.lang.IllegalArgumentException
public java.util.Iterator<H> getIterator(P peer, java.util.Date start, java.util.Date end) throws DataFault
getIterator
in interface HistoryHandler<P extends DataObject>
DataFault
public java.util.Iterator<H> getIterator(SQLFilter<P> peer, java.util.Date start, java.util.Date end) throws DataFault
getIterator
in interface HistoryHandler<P extends DataObject>
DataFault
public java.util.Iterator<H> getIterator(java.util.Date start, java.util.Date end) throws DataFault
getIterator
in interface HistoryHandler<P extends DataObject>
DataFault
public java.lang.String getPeerName()
getPeerName
in interface HistoryHandler<P extends DataObject>
public final boolean isPeerType(DataObject peer)
HistoryHandler
isPeerType
in interface HistoryHandler<P extends DataObject>
peer
- a DataObject to checkprotected H makeBDO(Repository.Record res) throws DataFault
DataObjectFactory
makeBDO
in class DataObjectFactory<H extends HistoryFactory.HistoryRecord<P>>
res
- Record to create object fromDataFault
public java.lang.Class<H> 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<H extends HistoryFactory.HistoryRecord<P>>
getTarget
in interface Targetted<H extends HistoryFactory.HistoryRecord<P>>
getTarget
in class DataObjectFactory<H extends HistoryFactory.HistoryRecord<P>>
protected final HistoryFactory.HistoryRecord<P> makeHistory(java.util.Date now, P peer) throws ConsistencyError, DataFault
peer
- DataObject to record.ConsistencyError
DataFault
protected java.util.List<OrderClause> getOrder()
getOrder
in class DataObjectFactory<H extends HistoryFactory.HistoryRecord<P>>
public void purge(P o) throws DataFault
HistoryHandler
purge
in interface HistoryHandler<P extends DataObject>
o
- DataObject peerDataFault
public final void terminate(P peer) throws java.lang.IllegalArgumentException, DataException
HistoryHandler
terminate
in interface HistoryHandler<P extends DataObject>
peer
- Peer object whose history will be terminatedjava.lang.IllegalArgumentException
DataException
public boolean skipUpdate(P peer)
peer
- public final HistoryFactory.HistoryRecord<P> update(P peer) throws java.lang.IllegalArgumentException, ConsistencyError, DataException
HistoryHandler
update
in interface HistoryHandler<P extends DataObject>
java.lang.IllegalArgumentException
ConsistencyError
DataException
public void fixSeries(P peer, java.util.Date start, java.util.Date end) throws DataException
peer
- start
- end
- DataException
protected void fixSeries(P peer, java.util.Iterator<H> it) throws DataFault, DataException
peer
- it
- DataFault
DataException
public void closeGaps(P peer, java.util.Date start, java.util.Date end) throws DataException
peer
- start
- end
- DataException
protected void postCreateTableSetup(AppContext c, java.lang.String table)
postCreateTableSetup
in class DataObjectFactory<H extends HistoryFactory.HistoryRecord<P>>
public void resetStructure()
TableStructureListener
resetStructure
in interface TableStructureListener
public void purgeOldData(java.util.Date epoch) throws java.lang.Exception
purgeOldData
in interface TimePurgeFactory
java.lang.Exception