Package eu.planets_project.tb.impl.model.exec

Examples of eu.planets_project.tb.impl.model.exec.ExecutionRecordImpl


        log.info("Deleting MeasurementEvent "+this.getId());
        TestbedManagerImpl tbm = (TestbedManagerImpl) JSFUtil.getManagedObject("TestbedManager");
        // Now update experiment.
        ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
        BatchExecutionRecordImpl batch = expBean.getExperiment().getExperimentExecutable().getBatchExecutionRecords().iterator().next();
        ExecutionRecordImpl run = batch.getRuns().iterator().next();
       
        // Remove the Event itself:
        ExperimentPersistencyRemote db = tbm.getExperimentPersistencyRemote();
        setTargetInvocation(null);
        setTargetExecution(null);
        db.removeMeasurementEvent(this);
        log.info("deleteMeasurementEvent: Removed the event, now updating the experiment");
       
        // And clip it out of the parent:
        MeasurementEventImpl toRemove = null;
        for( MeasurementEventImpl fme : run.getMeasurementEvents() ) {
            if( fme.getId() == getId())
                toRemove = fme;
        }
        if( toRemove != null ) {
            boolean removed = run.getMeasurementEvents().remove(toRemove);
            if( removed == false ) {
                log.error("Removing the measurement event failed!");
            }
        } else {
            log.error("Could not find event id "+this.getId()+" in the experiment's list of events.");
View Full Code Here


     * @return The list of results, stage by stage.
     */
    public List<StageMeasurementBean> getResultsByStage() {
        List<StageMeasurementBean> ms = new ArrayList<StageMeasurementBean>();
        // Peel through results:
        ExecutionRecordImpl executionRecord = this.getExecutionRecord();
        if( executionRecord == null ) return ms;
        for( ExecutionStageRecordImpl stagei : executionRecord.getStages() ) {
            for( MeasurementImpl res : stagei.getMeasuredObservables() ) {
                ms.add( new StageMeasurementBean( stagei, res ));
            }
           
        }
View Full Code Here

    /**
     * @return
     */
    public MeasurementEventImpl getManualMeasurementEvent() {
        MeasurementEventImpl me = null;
        ExecutionRecordImpl res = this.getExecutionRecordForSessionId();
        if( res == null ) return null;
        Set<MeasurementEventImpl> measurementEvents = res.getMeasurementEvents();
        for( MeasurementEventImpl mee : measurementEvents ) {
            if( mee.getAgent() != null && mee.getAgent().getType() == AgentType.USER ) {
                me = mee;
            }
        }
        // If none, create one and pass it back.
        if( me == null ) {
            log.info("Creating Manual Measurement Event.");
            me = new MeasurementEventImpl(res);
            res.getMeasurementEvents().add(me);
            UserBean user = (UserBean)JSFUtil.getManagedObject("UserBean");
            me.setAgent( new MeasurementAgent( user ));
            ExperimentPersistencyImpl.getInstance();
            ExperimentInspector.persistExperiment();
        }
View Full Code Here

    //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
View Full Code Here

     */
    public static void recordWorkflowResultToExperiment(long eid, WorkflowResult wfr, String filename,
            BatchExecutionRecordImpl batch, Experiment exp ) {
        DataHandler dh = new DataHandlerImpl();
        try {
            ExecutionRecordImpl rec = new ExecutionRecordImpl(batch);
            rec.setDigitalObjectReferenceCopy(filename);
            try {
                rec.setDigitalObjectSource(dh.get(filename).getName());
            } catch (FileNotFoundException e) {
                rec.setDigitalObjectSource(filename);
            }
            // Populate the exec record:
            rec.setStartDate(wfr.getStartDate());
            rec.setEndDate(wfr.getEndDate());
            rec.setReportLog(wfr.getReportLog());
            // And the stages.
            Set<ExecutionStageRecordImpl> stages = rec.getStages();
           
            if( wfr != null && wfr.getStages() != null ) {
                // Examine the result:
                if( WorkflowResult.RESULT_DIGITAL_OBJECT.equals(wfr.getResultType())) {
                    rec.setDigitalObjectResult( (DigitalObject) wfr.getResult(), exp );
                   
                } else if(WorkflowResult.RESULT_CREATEVIEW_RESULT.equals(wfr.getResultType()) ) {
                    CreateViewResult cvr = (CreateViewResult) wfr.getResult( );
                    Properties vp = new Properties();
                    vp.setProperty(ExecutionRecordImpl.RESULT_PROPERTY_CREATEVIEW_SESSION_ID, cvr.getSessionIdentifier());
                    vp.setProperty(ExecutionRecordImpl.RESULT_PROPERTY_CREATEVIEW_VIEW_URL, cvr.getViewURL().toString());
                    vp.setProperty(ExecutionRecordImpl.RESULT_PROPERTY_CREATEVIEW_ENDPOINT_URL, wfr.getMainEndpoint().toString() );
                    rec.setPropertiesListResult(vp);
                   
                } else {
                    rec.setResultType(ExecutionRecordImpl.RESULT_MEASUREMENTS_ONLY);
                }
               
                // Now pull out the stages, which include the measurements etc:
                for( ExecutionStageRecordImpl stage : wfr.getStages() ) {
                    // FIXME Can this be done from the session's Service Registry instead, please!?
                    if( stage.getEndpoint() != null ) {
                        log.info("Recording info about endpoint: "+stage.getEndpoint());
                        stage.setServiceRecord( ServiceBrowser.createServiceRecordFromEndpoint( eid, stage.getEndpoint(), Calendar.getInstance() ) );
                    }
                    // Re-reference this stage object from the Experiment:
                    stages.add(stage);
                }
            }

            batch.getRuns().add(rec);
            log.info("Added records ("+batch.getRuns().size()+") for "+rec.getDigitalObjectSource());
        } catch( Exception e ) {
            log.error("Exception while parsing Execution Record.");
            e.printStackTrace();
        }
       
View Full Code Here

TOP

Related Classes of eu.planets_project.tb.impl.model.exec.ExecutionRecordImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.