Ejemplo n.º 1
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)));
      }
    }
  }