Ejemplo n.º 1
0
  /**
   * @param m
   * @param sqSupport
   * @param backendRegistry
   * @throws XdsException
   */
  private void updateFoldersLastUpdateTimeSlot(
      Metadata m, SubmitObjectsRequestStoredQuerySupport sqSupport, BackendRegistry backendRegistry)
      throws XdsException {
    // Update any folders "lastUpdateTime" slot with the current time:
    m.updateFoldersLastUpdateTimeSlot();

    // if this submission adds a document to a folder then update that folder's lastUpdateTime Slot
    for (OMElement assoc : m.getAssociations()) {
      if (MetadataSupport.xdsB_eb_assoc_type_has_member.equals(m.getAssocType(assoc))) {
        String sourceId = m.getAssocSource(assoc);
        if (!m.getSubmissionSetId().equals(sourceId) && !m.getFolderIds().contains(sourceId)) {
          // Assoc src not part of the submission
          logger.info("Adding to Folder (1)" + sourceId);
          if (this.isFolder(sourceId, sqSupport)) {
            logger.info("Adding to Folder (2)" + sourceId);
            OMElement res =
                backendRegistry.basicQuery(
                    "SELECT * from RegistryPackage rp WHERE rp.id='" + sourceId + "'", true);
            // Update any folders "lastUpdateTime" slot:
            Metadata fm = MetadataParser.parseNonSubmission(res);
            fm.updateFoldersLastUpdateTimeSlot();
            // OMElement to_backend = fm.getV3SubmitObjectsRequest();
            // log_message.addOtherParam("From Registry Adaptor", to_backend);
            this.submitRegistryRequest(fm, backendRegistry, "Update Folder LastUpdateTime Slot");
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
  /**
   * @param m
   * @param backendRegistry
   * @throws XdsException
   */
  private void updateFolderContentsOnDocumentReplace(Metadata m, BackendRegistry backendRegistry)
      throws XdsException {
    // If this submission includes a DocumentEntry replace and the original DocumentEntry is in a
    // folder
    // then the replacement document must be put into the folder as well.  This must happen here
    // so the following logic to update folder lastUpdateTime can be triggered.

    HashMap<String, String> rplcToOrigIds = new HashMap<String, String>();
    for (OMElement assoc : m.getAssociations()) {
      if (MetadataSupport.xdsB_ihe_assoc_type_rplc.equals(m.getAssocType(assoc))) {
        rplcToOrigIds.put(m.getAssocSource(assoc), m.getAssocTarget(assoc));
      }
    }
    for (String replacementDocumentId : rplcToOrigIds.keySet()) {
      String originalDocumentId = rplcToOrigIds.get(replacementDocumentId);
      // for each original document, find the collection of folders it belongs to
      Metadata me = this.findFoldersForDocumentByUuid(originalDocumentId, backendRegistry);
      List<String> folderIds = me.getObjectIds(me.getObjectRefs());
      // for each folder, add an association placing replacment in that folder
      // This brings up interesting question, should the Assoc between SS and Assoc be generated
      // also?  YES!
      for (String fid : folderIds) {
        OMElement assoc =
            m.addAssociation(
                m.makeAssociation(
                    MetadataSupport.xdsB_eb_assoc_type_has_member, fid, replacementDocumentId));
        OMElement assoc2 =
            m.addAssociation(
                m.makeAssociation(
                    MetadataSupport.xdsB_eb_assoc_type_has_member,
                    m.getSubmissionSetId(),
                    assoc.getAttributeValue(MetadataSupport.id_qname)));
      }
    }
  }