/**
   * Adds an executable plan t2flow to the parent.
   *
   * @param t2flow the t2flow to add
   * @param parent the parent element of the element to create
   * @return the newly created element or null if none was created
   * @throws TavernaParserException if the workflow could not be parsed
   * @throws StorageException if the data could not be loaded
   */
  private Element addPreservationActionPlanT2flow(DigitalObject t2flow, Element parent)
      throws TavernaParserException, StorageException {
    Element executablePlan = null;

    if (t2flow != null && t2flow.isDataExistent()) {

      executablePlan = parent.addElement("executablePlan").addAttribute("type", "t2flow");

      if (!addDigitalObjectData) {
        // Add only DigitalObject ID, it can be replaced later
        executablePlan.setText(String.valueOf(t2flow.getId()));
      } else {
        DigitalObject t2flowObject = t2flow;
        try {
          if (t2flowObject.getData().getData() == null
              || t2flowObject.getData().getData().length == 0) {
            t2flowObject = digitalObjectManager.getCopyOfDataFilledDigitalObject(t2flowObject);
          }
          T2FlowParser parser =
              T2FlowParser.createParser(new ByteArrayInputStream(t2flowObject.getData().getData()));
          Document doc = parser.getDoc();
          executablePlan.add(doc.getRootElement());
        } finally {
          t2flowObject = null;
        }
      }
    }
    return executablePlan;
  }
Esempio n. 2
0
  /** Characterises results for all alternatives. */
  public void characteriseResults() {
    List<Alternative> runnableAlternatives = getRunnableAlternatives();
    List<SampleObject> allRecords = plan.getSampleRecordsDefinition().getRecords();
    for (Alternative alternative : runnableAlternatives) {
      Experiment exp = alternative.getExperiment();

      for (SampleObject record : allRecords) {
        DigitalObject u = exp.getResults().get(record);

        if (u.isDataExistent() && (u.getFitsXMLString() == null)) {
          characteriseFits(u);
        }
      }
    }
  }
  /**
   * Adds data for the preservation action plan to the parent element.
   *
   * @param collectionProfile source of the data
   * @param parent the parent element of the element to create
   * @return the newly created element or null if none was created
   * @throws ParserException if the collection profile could not be parsed
   * @throws StorageException if the data could not be loaded
   */
  private Element addPreservationActionPlanData(CollectionProfile collectionProfile, Element parent)
      throws ParserException, StorageException {

    Element collection = null;
    if (collectionProfile != null) {
      collection = parent.addElement("collection");
      collection.addAttribute("uid", collectionProfile.getCollectionID());
      // TODO: Collection has no name
      // collection.addAttribute("name",
      // p.getSampleRecordsDefinition().getCollectionProfile().getCollectionID());

      // Objects
      Element objects = parent.addElement("objects");

      DigitalObject profileObject = collectionProfile.getProfile();
      try {
        if (profileObject != null && profileObject.isDataExistent()) {

          if (!addDigitalObjectData) {
            objects.setText(String.valueOf(profileObject.getId()));
          } else {

            if (profileObject.getData().getData() == null
                || profileObject.getData().getData().length == 0) {
              profileObject = digitalObjectManager.getCopyOfDataFilledDigitalObject(profileObject);
            }

            C3POProfileParser parser = new C3POProfileParser();
            parser.read(new ByteArrayInputStream(profileObject.getData().getData()), false);

            List<String> objectIdentifiers = parser.getObjectIdentifiers();

            for (String objectIdentifier : objectIdentifiers) {
              objects.addElement("object").addAttribute("uid", objectIdentifier);
            }
          }
        }
      } finally {
        profileObject = null;
      }
    }
    return collection;
  }