Examples of WorkflowResultItem


Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   * @throws Exception
     */
    private String[] runIdentification(DigitalObject digo) throws Exception {       
        //an object used to document the results of a service call for the WorkflowResult
        //document the service type and start-time
        WorkflowResultItem wfResultItem = new WorkflowResultItem(
            WorkflowResultItem.SERVICE_ACTION_IDENTIFICATION,
            System.currentTimeMillis());
      wfResultItem.addLogInfo("STEP 1: Identification");
       
        //get the parameters that were passed along in the configuration
        List<Parameter> parameterList;
        if(this.getServiceCallConfigs(identify)!=null){
          parameterList = this.getServiceCallConfigs(identify).getAllPropertiesAsParameters();
        }else{
          parameterList = new ArrayList<Parameter>();
        }
 
        //now actually execute the identify operation of the service
        IdentifyResult results = identify.identify(digo, parameterList);
       
        //document the end-time and input digital object and the params
        wfResultItem.setEndTime(System.currentTimeMillis());
        wfResultItem.setInputDigitalObjectRef(digo.getPermanentUri());
        wfResultItem.setServiceParameters(parameterList);
        wfResultItem.setServiceEndpoint(identify.describe().getEndpoint());
       
        //have a look at the service's results
        ServiceReport report = results.getReport();
        List<URI> types = results.getTypes();

        //report service status and type
        wfResultItem.setServiceReport(report);

        if (report.getType() == Type.ERROR) {
            String s = "Service execution failed: " + report.getMessage();
            wfResultItem.addLogInfo(s);
            throw new Exception(s);
        }

        if (types.size() < 1) {
            String s = "The specified file type is currently not supported by this workflow";
            wfResultItem.addLogInfo(s);
            throw new Exception(s);
        }

        String[] strings = new String[types.size()];
        int count = 0;
        for (URI uri : types) {
            strings[count] = uri.toASCIIString();
            //document the result
            wfResultItem.addExtractedInformation(strings[count]);
            count++;
        }
        return strings;
    }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

        try {
          //get the digital objects and iterate one by one
            for (DigitalObject dgoA : this.getData()) {
             
              //document all general actions for this digital object
              WorkflowResultItem wfResultItem = new WorkflowResultItem(dgoA.getPermanentUri(),
                    WorkflowResultItem.GENERAL_WORKFLOW_ACTION,
                    System.currentTimeMillis());
               wfResult.addWorkflowResultItem(wfResultItem);
             
               //start executing on digital ObjectA
              this.processingDigo = dgoA.getPermanentUri();
             
                try {
                    // Migrate Object round-trip
                    wfResultItem.addLogInfo("starting migration A-B");
                    URI dgoBRef = runMigration(migrate1,dgoA.getPermanentUri(),false);
                      wfResultItem.addLogInfo("completed migration A-B");
                      wfResultItem.addLogInfo("starting migration B-C");
                    URI dgoCRef = runMigration(migrate2,dgoBRef,false);
                      wfResultItem.addLogInfo("completed migration B-C");
                      wfResultItem.addLogInfo("starting migration C-D");
                    URI dgoDRef = runMigration(migrate3,dgoCRef,false);
                      wfResultItem.addLogInfo("completed migration C-D");
                      wfResultItem.addLogInfo("starting migration D-E");
                    //this object is documented as main experiment outcome file
                    URI dgoERef = runMigration(migrate4,dgoDRef,true);
                      wfResultItem.addLogInfo("completed migration D-E");
                   
                      wfResultItem.addLogInfo("starting XCDL extraction for A");
                    URI dgoAXCDL = runMigration(migratexcdl1,dgoA.getPermanentUri(),false);
                      wfResultItem.addLogInfo("completed XCDL extraction for A");
                      wfResultItem.addLogInfo("starting XCDL extraction for B");
                    URI dgoEXCDL = runMigration(migratexcdl1,dgoERef,false);
                      wfResultItem.addLogInfo("completed XCDL extraction for B");
                   
                    //perform object comparison
                      wfResultItem.addLogInfo("starting comparisson for XCDL1 and XCDL2");
                    this.compareDigitalObjectsIdentical(dgoAXCDL, dgoEXCDL);
                      wfResultItem.addLogInfo("completed comparisson for XCDL1 and XCDL2");
                   
                      wfResultItem.addLogInfo("successfully completed workflow for digitalObject with permanent uri:"+processingDigo);
                      wfResultItem.setEndTime(System.currentTimeMillis());
                   
                } catch (Exception e) {
                  String err = "workflow execution error for digitalObject #" + count +" with permanent uri: "+processingDigo+"";           
                    wfResultItem.addLogInfo(err+" "+e);
                    wfResultItem.setEndTime(System.currentTimeMillis());
                }
                count++;
            }
           
            wfResult.setEndTime(System.currentTimeMillis());
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

     * @throws Exception
     */
    private void compareDigitalObjectsIdentical(URI digo1Ref, URI digo2Ref) throws Exception {
   
      //creating the logger
      WorkflowResultItem wfResultItem = new WorkflowResultItem(
            WorkflowResultItem.SERVICE_ACTION_COMPARE,
            System.currentTimeMillis());
       wfResult.addWorkflowResultItem(wfResultItem);
       wfResultItem.setAboutExecutionDigoRef(processingDigo);
      
        try {
      //FIXME: using a static list of properties ... this should move to the configuration file
      List<Parameter> configProperties = comparexcdl1.convert(CONFIG);
     
      //document
      wfResultItem.setServiceParameters(configProperties);
      wfResultItem.setStartTime(System.currentTimeMillis());
          wfResultItem.setServiceEndpoint(comparexcdl1.describe().getEndpoint());
         
          DigitalObject digo1 = this.getDataRegistry().retrieve(digo1Ref);
          DigitalObject digo2 = this.getDataRegistry().retrieve(digo2Ref);
     
          //call the comparison service
      CompareResult result = comparexcdl1.compare(digo1, digo2,
          configProperties);
       
      //document
      wfResultItem.setEndTime(System.currentTimeMillis());
      ServiceReport report = result.getReport();
      //report service status and type
      wfResultItem.setServiceReport(report);
      if (report.getType() == Type.ERROR) {
        String s = "Service execution failed: " + report.getMessage();
        wfResultItem.addLogInfo(s);
        throw new Exception(s);
      }
      //document: add report on outputDigitalObject
      wfResultItem.addExtractedInformation(result.getProperties().toString());
      wfResultItem.addLogInfo("comparisson completed");
     
    } catch (Exception e) {
      wfResultItem.addLogInfo("comparisson failed: "+e);
      throw e;
    }
    }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   */
  @SuppressWarnings("finally")
  public WorkflowResult execute(DigitalObject dgoA) {

    // document all general actions for this digital object
    WorkflowResultItem wfResultItem = new WorkflowResultItem(dgoA.getPermanentUri(),
        WorkflowResultItem.GENERAL_WORKFLOW_ACTION, System
            .currentTimeMillis(),this.getWorkflowReportingLogger());
    this.addWFResultItem(wfResultItem);
    wfResultItem.addLogInfo("working on workflow template: "+this.getClass().getName());

    // start executing on digital ObjectA
    this.processingDigo = dgoA.getPermanentUri();

    try {
      //run a pre-Identification service on A to determine it's format
        wfResultItem.addLogInfo("starting identification A");
      URI formatA = identifyFormat(identifyFormatA, dgoA.getPermanentUri());
        wfResultItem.addLogInfo("completed identification A");
      // Migrate Object round-trip
        wfResultItem.addLogInfo("starting migration A-B");
      URI dgoB = runMigration(migrateAB, dgoA.getPermanentUri(), formatA, null, false);
        wfResultItem.addLogInfo("completed migration A-B");
        wfResultItem.addLogInfo("starting migration B-C");
      URI dgoC = runMigration(migrateBC, dgoB,null, formatA, true);
        wfResultItem.addLogInfo("completed migration B-C");
       
      //compare the object's A and C
        wfResultItem.addLogInfo("starting comparison A-C");
      runComparison(compareAC,dgoA.getPermanentUri(),dgoC);
        wfResultItem.addLogInfo("completed comparison A-C");

      //TODO: use the identification service for data enrichment (e.g. mime type of output object)
       
      wfResultItem
        .addLogInfo("successfully completed workflow for digitalObject with permanent uri:"
            + processingDigo);
      wfResultItem.setEndTime(System.currentTimeMillis());

    } catch (Exception e) {
      String err = "workflow execution error for digitalObject #"
          + " with permanent uri: " + processingDigo;
      wfResultItem.addLogInfo(err + " " + e);
      wfResultItem.setEndTime(System.currentTimeMillis());
    }

      return this.getWFResult();
  }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

        // store the digital object in jcr repository
        //URI uriA = this.storeDigitalObjectInRepository(dgoA,new URI("planets://localhost:8080/dr/planets-jcr"));
        //dgoA = this.getDataRegistry().retrieve(uriA);

        // document all general actions for this digital object
        WorkflowResultItem wfResultItem = new WorkflowResultItem(dgoA.getPermanentUri(),
            WorkflowResultItem.GENERAL_WORKFLOW_ACTION, System
                .currentTimeMillis(),this.getWorkflowReportingLogger());
        this.addWFResultItem(wfResultItem);
        wfResultItem.addLogInfo("working on workflow template: "+this.getClass().getName());

        // start executing on digital ObjectA
        this.processingDigo = dgoA;

        try {
          // Migrate Object round-trip
            wfResultItem.addLogInfo("starting migration A-B");
          DigitalObject dgoB = runMigration(migrate1, dgoA, false);
            wfResultItem.addLogInfo("completed migration A-B");
            wfResultItem.addLogInfo("starting migration B-C");
          DigitalObject dgoC = runMigration(migrate2, dgoB, false);
            wfResultItem.addLogInfo("completed migration B-C");
            wfResultItem.addLogInfo("starting migration C-D");
          DigitalObject dgoD = runMigration(migrate3, dgoC, true);
            wfResultItem.addLogInfo("completed migration C-D");

            wfResultItem
              .addLogInfo("successfully completed workflow for digitalObject with permanent uri:"
                  + processingDigo);
            wfResultItem.setEndTime(System.currentTimeMillis());

        } catch (Exception e) {
          String err = "workflow execution error for digitalObject #"
              + count + " with permanent uri: " + processingDigo
              + "";
          wfResultItem.addLogInfo(err + " " + e);
          wfResultItem.setEndTime(System.currentTimeMillis());
        }
        count++;
      }

      this.getWFResult().setEndTime(System.currentTimeMillis());
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   * @param digo2 data registry pointer to digital object2
   * @throws Exception
   */
  private CompareResult runComparison(Compare compareService, URI digo1Ref, URI digo2Ref) throws Exception{
   
    WorkflowResultItem wfResultItem = new WorkflowResultItem(this.processingDigo,
        WorkflowResultItem.SERVICE_ACTION_COMPARE, System
            .currentTimeMillis());
   
    this.getWFResult().addWorkflowResultItem(wfResultItem);

    try {
      // get all parameters that were added in the configuration file
      List<Parameter> parameterList;
      if (this.getServiceCallConfigs(compareService) != null) {
        parameterList = this.getServiceCallConfigs(compareService)
            .getAllPropertiesAsParameters();
      } else {
        parameterList = new ArrayList<Parameter>();
      }

      // document
      wfResultItem.setServiceParameters(parameterList);
      wfResultItem.setStartTime(System.currentTimeMillis());
      // document the endpoint if available - retrieve from WorkflowContext
      String endpoint = this.getWorkflowContext().getContextObject(
          compareService, WorkflowContext.Property_ServiceEndpoint,
          java.lang.String.class);
      if (endpoint != null) {
        wfResultItem.setServiceEndpoint(new URL(endpoint));
      }
      ServiceDescription serDescr = compareService.describe();
      wfResultItem.setServiceDescription(serDescr);

      //retrieve the digital objects from their data registry location
      DigitalObject digo1 = this.retrieveDigitalObjectDataRegistryRef(digo1Ref);
      DigitalObject digo2 = this.retrieveDigitalObjectDataRegistryRef(digo2Ref);
     
      // now call the comparison
      CompareResult compareResult = compareService.compare(digo1,digo2, parameterList);
     
      // document
      wfResultItem.setEndTime(System.currentTimeMillis());
      ServiceReport report = compareResult.getReport();
      // report service status and type
      wfResultItem.setServiceReport(report);
      if (report.getType() == Type.ERROR) {
        String s = "Service execution failed: " + report.getMessage();
        wfResultItem.addLogInfo(s);
        throw new Exception(s);
      }
     
      //document the comparison's output
      if((compareResult.getProperties()!=null)&&(compareResult.getProperties().size()>0)){
        wfResultItem.addLogInfo("Comparing properties of object A: "+digo1.getPermanentUri()+" with object B: "+digo2.getPermanentUri());
        for(Property p : compareResult.getProperties()){
          String extractedInfo = "[name: "+p.getName()+" value: "+p.getValue()+" untit: "+p.getUnit()+" description:"+p.getDescription()+"] \n";
          wfResultItem.addExtractedInformation(extractedInfo);
        }
      }
      else{
        wfResultItem.addLogInfo("No comparison properties received");
      }

      wfResultItem.addLogInfo("comparison completed");

      return compareResult;

    } catch (Exception e) {
      wfResultItem.addLogInfo("comparison failed " + e);
      throw e;
    }
  }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   * @return
   * @throws Exception
   */
   private URI identifyFormat(Identify identifyService, URI digoRef) throws Exception{
    
     WorkflowResultItem wfResultItem = new WorkflowResultItem(this.processingDigo,
          WorkflowResultItem.SERVICE_ACTION_IDENTIFICATION, System
              .currentTimeMillis());
     
     wfResultItem.setInputDigitalObjectRef(digoRef);
      this.getWFResult().addWorkflowResultItem(wfResultItem);
   
    // get all parameters that were added in the configuration file
    List<Parameter> parameterList;
    if (this.getServiceCallConfigs(identifyService) != null) {
      parameterList = this.getServiceCallConfigs(identifyService)
          .getAllPropertiesAsParameters();
    } else {
      parameterList = new ArrayList<Parameter>();
    }
 
    // document
    wfResultItem.setServiceParameters(parameterList);
    // document the endpoint if available - retrieve from WorkflowContext
    String endpoint = this.getWorkflowContext().getContextObject(
        identifyService, WorkflowContext.Property_ServiceEndpoint,
        java.lang.String.class);
    if (endpoint != null) {
      wfResultItem.setServiceEndpoint(new URL(endpoint));
    }
    wfResultItem.setStartTime(System.currentTimeMillis());
   
    //resolve the digital Object reference
    DigitalObject digo = this.retrieveDigitalObjectDataRegistryRef(digoRef);
   
    //call the identification service
    IdentifyResult identifyResults = identifyService.identify(digo,parameterList);
   
    // document
    wfResultItem.setEndTime(System.currentTimeMillis());
    ServiceReport report = identifyResults.getReport();
    // report service status and type
    wfResultItem.setServiceReport(report);
    if (report.getType() == Type.ERROR) {
      String s = "Service execution failed: " + report.getMessage();
      wfResultItem.addLogInfo(s);
      throw new Exception(s);
    }
   
    //document the comparison's output
    URI ret = null;
    if((identifyResults.getTypes()!=null)&&(identifyResults.getTypes().size()>0)){
      wfResultItem.addLogInfo("identifying properties of object: "+digo.getPermanentUri());
      for(URI uri : identifyResults.getTypes()){
        if(ret == null){
          ret = uri;
        }
        String extractedInfo = "[uri: "+uri+"] \n";
        wfResultItem.addExtractedInformation(extractedInfo);
      }
    }
    else{
      String s = "Identification failed: format not identified";
      wfResultItem.addLogInfo(s);
      throw new Exception(s);
    }

    wfResultItem.addLogInfo("Identification completed, using format: "+ret);
    return ret;
   }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   *
   * @see eu.planets_project.ifr.core.wee.api.workflow.WorkflowTemplate#execute()
   */
  @SuppressWarnings("finally")
    public WorkflowResult execute(DigitalObject dgo) {
    WorkflowResultItem wfResultItem = new WorkflowResultItem(
        dgo.getPermanentUri(),
        WorkflowResultItem.GENERAL_WORKFLOW_ACTION,
        System.currentTimeMillis(),
        this.getWorkflowReportingLogger());
    this.addWFResultItem(wfResultItem);
   
      wfResultItem.addLogInfo("working on workflow template: "+this.getClass().getName());
      wfResultItem.addLogInfo("workflow-instance id: "+this.getWorklowInstanceID());
     
    try {
      // start executing on digital Object
      this.processingDigo = dgo;

      // Single Migration
      wfResultItem.addLogInfo("starting migration A-B");
      URI dgoBRef = runMigration(migrate, dgo.getPermanentUri(), true);
        wfResultItem.addLogInfo("completed migration A-B");

      wfResultItem
        .addLogInfo("successfully completed workflow for digitalObject with permanent uri:"
            + processingDigo);
      wfResultItem.setEndTime(System.currentTimeMillis());
    } catch (Exception e) {
      String err = "workflow execution error for digitalObject  with permanent uri: " + processingDigo
      + "";
      wfResultItem.addLogInfo(err + " " + e);
      wfResultItem.setEndTime(System.currentTimeMillis());
    }
    return this.getWFResult();

  }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   */
  @SuppressWarnings("finally")
  public WorkflowResult execute(DigitalObject dgoA) {

    // document all general actions for this digital object
    WorkflowResultItem wfResultItem = new WorkflowResultItem(
        dgoA.getPermanentUri(),
        WorkflowResultItem.GENERAL_WORKFLOW_ACTION,
        System.currentTimeMillis(),
        this.getWorkflowReportingLogger());
    this.addWFResultItem(wfResultItem);
    wfResultItem.addLogInfo("working on workflow template: "+this.getClass().getName());
    wfResultItem.addLogInfo("workflow-instance id: "+this.getWorklowInstanceID());

    // start executing on digital ObjectA
    this.processingDigo = dgoA;

    try {
      // Single Migration
        wfResultItem.addLogInfo("starting migration A-B");
      URI dgoBRef = runMigration(migrate1, dgoA.getPermanentUri(), true);
        wfResultItem.addLogInfo("completed migration A-B");

      //TODO: use the identification service for data enrichment (e.g. mime type of output object)
       
      wfResultItem
        .addLogInfo("successfully completed workflow for digitalObject with permanent uri:"
            + processingDigo);
      wfResultItem.setEndTime(System.currentTimeMillis());

    } catch (Exception e) {
      String err = "workflow execution error for digitalObject with permanent uri: " + processingDigo;
      wfResultItem.addLogInfo(err + " " + e);
      wfResultItem.setEndTime(System.currentTimeMillis());
    }
   
    return this.getWFResult();
  }
