Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.Event


  public DigitalObject store(URI uri, DigitalObject digitalObject, boolean includeContent)
      throws DigitalObjectNotStoredException
    {
    DigitalObject res = null;
    try {
      Event eIngest = buildIngestEvent(includeContent);
      List<Event> lEvents = digitalObject.getEvents();
      //add the ingest event
      lEvents.add(eIngest);
     
      //create an updated DigitalObject
View Full Code Here


          .unit("boolean")
          .type("repository characteristic")
          .build();
    pList.add(pIngestContent);
    //FIXME: cheating with the duration, but null not allowed
    Event eIngest = new Event(INGEST_EVENT, System.currentTimeMillis()+"", new Double(100), this.getAgent(), pList);
    return eIngest;
  }
View Full Code Here

          wfResultItem.addLogInfo("base URI " + baseUri);
     
          dgoB = dataRegistry.getDigitalObjectManager(baseUri).retrieve(dgoBRef)
          wfResultItem.addLogInfo("dgoB: " + dgoB.toString());
          if (dgoB != null && dgoA.getPermanentUri() != null) {
              Event eMigration = buildEvent(dgoA.getPermanentUri());
            dgoB = addEvent(dgoB, eMigration);
               }

        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
View Full Code Here

          .description("This is a link to original document")
          .unit("URI")
          .type("digital object migration")
          .build();
    pList.add(pIdentificationContent);
    Event eIdentifyFormat = new Event(
        MIGRATE_EVENT, System.currentTimeMillis() + "", new Double(100),
        new Agent("JCR Repository v1.0", "The Planets Jackrabbit Content Repository", "planets://data/repository"),
        pList);
    return eIdentifyFormat;
  }
