public class XMLRecordParser extends BatchParser implements uk.ac.ed.epcc.webapp.Contexed, PropertyContainerParser
Properties are extracted from each XML record using an Xpath expression to
identify the fragment to parse and a DomValueParser to perform the parse.
Subclasses can pre-define properties and use annotations to set the xpath and parser
values.
New properties can be defined by setting: tag.prop.name=type where type is one of string, date or number.
The xpath target is set using tag.prop-name.xpath
Namespaces for use in these Xpaths can be defined using tag.namespace.prefix=uri
The DomValueParser can be set using tag.prop-name.parser
though if this property is not set a default parser is generated using the schema type or the
target type of the property.
ACCOUNT_PROP, batch, BATCH_SCRIPT_PROP, CPU_WAIT_PROP, EXPECTED_FINISH, JOB_ID_PROP, JOB_NAME_PROP, NODE_COUNT_PROP, PARTITION_PROP, PROC_COUNT_PROP, QUEUE_PROP, REQUEST_ACCURACY_PROP, REQUESTED_CPUS_PROP, REQUESTED_WALLCLOCK_PROP, RESIDENCY_PROP, SERIAL_PROP, SLOWDOWN_PROP, SUBJOB_PROP, SUBMITTED_PROP, SUBMITTED_TIMESTAMP, SUCCESS_PROP, TIME_PROP, WAIT_PROP, WALLCLOCK_PROPDUPLICATE_KEY| Constructor and Description |
|---|
XMLRecordParser(uk.ac.ed.epcc.webapp.AppContext context)
Constructs a new
OGFUsageRecordParser. |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
defaultSchemaName()
Default Schema to use when none set via properties
|
java.lang.String |
endParse()
End a batch parse this de-allocates any temporary storage and
and perform any final operations.
|
uk.ac.ed.epcc.webapp.AppContext |
getContext() |
protected XMLSplitter |
getSplitter() |
protected java.lang.String[] |
getTargets() |
protected PropertyFinder |
initFinder(uk.ac.ed.epcc.webapp.AppContext context2,
PropertyFinder prev)
First stage of the initFinder process.
|
PropertyFinder |
initFinder(uk.ac.ed.epcc.webapp.AppContext context,
PropertyFinder prev,
java.lang.String mode)
Generate a PropertyFinder that will find any PropertyTag generated by this class.
|
protected ParsernameSpaceContext |
makeNameSpaceContext()
This is used for namespace resolution
In particular for the Xpath expressions used by the parser.
|
boolean |
parse(PropertyMap map,
java.lang.String record)
Parse a String representation of the UsageRecord.
|
protected void |
postProcess(PropertyMap map)
Extension point to allow a parser to post-process the values.
|
java.util.Iterator<java.lang.String> |
splitRecords(java.lang.String records)
split a multiple record update into individual records
in the way appropriate to this accountng scheme.
|
void |
startParse(PropertyContainer defaults)
Start a batch parse.
|
getDerivedPropertiesreadDouble, readInteger, readLong, readTimegetDefaultUniqueProperties, modifyDefaultTableSpecification, uniqueclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefaultUniquePropertiesgetDerivedProperties, modifyDefaultTableSpecificationpublic XMLRecordParser(uk.ac.ed.epcc.webapp.AppContext context)
OGFUsageRecordParser. This parser is cannot
be considered properly constructed until a called to
initFinder(AppContext, PropertyFinder, String) is made.
Attempts to use this parser before either of the methods have been called
will result in an IllegalStateException being thrown. The
AppContext is replaced when
initFinder(AppContext, PropertyFinder,String) is called.context - The current AppContextpublic java.lang.String endParse()
PropertyContainerUpdaterendParse in interface PropertyContainerUpdaterendParse in class AbstractPropertyContainerUpdaterpublic uk.ac.ed.epcc.webapp.AppContext getContext()
getContext in interface uk.ac.ed.epcc.webapp.Contexedpublic final PropertyFinder initFinder(uk.ac.ed.epcc.webapp.AppContext context, PropertyFinder prev, java.lang.String mode)
PropertyContainerUpdaterAll properties defined at run-time should have their PropertyTag objects constructed by the time the first call to this method returns. As some parsers properties will generate different things depending on the other properties already in scope this method is passed a PropertyFinder for any properties that may already be in scope. This will include any default parameters specified when the data was uploaded and any properties generated from the database meta-data. Though it is perfectly legal to return a PropertyFinder that returns a superset of the generated properties the only requirement is that the returned finder can find any property that this classes parse method may actually generate values for. So Normally the contents of the super-finder are not included in the result unless these values are actually generated by the parse. If values are generated then a MultiFinder can be populated with the PropertyRegistrys from the generated properties
initFinder in interface PropertyContainerUpdaterinitFinder in class BaseParserprev - PropertyFinder for the higher levels in the call chain.mode - String name of the destination table in case per-table customisation is neededprotected PropertyFinder initFinder(uk.ac.ed.epcc.webapp.AppContext context2, PropertyFinder prev)
context2 - prev - protected java.lang.String defaultSchemaName()
public boolean parse(PropertyMap map, java.lang.String record) throws AccountingParseException
PropertyContainerParserparse in interface PropertyContainerParserAccountingParseExceptionmap - PropertyMap to add quantitiesprotected void postProcess(PropertyMap map)
map - public java.util.Iterator<java.lang.String> splitRecords(java.lang.String records)
throws AccountingParseException
AbstractPropertyContainerParsersplitRecords in interface PropertyContainerParsersplitRecords in class AbstractPropertyContainerParserAccountingParseException - If a problem occurs while splitting the recordsrecords - string containing multiple recordsprotected ParsernameSpaceContext makeNameSpaceContext()
protected java.lang.String[] getTargets()
protected XMLSplitter getSplitter()
public void startParse(PropertyContainer defaults) throws java.lang.Exception
PropertyContainerUpdaterstartParse in interface PropertyContainerUpdaterstartParse in class AbstractPropertyContainerUpdaterjava.lang.Exceptiondefaults - properties constant for this accounting run.