View Full Code Here

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowResultItem

   */
  @SuppressWarnings("finally")
  public WorkflowResult execute(DigitalObject dgoA) {

    // document all general actions for this digital object
    WorkflowResultItem wfResultItem = new WorkflowResultItem(
        dgoA.getPermanentUri(),
        WorkflowResultItem.GENERAL_WORKFLOW_ACTION,
        System.currentTimeMillis(),
        this.getWorkflowReportingLogger());
    this.addWFResultItem(wfResultItem);
    wfResultItem.addLogInfo("working on workflow template: "+this.getClass().getName());
    wfResultItem.addLogInfo("workflow-instance id: "+this.getWorklowInstanceID());

    // start executing on digital ObjectA
    this.processingDigo = dgoA;

    try {
      // TODO Characterisation service
      // TODO Validation service
            // Identification service for data enrichment (e.g. mime type of output object)
            String[] types = runIdentification(dgoA);
            wfResultItem.addLogInfo("Completed identification. result" + Arrays.asList(types).toString());

            // Extract metadata - will otherwise get lost between steps!
            String metadata = "";
            List<Metadata> mList = dgoA.getMetadata();
            if ((mList != null) && (mList.size() > 0)) {
                metadata = mList.get(0).getContent();
            }

            if (metadata == null) {
              wfResultItem.addLogInfo("No metadata contained in DigitalObject!");
            } else {
              wfResultItem.addLogInfo("Extracted metadata: " + metadata);
            }
           

      // Migration service
          wfResultItem.addLogInfo("STEP 2: Starting migration");
      URI dgoBRef = runMigration(migrate, dgoA.getPermanentUri(), true);
      wfResultItem.addLogInfo("Completed migration. URI: " + dgoBRef);
     
      // Add migration resulting text to metadata
      if (dgoBRef != null) {
        try {
            DataRegistry dataRegistry = DataRegistryFactory.getDataRegistry();
          URI baseUri = new PDURI(dgoBRef.normalize()).formDataRegistryRootURI();
          wfResultItem.addLogInfo("base URI " + baseUri);
     
          DigitalObject obj = dataRegistry.getDigitalObjectManager(baseUri).retrieve(dgoBRef);   
          wfResultItem.addLogInfo("obj: " + obj.toString());

          InputStream contentStream = obj.getContent().getInputStream();             
              BufferedReader br = new BufferedReader(new InputStreamReader(contentStream));
              StringBuilder sb = new StringBuilder();
              String line = null;
   
              while ((line = br.readLine()) != null) {
                sb.append(line + "\n");
              }
   
              br.close();
              String migrationResult = sb.toString();
                wfResultItem.addLogInfo("Migrated file contents: " + migrationResult);
            Metadata migrationMetadata = new Metadata(dgoA.getPermanentUri(), MIGRATION_METADATA, migrationResult);
            dgoA = addMetadata(dgoA, migrationMetadata);
        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
        }
      }
     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 3: Insert in JCR repository. initial digital object: " + dgoA.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Initialize JCR repository instance.");
            JcrDigitalObjectManagerImpl dodm =
               (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            DigitalObject dgoB = dodm.store(PERMANENT_URI_PATH, dgoA, true);
           wfResultItem.addLogInfo("Completed storing in JCR repository: " + dgoB.toString());
          
           // Enrich digital object with metadata from characterization service
      Metadata characterisationMetadata = new Metadata(dgoB.getPermanentUri(), CHARACTERISATION_METADATA, "testdata");
      dgoB = addMetadata(dgoB, characterisationMetadata);

      // Update digital object in JCR repository
            wfResultItem.addLogInfo("STEP 4: Update digital object in JCR repository. initial digital object: " +
                dgoB.toString());
           dgoB = dodm.updateDigitalObject(dgoB, false);
           wfResultItem.addLogInfo("Completed update in JCR repository. result digital object: " + dgoB.toString());
           
           
            // TODO Send back to the initial repository
            wfResultItem.addLogInfo("STEP 5: Send enriched digital object back to the initial repository ");           
           wfResultItem.addLogInfo("Completed sending of enriched digital object to the initial repository.");
           
            wfResultItem.setEndTime(System.currentTimeMillis());

      wfResultItem
        .addLogInfo("Successfully completed workflow for digitalObject with permanent uri:"
            + processingDigo);
      wfResultItem.setEndTime(System.currentTimeMillis());

    } catch (Exception e) {
      String err = "workflow execution error for digitalObject with permanent uri: " + processingDigo;
      wfResultItem.addLogInfo(err + " " + e);
      wfResultItem.setEndTime(System.currentTimeMillis());
    }
   
    return this.getWFResult();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.