T - type of usage recordpublic class UsageRecordParseTargetPlugIn<T extends UsageRecordFactory.Use> extends java.lang.Object implements UsageRecordParseTarget<T>, uk.ac.ed.epcc.webapp.Contexed
UsageRecordParseTarget using a PlugInOwner and
a UsageRecordFactory. This is usually used in composition so that the UsageRecordFactory
can implement the interface directly.
Note that the default implementation of findDuplicate(uk.ac.ed.epcc.safe.accounting.db.UsageRecordFactory.Use) method
provided in this class is independent of the other methods in UsageParseTarget so sub-classes can overrride and
Factories using this class in composition can re-implement this method.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
UNIQUE_PROPERTIES_PREFIX |
| Constructor and Description |
|---|
UsageRecordParseTargetPlugIn(uk.ac.ed.epcc.webapp.AppContext conn,
PlugInOwner owner,
UsageRecordFactory<T> fac) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowReplace(DerivedPropertyMap map,
T record)
Should replacement of the existing record with new values be allowed.
|
boolean |
commitRecord(PropertyContainer map,
T record)
Commit a new record also apply any required side-effects
As the record may only contain a sub-set of the known properties
the full PropertyContainer is passed separately
|
void |
deleteRecord(T old_record)
Delete an existing Record including any required side-effects
|
java.lang.StringBuilder |
endParse()
Complete a batch parse.
|
T |
findDuplicate(T r)
find a record in the database that is a previous version of the current line.
|
uk.ac.ed.epcc.webapp.AppContext |
getContext() |
PropertyFinder |
getFinder()
Get the PropertyFinder corresponding to this parse
|
java.lang.String |
getUniqueID(T r) |
protected java.util.Set<PropertyTag> |
getUniqueProperties()
Get the set of unique properties to use for detecting re-inserts.
|
boolean |
isComplete(T r)
Is this a complete or partial record.
|
boolean |
parse(DerivedPropertyMap map,
java.lang.String current_line)
Parse a text line into a DerivedPropertyMap.
|
protected java.util.Set<PropertyTag> |
parsePropertyList(java.lang.String list) |
T |
prepareRecord(DerivedPropertyMap map)
Create an uncommitted DB record from the property map.
|
java.util.Iterator<java.lang.String> |
splitRecords(java.lang.String update)
split update text into a series of lines.
|
void |
startParse(PropertyMap defaults)
Start a batch parse.
|
void |
updateRecord(DerivedPropertyMap map,
T record)
Perform a full update of an existing record.
|
public static final java.lang.String UNIQUE_PROPERTIES_PREFIX
public UsageRecordParseTargetPlugIn(uk.ac.ed.epcc.webapp.AppContext conn,
PlugInOwner owner,
UsageRecordFactory<T> fac)
public uk.ac.ed.epcc.webapp.AppContext getContext()
getContext in interface uk.ac.ed.epcc.webapp.Contexedpublic boolean parse(DerivedPropertyMap map, java.lang.String current_line) throws AccountingParseException
PropertyContainerParseTargetparse in interface PropertyContainerParseTarget<T extends UsageRecordFactory.Use>AccountingParseExceptionmap - DerivedPropertyMap to be populatedpublic java.util.Iterator<java.lang.String> splitRecords(java.lang.String update)
throws AccountingParseException
PropertyContainerParseTargetsplitRecords in interface PropertyContainerParseTarget<T extends UsageRecordFactory.Use>AccountingParseExceptionpublic void startParse(PropertyMap defaults) throws java.lang.Exception
PropertyContainerParseTargetstartParse in interface PropertyContainerParseTarget<T extends UsageRecordFactory.Use>java.lang.Exceptiondefaults - PropertyMap of default global propertiespublic java.lang.StringBuilder endParse()
PropertyContainerParseTargetendParse in interface PropertyContainerParseTarget<T extends UsageRecordFactory.Use>public PropertyFinder getFinder()
PropertyContainerParseTargetgetFinder in interface PropertyContainerParseTarget<T extends UsageRecordFactory.Use>protected java.util.Set<PropertyTag> parsePropertyList(java.lang.String list) throws InvalidPropertyException
InvalidPropertyExceptionprotected java.util.Set<PropertyTag> getUniqueProperties()
public T findDuplicate(T r) throws java.lang.Exception
UsageRecordParseTargetfindDuplicate in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>java.lang.Exceptionr - Uncommitted AccountingRecordpublic boolean isComplete(T r)
UsageRecordParseTargetisComplete in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>public void deleteRecord(T old_record) throws java.lang.Exception, uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFault
UsageRecordParseTargetdeleteRecord in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>java.lang.Exceptionuk.ac.ed.epcc.webapp.model.data.Exceptions.DataFaultpublic boolean commitRecord(PropertyContainer map, T record) throws uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFault
UsageRecordParseTargetcommitRecord in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFaultmap - Full PropertyContainer for new recordrecord - new record to commitpublic void updateRecord(DerivedPropertyMap map, T record) throws java.lang.Exception
UsageRecordParseTargetupdateRecord in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFaultjava.lang.Exceptionpublic boolean allowReplace(DerivedPropertyMap map, T record)
UsageRecordParseTargetallowReplace in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>map - DerivedPropertyMap of new parsed valuesrecord - existing recordpublic T prepareRecord(DerivedPropertyMap map) throws uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFault, InvalidPropertyException, AccountingParseException
UsageRecordParseTargetprepareRecord in interface UsageRecordParseTarget<T extends UsageRecordFactory.Use>uk.ac.ed.epcc.webapp.model.data.Exceptions.DataFaultInvalidPropertyExceptionAccountingParseExceptionpublic java.lang.String getUniqueID(T r) throws java.lang.Exception
java.lang.Exception