Package eu.planets_project.tb.api.model

Examples of eu.planets_project.tb.api.model.Experiment


    /**
     * @return
     */
    private ExecutionRecordImpl getExecutionRecordForSessionId() {
        ExperimentInspector ei = (ExperimentInspector)JSFUtil.getManagedObject("ExperimentInspector");
        Experiment exp = ei.getExperimentBean().getExperiment();
        ifthis.isValid() && exp.getExperimentExecutable().getNumBatchExecutionRecords() > 0 ) {
            for( ExecutionRecordImpl exec : exp.getExperimentExecutable().getBatchExecutionRecords().iterator().next().getRuns() ) {
                ViewResultBean vrb = ViewResultBean.createViewResultBeanFromExecutionRecord(exec);
                if( vrb != null ) {
                    if( this.getSessionId().equals( vrb.getSessionId() )) {
                        return exec;
                    }
View Full Code Here


     * @return
     */
    public String downloadExperiment( Long expID ) {
        if( expID == null ) return "experimentNotFound";
        TestbedManager testbedMan = (TestbedManager)JSFUtil.getManagedObject("TestbedManager")
        Experiment exp = testbedMan.getExperiment(expID);
        return downloadExperiment( (ExperimentImpl) exp );
    }
View Full Code Here

    public String addCommentAction() {
        log.debug("Recieved addCommentAction()" );
        log.debug("Recieved addCommentAction parentId = '" + parentId + "'" );
        log.debug("Recieved addCommentAction expPhase = '" + expPhase + "'" );
       
        Experiment exp = null;
        ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
        exp = expBean.getExperiment();
       
        log.debug("Recieved comment " + getComment() + " for " + expBean.getEname());
       
        Comment cmt = new CommentImpl(exp.getEntityID(), getExpPhase() );
        if( title == null || "".equals(title) ) {
            title = getComment();
            if ( title.length() > CommentBacking.TITLE_LENGTH )
                title = getComment().substring(0, CommentBacking.TITLE_LENGTH );
        }
        // User is?
        UserBean user = (UserBean)JSFUtil.getManagedObject("UserBean");
        // Existing comment?
        if( ! "".equals(commentId) && commentId != null ) {
            cmt = cm.getComment(this.getlCommentID());
        } else {
            cmt.setAuthorID(user.getUserid());
            cmt.setExperimentPhaseID( expBean.getCurrentPhaseName() );
        }
        // Edit/update the comment:
        cmt.setParentID( getlParentID() );
        cmt.setExperimentID(exp.getEntityID());
        cmt.setPostDate( java.util.Calendar.getInstance() );
        cmt.setComment(title , this.comment );
       

        // Add or update, depending on commendId:
View Full Code Here

     */
    private static long storeExperiment( ExperimentImpl exp ) {
        // Merge into DB
        TestbedManager testbedMan = (TestbedManager) JSFUtil.getManagedObject("TestbedManager");
        long lExpID = testbedMan.registerExperiment(exp);
        Experiment newExp = testbedMan.getExperiment(lExpID);
        log.info("Persisted experiment "+newExp.getEntityID());
        return lExpID;
    }
View Full Code Here

   * @param expID
   * @param weeWFResult
   */
  public void processNotify_WorkflowCompleted(long expID, WorkflowResult weeWFResult){
    log.info("processing WEEBatchExperiment: processNotify_WorkflowCompleted");
    Experiment exp = testbedMan.getExperiment(expID);
    if(weeWFResult==null){
      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));
View Full Code Here

   * completed workflow execution
   * @param expID
   * @param failureReason
   */
  public void processNotify_WorkflowFailed(long expID,String failureReason){
    Experiment exp = testbedMan.getExperiment(expID);
    BatchExecutionRecordImpl batchRecord = new BatchExecutionRecordImpl((ExperimentExecutableImpl)exp.getExperimentExecutable());
    batchRecord.setBatchRunSucceeded(false);
   
    this.helperUpdateExpWithBatchRecord(exp, batchRecord);
    //TODO AL: any more fields/events/measurements to extract?
  }
View Full Code Here

  /**
   * All actions of setting an experiment into state 'processing has started'
   * @param expID
   */
  public void processNotify_WorkflowStarted(long expID){
    Experiment exp = testbedMan.getExperiment(expID);
      exp.getExperimentExecutable().setExecutableInvoked(true);
      if ( exp.getExperimentExecutable().getBatchExecutionRecords() != null ) {
            log.info("processNotify_WorkflowStarted: Updating the experiment 'started': #"+exp.getExperimentExecutable().getBatchExecutionRecords().size());
      } else {
            log.info("processNotify_WorkflowStarted: Updating the experiment 'started': "+exp.getExperimentExecutable().getBatchExecutionRecords());
      }
      //testbedMan.updateExperiment(exp);
      edao.updateExperiment(exp);
  }
View Full Code Here

    public ArrayList<Experiment> getErefBeans() {
        ArrayList<Experiment> ert = new ArrayList<Experiment>();
        TestbedManager testbedMan = (TestbedManager)JSFUtil.getManagedObject("TestbedManager")
        for( int i=0; i < this.eref.size(); i++ ) {
            Experiment erp = testbedMan.getExperiment((Long.parseLong(this.eref.get(i))));
            ert.add(i,erp);
        }
        return ert;
    }
View Full Code Here

        fmsg.setDetail("Experiment name was not valid and could not be stored!");
        fmsg.setSummary("Experiment name could not be stored!");
        fmsg.setSeverity(FacesMessage.SEVERITY_ERROR);
        // Flag to catch new/existing state:
        log.debug("Checking if this is a new experiment.");
        Experiment exp = expBean.getExperiment();
        // if not yet created, create new Experiment object and new Bean
        if ((expBean.getID() <= 0)) {
            // Create new Experiment if necessary
            if( exp == null )
                exp = new ExperimentImpl();
            // Get userid info from managed bean
            UserBean currentUser = (UserBean) JSFUtil.getManagedObject("UserBean");
            // set current User as experimenter
            exp.getExperimentSetup().getBasicProperties().setExperimenter(currentUser.getUserid());
            try {
                log.debug("New experiment, setting name: " + expBean.getEname() );
                exp.getExperimentSetup().getBasicProperties().setExperimentName(expBean.getEname());       
            } catch (InvalidInputException e) {
                // add message-tag for duplicate name
                FacesContext ctx = FacesContext.getCurrentInstance();
                ctx.addMessage("ename",fmsg);
                return false;
View Full Code Here

   
    public void executeWorkflow( TestbedBatchJob job ) {
        job.setStatus(TestbedBatchJob.RUNNING);
        job.setPercentComplete(0);
        job.setStartDate(Calendar.getInstance());
        Experiment exp = edao.findExperiment(job.getExpID());
        // Set up the DB:
        BatchExecutionRecordImpl batch = this.createExperimentBatch(job, exp);
       
        try {
            // FIXME, Some experiment types may take all DOBs into one workflow?  Emulation?
           
            // Set up the basics:
            DataHandler dh = new DataHandlerImpl();
            int total = job.getDigitalObjects().size();
            int i = 0;
           
           
            // Process each in turn:
            for( String filename : job.getDigitalObjects() ) {
                Calendar start = Calendar.getInstance();
                log.info("Running job: "+(i+1)+"/"+total);
                DigitalObject dob = dh.get(filename).getDigitalObject();
                WorkflowResult wfr = null;
               
                // Actually run the workflow:
                try {
                    wfr = this.executeWorkflowOn(job, dob);
                    job.setWorkflowResult(filename, wfr);
                } catch( Exception e ) {
                    e.printStackTrace();
                }
               
                // Report:
                if( wfr != null ) {
                    // Patch in the start and end dates:
                    wfr.setStartDate(start);
                    wfr.setEndDate( Calendar.getInstance());
                    // Inspect the report:
                    if( wfr.getReportLog() != null ) {
                        log.info("Got report: " + wfr.getReportLog());
                    }
                    // Is there a result?
                    if( wfr.getResult() != null ) {
                        log.info("Got result: "+wfr.getResult().toString());
                    }
                }

                // Store results in the database:
                this.storeWorkflowResults(job, wfr, dob, filename, batch, exp );
               
                log.info("Ran job: "+(i+1)+"/"+total);
                // Update counter:
                i++;
                job.setPercentComplete((int)(100.0*i/total));
            }
           
            // Record that all went well:
            log.info("Status: DONE - All went well.");
            // Set the job status:
            job.setStatus(TestbedBatchJob.DONE);
            job.setPercentComplete(100);
            job.setEndDate(Calendar.getInstance());
            // Record batch info:
            exp.getExperimentExecutable().setExecutionSuccess(true);
            batch.setBatchRunSucceeded(true);
        } catch( Exception e ) {
            job.setStatus(TestbedBatchJob.FAILED);
            job.setPercentComplete(100);
            job.setEndDate(Calendar.getInstance());
            log.error("Job failed, with exception: "+e);
            batch.setBatchRunSucceeded(false);
            exp.getExperimentExecutable().setExecutionSuccess(false);
            e.printStackTrace();
        }

        // Record general information:
        batch.setEndDate(job.getEndDate());
        exp.getExperimentExecutable().setExecutableInvoked(true);
        exp.getExperimentExecutable().setExecutionCompleted(true);
        exp.getExperimentExecutable().setExecutionEndDate(Calendar.getInstance().getTimeInMillis());
        exp.getExperimentExecution().setEndDate(Calendar.getInstance());
        exp.getExperimentExecution().setState(Experiment.STATE_COMPLETED);
        exp.getExperimentEvaluation().setState(Experiment.STATE_IN_PROGRESS);  
       
        // Persist these changes:
        log.info("Attempting to store results...");
        edao.updateExperiment(exp);
        log.info("Results have been stored in the experiment.");
View Full Code Here

TOP

Related Classes of eu.planets_project.tb.api.model.Experiment

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.