addCreateUpload(digester, "*/experiment/results/result", null, DigitalObject.class);
addCreateUpload(digester, "*/result/xcdlDescription", "setXcdlDescription", XcdlDescription.class);
// call function addUpload of ExperimentWrapper
CallMethodRule r = new CallMethodRule(1, "addResult", 2); //method with two params
// every time */experiment/uploads/upload is encountered
digester.addRule("*/experiment/results/result", r);
// use attribute "key" as first param
digester.addCallParam("*/experiment/results/result", 0 , "key");
// and the object on stack (DigitalObject) as the second
digester.addCallParam("*/experiment/results/result",1,true);
// addCreateUpload(digester, "*/experiment/xcdlDescriptions/xcdlDescription", null, XcdlDescription.class);
// // call function addXcdlDescription of ExperimentWrapper
// r = new CallMethodRule(1, "addXcdlDescription", 2); //method with two params
// // every time */experiment/xcdlDescriptions/xcdlDescription is encountered
// digester.addRule("*/experiment/xcdlDescriptions/xcdlDescription", r);
// // use attribute "key" as first param
// digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription", 0 , "key");
// // and the object on stack (DigitalObject) as the second
// digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription",1,true);
digester.addObjectCreate("*/experiment/detailedInfos/detailedInfo", DetailedExperimentInfo.class);
digester.addSetProperties("*/experiment/detailedInfos/detailedInfo");
digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/programOutput");
digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/cpr");
// call function "addDetailedInfo" of ExperimentWrapper
r = new CallMethodRule(1, "addDetailedInfo", 2); //method with two params
// every time */experiment/detailedInfos/detailedInfo is encountered
digester.addRule("*/experiment/detailedInfos/detailedInfo", r);
// use attribute "key" as first param
digester.addCallParam("*/experiment/detailedInfos/detailedInfo", 0 , "key");
// and the object on stack as second parameter
digester.addCallParam("*/experiment/detailedInfos/detailedInfo",1,true);
// read contained measurements:
digester.addObjectCreate("*/detailedInfo/measurements/measurement", Measurement.class);
digester.addSetNext("*/detailedInfo/measurements/measurement", "put");
// values are defined with wild-cards, and therefore set automatically
digester.addObjectCreate("*/measurement/property", MeasurableProperty.class);
digester.addSetProperties("*/measurement/property");
digester.addSetNext("*/measurement/property", "setProperty");
// scales are defined with wild-cards, and therefore set automatically
/*
* for each value type a set of rules
* because of FreeStringValue we need to store the value as XML-element
* instead of an attribute
* naming them "ResultValues" wasn't nice too
*/
addCreateValue(digester, BooleanValue.class, "setValue");
addCreateValue(digester, FloatRangeValue.class, "setValue");
addCreateValue(digester, IntegerValue.class, "setValue");
addCreateValue(digester, IntRangeValue.class, "setValue");
addCreateValue(digester, OrdinalValue.class, "setValue");
addCreateValue(digester, PositiveFloatValue.class, "setValue");
addCreateValue(digester, PositiveIntegerValue.class, "setValue");
addCreateValue(digester, YanValue.class, "setValue");
addCreateValue(digester, FreeStringValue.class, "setValue");
// go no go decision
digester.addObjectCreate("*/plan/decision", Decision.class);
digester.addSetProperties("*/plan/decision");
digester.addSetNext("*/plan/decision", "setDecision");
digester.addCallMethod("*/plan/decision/actionNeeded", "setActionNeeded", 0);
digester.addCallMethod("*/plan/decision/reason", "setReason", 0);
digester.addFactoryCreate("*/plan/decision/goDecision", GoDecisionFactory.class);
digester.addSetNext("*/plan/decision/goDecision", "setDecision");
// evaluation
digester.addObjectCreate("*/plan/evaluation", Evaluation.class);
digester.addSetProperties("*/plan/evaluation");
digester.addSetNext("*/plan/evaluation", "setEvaluation");
digester.addCallMethod("*/plan/evaluation/comment", "setComment", 0);
// importance weighting
digester.addObjectCreate("*/plan/importanceWeighting", ImportanceWeighting.class);
digester.addSetProperties("*/plan/importanceWeighting");
digester.addSetNext("*/plan/importanceWeighting", "setImportanceWeighting");
digester.addCallMethod("*/plan/importanceWeighting/comment", "setComment", 0);
// recommendation
digester.addObjectCreate("*/plan/recommendation", RecommendationWrapper.class);
digester.addSetProperties("*/plan/recommendation");
digester.addSetNext("*/plan/recommendation", "setRecommendation");
digester.addCallMethod("*/plan/recommendation/reasoning", "setReasoning", 0);
digester.addCallMethod("*/plan/recommendation/effects", "setEffects", 0);
// transformation
digester.addObjectCreate("*/plan/transformation", Transformation.class);
digester.addSetProperties("*/plan/transformation");
digester.addSetNext("*/plan/transformation", "setTransformation");
digester.addCallMethod("*/plan/transformation/comment", "setComment", 0);
// Tree
/* Some rules for tree parsing are necessary for importing templates too,
* that's why they are added by this static method. */
ProjectImporter.addTreeParsingRulesToDigester(digester);
digester.addObjectCreate("*/leaf/evaluation", HashMap.class);
digester.addSetNext("*/leaf/evaluation", "setValueMap");
/*
* The valueMap has an entry for each (considered) alternative ...
* and for each alternative there is a list of values, one per SampleObject.
* Note: The digester uses a stack, therefore the rule to put the list of values to the valueMap
* must be added after the rule for adding the values to the list.
*/
/*
* 2. and for each alternative there is a list of values, one per SampleObject
*/
digester.addObjectCreate("*/leaf/evaluation/alternative", Values.class);
digester.addCallMethod("*/leaf/evaluation/alternative/comment", "setComment", 0);
/*
* for each result-type a set of rules
* they are added to the valueMap by the rules above
*/
addCreateResultValue(digester, BooleanValue.class);
addCreateResultValue(digester, FloatValue.class);
addCreateResultValue(digester, FloatRangeValue.class);
addCreateResultValue(digester, IntegerValue.class);
addCreateResultValue(digester, IntRangeValue.class);
addCreateResultValue(digester, OrdinalValue.class);
addCreateResultValue(digester, PositiveFloatValue.class);
addCreateResultValue(digester, PositiveIntegerValue.class);
addCreateResultValue(digester, YanValue.class);
addCreateResultValue(digester, FreeStringValue.class);
/*
* 1. The valueMap has an entry for each (considered) alternative ...
*/
// call put of the ValueMap (HashMap)
r = new CallMethodRule(1, "put", 2);
digester.addRule("*/leaf/evaluation/alternative", r);
digester.addCallParam("*/leaf/evaluation/alternative", 0 , "key");
digester.addCallParam("*/leaf/evaluation/alternative",1,true);
// digester.addObjectCreate("*/plan/executablePlan/planWorkflow", ExecutablePlanContentWrapper.class);
// digester.addSetProperties("*/plan/executablePlan/planWorkflow");
// digester.addSetNext("*/plan/executablePlan/planWorkflow", "setRecommendation");
// Executable plan definition
digester.addObjectCreate("*/plan/executablePlan", ExecutablePlanDefinition.class);
digester.addSetProperties("*/plan/executablePlan");
digester.addSetNext("*/plan/executablePlan", "setExecutablePlanDefinition");
//
// Import Planets executable plan if present
//
try {
// object-create rules are called at the beginning element-tags, in the same order as defined
// first create the wrapper
digester.addObjectCreate("*/plan/executablePlan/planWorkflow", NodeContentWrapper.class);
// then an element for workflowConf
digester.addRule("*/plan/executablePlan/planWorkflow/workflowConf", new NodeCreateRule());
// CallMethod and SetNext rules are called at closing element-tags, (last in - first out!)
CallMethodRule rr = new CallMethodRule(1, "setNodeContent", 2);
digester.addRule("*/plan/executablePlan/planWorkflow/workflowConf", rr);
// right below the wrapper is an instance of ExecutablePlanDefinition
digester.addCallParam("*/plan/executablePlan/planWorkflow/workflowConf", 0 , 1);
// provide the name of the setter method
digester.addObjectParam("*/plan/executablePlan/planWorkflow/workflowConf", 1, "setExecutablePlan");
// the generated node is not accessible as CallParam (why?!?), but available for addSetNext
digester.addSetNext("*/plan/executablePlan/planWorkflow/workflowConf", "setNode");
} catch (ParserConfigurationException e) {
PlatoLogger.getLogger(this.getClass()).error(e.getMessage(),e);
}
//
// Import EPrints executable plan if present
//
try {
digester.addObjectCreate("*/plan/executablePlan/eprintsPlan", NodeContentWrapper.class);
// then an element for workflowConf
digester.addRule("*/plan/executablePlan/eprintsPlan", new NodeCreateRule());
CallMethodRule rr2 = new CallMethodRule(1, "setNodeContentEPrintsPlan", 2);
digester.addRule("*/plan/executablePlan/eprintsPlan", rr2);
// right below the wrapper is an instance of ExecutablePlanDefinition
digester.addCallParam("*/plan/executablePlan/eprintsPlan", 0 , 1);
// provide the name of the setter method
digester.addObjectParam("*/plan/executablePlan/eprintsPlan", 1, "setEprintsExecutablePlan");