log.info("processing WEEBatchExperiment: wfResult = null -> processing notify_WorkflowFailed");
this.processNotify_WorkflowFailed(expID, "WorkflowResult not available");
return;
}
//create a BatchExecutionRecord
BatchExecutionRecordImpl batchRecord = new BatchExecutionRecordImpl( (ExperimentExecutableImpl) exp.getExperimentExecutable() );
//startTime
Calendar c1 = new GregorianCalendar();
c1.setTimeInMillis(weeWFResult.getStartTime());
batchRecord.setStartDate(c1);
//endTime
Calendar c2 = new GregorianCalendar();
c2.setTimeInMillis(weeWFResult.getEndTime());
batchRecord.setStartDate(c2);
BatchWorkflowResultLogImpl wfResultLog = new BatchWorkflowResultLogImpl();
try {
//try serializing the workflow result log- as this is the way it needs to be stored
String wfResultxml = JaxbUtil.marshallObjectwithJAXB(WorkflowResult.class, weeWFResult);
log.debug("Successfully serialized the workflowResult Log via Jaxb" );
//store the wfResultLog in the db model bean
wfResultLog.setSerializedWorkflowResult(wfResultxml);
} catch (Exception e) {
log.debug("Problems serializing wfResultLog object",e);
this.processNotify_WorkflowFailed(expID, "WorkflowResult not serializable");
return;
}
batchRecord.setWorkflowExecutionLog(wfResultLog);
batchRecord.setBatchRunSucceeded(true);
//now iterate over the results and extract and store all crated digos
List<ExecutionRecordImpl> execRecords = new ArrayList<ExecutionRecordImpl>();
//group related wfResult items per input digital objects
Map<URI,List<WorkflowResultItem>> structuredResults = this.getAllWFResultItemsPerInputDigo(weeWFResult);
//FIXME AL: We still need to crate empty executionRecords for the items that weren't processed by the wee (e.g. expSetup.getInputData and compare to the log)
for(URI inputDigoURI : structuredResults.keySet()){
int actionCounter = 0;
ExecutionRecordImpl execRecord = new ExecutionRecordImpl(batchRecord);
//the input Digo for all this information is about
// FIXME This appears to be the resolved URI, not the proper Planets DR URI:
execRecord.setDigitalObjectReferenceCopy(inputDigoURI+"");
Properties p = new Properties();
//iterate over the results and document the migration action - all other information goes into properties.
for(WorkflowResultItem wfResultItem : structuredResults.get(inputDigoURI)){
//1. check if this record was about the migration action
String action = wfResultItem.getSActionIdentifier();
if(action.startsWith(WorkflowResultItem.SERVICE_ACTION_MIGRATION)){
URI outputDigoRef = wfResultItem.getOutputDigitalObjectRef();
if(outputDigoRef!=null){
//DigitalObject outputDigo = dataRegistry.retrieve(outputDigoRef);
//1.a download the ResultDigo into the TB and store it's reference - if it's the final migration producing the output object
if(action.equals(WorkflowResultItem.SERVICE_ACTION_FINAL_MIGRATION)){
//documenting the final output object
URI tbUri = execRecord.setDigitalObjectResult(outputDigoRef, exp);
//FIXME: currently not possible to mix DIGO and PROPERTY result:
p.put(ExecutionRecordImpl.RESULT_PROPERTY_URI, tbUri.toString());
}
else{
//1.b documenting the interim results in a multi-migration-workflow
//DataHandler dh = new DataHandlerImpl();
//URI tbUri = dh.storeDigitalObject(outputDigo, exp);
p.put(ExecutionRecordImpl.RESULT_PROPERTY_INTERIM_RESULT_URI+"["+actionCounter+"]", outputDigoRef.toString());
}
Calendar start = new GregorianCalendar();
start.setTimeInMillis(wfResultItem.getStartTime());
execRecord.setStartDate(start);
Calendar end = new GregorianCalendar();
end.setTimeInMillis(wfResultItem.getEndTime());
execRecord.setEndDate(end);
}
}
//1b. every service action gets persisted as a stage record
ExecutionStageRecordImpl stageRecord = fillInExecutionStageRecord(wfResultItem,actionCounter,execRecord,action,exp.getEntityID());
execRecord.getStages().add(stageRecord);
//2. or about some general reporting information
if(action.startsWith(WorkflowResultItem.GENERAL_WORKFLOW_ACTION)){
execRecord.setReportLog(this.parseReportLog(wfResultItem));
}
//3. document all other metadata for actions: identification, etc. as properties over all actions
try{
this.updateProperties(actionCounter, p, wfResultItem);
}catch(Exception e){
log.error("processing WEEBatchExperiment: Problems crating execution record properties for a workflowResultItem "+e);
}
actionCounter++;
}
try {
execRecord.setPropertiesListResult(p);
} catch (IOException e) {
log.debug("processing WEEBatchExperiment: Problem adding properties to executionRecord: "+e);
}
//got all information - now add the record for this inputDigo
log.info("processing WEEBatchExperiment: Adding an execution record: "+inputDigoURI);
execRecords.add(execRecord);
}
batchRecord.setRuns(execRecords);
this.helperUpdateExpWithBatchRecord(exp, batchRecord);
}