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 2: 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

   
    /**
     * @param digital object
     */
    private List<Property> runCharacterization(DigitalObject digitalObject) {
        WorkflowResultItem wfResultItem = new WorkflowResultItem(
            WorkflowResultItem.SERVICE_ACTION_CHARACTERISATION,
            System.currentTimeMillis());
      wfResultItem.addLogInfo("STEP 1: Characterisation");
        CharacteriseResult characteriseResult = characterise.characterise(
                digitalObject, null);
       wfResultItem.addLogInfo("Characterise name: " + characterise.NAME + ", qname: " + characterise.QNAME);
        List<Property> properties = characteriseResult.getProperties();
        wfResultItem.addLogInfo("Characterised as: " + properties);
        wfResultItem.addLogInfo("Characterise endpoint: " + characterise.describe().getEndpoint());
        return properties;
    }
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());

        List<DigitalObject> objects = new ArrayList<DigitalObject>();
        String metadata;
        String title;  //used to note a file name
        try {
            metadata = null;
            title = null;
           
            //start executing on digital ObjectA
          this.processingDigo = dgo.getPermanentUri();

            try {
              wfResultItem.addLogInfo("****** initial DO. " + dgo.toString());
              // Manage the Digital Object Data Registry:
              wfResultItem.addLogInfo("Create JCR for digital object.");
                JcrDigitalObjectManagerImpl dodm =
                  (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
               
          // Prepare data for digital object - to remove later
            Metadata META1 = new Metadata(URI.create("http://planets-project.eu"), "meta1", "meta1");
            Metadata META2 = new Metadata(URI.create("http://planets-project.eu"), "meta2", "meta2");
            Metadata[] metaList = new Metadata[2];
            metaList[0] = META1;
            metaList[1] = META2;
            Event[] eventList = new Event[2];
            Agent agent = new Agent("id", "name", "type");
            List<eu.planets_project.services.datatypes.Property> propList = new ArrayList<eu.planets_project.services.datatypes.Property>();
            eu.planets_project.services.datatypes.Property
            prop1 = new eu.planets_project.services.datatypes.Property.Builder(URI.create("http://planets-project.eu"))
                 .name("Java JVM System Properties")
                 .value("value")
                 .description("description")
                 .unit("unit")
                 .type("type")
                 .build();
            eu.planets_project.services.datatypes.Property
            prop2 = new eu.planets_project.services.datatypes.Property.Builder(URI.create("http://planets-project.eu"))
                 .name("Java JVM System Properties2")
                 .value("value2")
                 .description("description2")
                 .unit("unit2")
                 .type("type2")
                 .build();
            propList.add(prop1);
            propList.add(prop2);
            Event event1 = new Event("summary1", "datetime1", 10.23d, agent, propList);
            Event event2 = new Event("summary2", "datetime2", 22.45d, agent, propList);
            eventList[0] = event1;
            eventList[1] = event2;

        dgo = new DigitalObject.Builder(dgo.getContent())
            .title(dgo.getTitle())
                     .permanentUri(DOREP)
                     .manifestationOf(DOFORMAT)
                     .format(DOFORMAT)
                     .metadata(metaList)
                     .events(eventList)
                     .build();

               
        wfResultItem.addLogInfo("****** Store DO in JCR. " + dgo.toString());
              DigitalObject resultDO = dodm.store(PERMANENT_URI_PATH, dgo, true);
              DigitalObject resultDO2 = dodm.store(PERMANENT_URI_PATH_2, dgo, true);
              DigitalObject resultDO3 = dodm.store(PERMANENT_URI_PATH_3, dgo, true);
              URI permanentUri = resultDO.getPermanentUri();
              URI permanentUri2 = resultDO2.getPermanentUri();
              URI permanentUri3 = resultDO3.getPermanentUri();
              wfResultItem.addLogInfo("Store DO in JCR res: " + permanentUri.toString());
                wfResultItem.addLogInfo("Store DO2 in JCR res: " + permanentUri2.toString());
                wfResultItem.addLogInfo("Store DO3 in JCR res: " + permanentUri3.toString());
              DigitalObject tmpDO = dodm.retrieve(permanentUri, true);
              wfResultItem.addLogInfo("result DO from JCR title: " + tmpDO.getTitle());
                wfResultItem.addLogInfo("result DO from JCR content length: " + tmpDO.getContent().length());
               
            DigitalObjectContent c2 = dodm.retrieveContent(permanentUri);
            wfResultItem.addLogInfo("retrieveContent result length: " + c2.length());

              tmpDO = dodm.retrieve(permanentUri, false);
              wfResultItem.addLogInfo("retrieve DO without content");
              if (tmpDO.getContent() != null)
              {
                wfResultItem.addLogInfo("result DO without content from JCR content length: " + tmpDO.getContent().length());
              }

                // Identify
              wfResultItem.addLogInfo("starting identify object: ");
                String[] types = runIdentification(dgo, wfResultItem);
              wfResultItem.addLogInfo("completed identify object format: " +
                  new Message("Identification", new Parameter("File", dgo.getTitle()), new Parameter(
                        "Result", Arrays.asList(types).toString())));

                // Extract metadata - will otherwise get lost between steps!
                List<Metadata> mList = dgo.getMetadata();

                if ((mList != null) && (mList.size() > 0)) {
                    metadata = mList.get(0).getContent();
                }

                if (metadata == null) {
                  wfResultItem.addLogInfo("No metadata contained in DigitalObject!");
                  wfResultItem.addLogInfo("Add title: " + dgo.getTitle());
                    title = dgo.getTitle();
          if(title.contains("."))
          {
            title = title.substring(0, title.lastIndexOf("."));
          }
              URI myMigrateToURI =
                    this.getServiceCallConfigs(this.migrate).getPropertyAsURI(SER_PARAM_MIGRATE_TO);
                    String newExtension =
                          FormatRegistryFactory.getFormatRegistry().getFirstExtension(myMigrateToURI);
                      title = title + "." + newExtension;
                } else {
                  wfResultItem.addLogInfo("Extracted metadata: " + metadata);
                }
               
                // Migrate
                try {
                    FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
                    String ext = fr.getFirstExtension(new URI(types[0]));
                    wfResultItem.addLogInfo("Getting extension: " + ext);
                    if (ext != null) {
                        URI uridgo = runMigration(migrate, dgo.getPermanentUri());
                        dgo = new DigitalObject.Builder(dgo.getContent())
                            .title(title)
                            .build();
                        objects.add(dgo);
                        wfResultItem.addLogInfo("Migration result uri: " + uridgo + ", result: " +
                            new Message("Migration", new Parameter("Input", ext), new Parameter("Result", dgo
                                .getTitle())));
                    }
                } catch (URISyntaxException e) {
                    throw new RuntimeException(e);
                }
            } catch (Exception e) {
              wfResultItem.addLogInfo(e.getClass() + ": " + e.getMessage());
                System.out.println(e);
            }
        } finally {
            /* A final message: */
            /* And return a result object: */
            try {
              wfResultItem.addLogInfo("successfully completed workflow for digitalObject with permanent uri: " + processingDigo);
              wfResultItem.setEndTime(System.currentTimeMillis());
          return this.getWFResult();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
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 {
            wfResultItem.addLogInfo("****** initial DO. " + dgo.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Create JCR for digital object.");
            JcrDigitalObjectManagerImpl dodm =
              (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            wfResultItem.addLogInfo("****** digital object before store.");
          dgo = dodm.store(PERMANENT_URI_PATH, dgo, true);
          wfResultItem.addLogInfo("****** digital object after store: " + dgo.toString());
          URI permanentUri = dgo.getPermanentUri();
            wfResultItem.addLogInfo("Store DO in JCR res: " + permanentUri.toString());
          DigitalObject tmpDO = dodm.retrieve(permanentUri, true);
            wfResultItem.addLogInfo("result DO from JCR content length: " + tmpDO.getContent().length());
            wfResultItem.addLogInfo("result DO from JCR after retrieve: " + tmpDO.toString());
            wfResultItem.setEndTime(System.currentTimeMillis());

    } catch (Exception e) {
      wfResultItem.addLogInfo("exception: "+e.toString()+" for DO: "+dgo.toString());
      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.