View Full Code Here

    try {
      // Characterisation service
            wfResultItem.addLogInfo("Start characterization. dgoA: " + dgoA);
            List<Property> properties = runCharacterization(dgoA);
            wfResultItem.addLogInfo("Completed characterization.");
      Event eCharacterisation = buildEvent(properties);
      dgoA = addEvent(dgoA, eCharacterisation, null);
            wfResultItem.addLogInfo("Characterisatin properties added to the digital object.");
                       
            // 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());

      for (WorkflowResultItem wri : getWFResult().getWorkflowResultItems()) {
        wfResultItem.addLogInfo("for Identification parameter: " + Arrays.asList(wri.getServiceParameters()).toString());
        wfResultItem.addLogInfo("for endpoint: " + wri.getServiceEndpoint());
      }

      String initialFileName = dgoA.getPermanentUri().toString().substring(
          dgoA.getPermanentUri().toString().lastIndexOf(URI_SEPARATOR) + 1 );
              wfResultItem.addLogInfo(new Message("Characterisation", new Parameter("File", initialFileName), new Parameter(
                    "Result", "Properties")));
              wfResultItem.addLogInfo(new Message("Identification", new Parameter("File", initialFileName), new Parameter(
                    "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 3: Starting migration");
      URI dgoBRef = runMigration(migrate, dgoA.getPermanentUri(), true);
      wfResultItem.addLogInfo("Completed migration. URI: " + dgoBRef);
     
      String migrationEndpoint = "";
      for (WorkflowResultItem wri : getWFResult().getWorkflowResultItems()) {
        wfResultItem.addLogInfo("for Migration parameter: " + Arrays.asList(wri.getServiceParameters()).toString());
        wfResultItem.addLogInfo("for endpoint: " + wri.getServiceEndpoint());
        if (wri.getServiceParameters().size() > 0
            && Arrays.asList(wri.getServiceParameters()).toString().contains("migration")) {
          wfResultItem.addLogInfo(new Message("Migration", new Parameter("Input", Arrays.asList(types).toString())
          , new Parameter("Result", Arrays.asList(wri.getServiceParameters()).toString())));
          migrationEndpoint = wri.getServiceEndpoint();
        }
      }

      // Evaluate migrated file data
      String migratedFileName = "";
      String migratedFileSize = "";
     
      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();
            migratedFileName = dgoA.getPermanentUri().toString().substring(
                dgoA.getPermanentUri().toString().lastIndexOf(URI_SEPARATOR) + 1 );
            migratedFileSize = Integer.toString(sb.toString().length());
        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
        }
      }
     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 4: 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());
          
          wfResultItem.addLogInfo(new Message("JCRinsert", new Parameter("Digital Object", dgoB.getTitle()), new Parameter(
                    "Result", dgoB.getPermanentUri().toString())));

           // Enrich digital object with format information from identification service
           if (types != null) {
             wfResultItem.addLogInfo("Identified formats count: " + types.length);
        for (int i=0; i<types.length; i++) {
          wfResultItem.addLogInfo("type[" + i + "]: " + types[i]);
        }     

        if (types[0] != null) {
            List<Property> pList = new ArrayList<Property>();
            Property pIdentificationContent = new Property.Builder(URI.create("Identify"))
                  .name("content by reference")
                  .value(types[0].toString())
                  .description("This is a format for initial document identified by identification service")
                  .unit("URI")
                  .type("digital object format")
                  .build();
            pList.add(pIdentificationContent);
            Event eIdentifyFormat = new Event(
                IDENTIFICATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
                new Agent("http://testbed-dev.planets-project.ait.ac.at:80/pserv-pc-droid/Droid?wsdl"
                    , identify.NAME, identify.QNAME.toString()),
                pList);
          dgoB = addEvent(dgoB, eIdentifyFormat, URI.create(types[0]));
         
          List<Property> pMigrationList = new ArrayList<Property>();
          Property pMigrationContent = new Property.Builder(URI.create("Migrate"))
                .name("content by reference")
                .value(types[0].toString())
                .description("This is a migration event")
                .unit("URI")
                .type("digital object format")
                .build();
          pMigrationList.add(pMigrationContent);
            Event eMigration = new Event(
                MIGRATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
                new Agent(migrationEndpoint, migrate.NAME, migrate.QNAME.toString()),
                pMigrationList);
          dgoB = addEvent(dgoB, eMigration, null);
         
               // add create SIP event
          List<Property> pSipList = new ArrayList<Property>();
          Property pSipContent = new Property.Builder(URI.create("CreateSIP"))
                .name("SIP message")
                .value(types[0].toString())
                .description("This is a SIP message creation")
                .unit("file")
                .type("ZIP format")
                .build();
          pSipList.add(pSipContent);
          Event eSip = new Event(
              SIP_CREATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
              new Agent("ZIP file", "The SIP message creation", "ZIP"),
              pSipList);
          dgoB = addEvent(dgoB, eSip, null);         
             }
View Full Code Here

  /**
   * Create a characterisation event.
   * @return The created event
   */
  public Event buildEvent(List<Property> pList) {
    Event eCharacterisation = new Event(
        CHARACTERISATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
        new Agent("http://centos.planets-project.ait.ac.at/pserv-pc-fits/FitsCharacterise?wsdl",
            characterise.NAME, characterise.QNAME.toString()),
        pList);
    return eCharacterisation;
View Full Code Here

                 .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())
View Full Code Here

      }

      DigitalObject migOutput = migrateResult.getDigitalObject();

      // add Migration Event to DigitalObject
      Event migrEvent = buildMigrationOutputEvent(digoToMigrate,
          parameterList, wfResultItem.getStartTime(), wfResultItem
              .getDuration(),serDescr,endpoint);

      List<Event> lEvents = migOutput.getEvents();
      lEvents.add(migrEvent);
View Full Code Here

    propList.add(pMigrDuration);
    propList.add(pSerParams);
    propList.add(pOldContentLink);

    Event migrateEvent = new Event("planets://action/service/migrate",
        startTime + "", new Long(duration).doubleValue(), wfi
            .getWEEAgent(), propList);
    return migrateEvent;

  }
View Full Code Here

    assertTrue("Expecting hasEvent() for INGEST_EVENT to return true",
           DigitalObjectUtils.hasEvent(resContentByValueObject,
           JcrDigitalObjectManagerImpl.INGEST_EVENT));

    // add an ingest event from resContentByValueObject to the expectedStoreDigitalObject
    Event ingestEvent = DigitalObjectUtils.getEventBySummary
    (resContentByValueObject, JcrDigitalObjectManagerImpl.INGEST_EVENT);   
    expectedStoreDigitalObject = DigitalObjectUtils.addEvent(expectedStoreDigitalObject, ingestEvent);

    // except content and permanent URI resContentByValueObject and expectedStoreDigitalObject
    // should be equal
View Full Code Here

TOP

Related Classes of eu.planets_project.services.datatypes.Event

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.