Ejemplo n.º 1
0
  private static Set<DcsManifestationFile> getManifestationFileSet(SolrDocument doc) {
    Set<DcsManifestationFile> set = new HashSet<DcsManifestationFile>();

    String[] filerefs = setgetAll(doc, ManifestationFileField.FILE_REF);
    String[] paths = setgetAll(doc, ManifestationFileField.PATH);

    for (int i = 0; i < filerefs.length; i++) {
      DcsManifestationFile mf = new DcsManifestationFile();

      if (filerefs[i] != null) {
        mf.setRef(new DcsFileRef(filerefs[i]));
      }

      if (paths[i] != null && paths[i].length() > 0) {
        mf.setPath(paths[i]);
      }

      // <doc
      // field="mf_rel_urn:dataconservancy.org:file/4326762_hasRelationship">urn:dataconservancy.org:rel/isMetadataFor</doc>
      // <doc
      // field="mf_rel_urn:dataconservancy.org:file/4326762_relatedTo">http://dataconservancy.org/dcs/entity/article_du</doc>

      String[] relations =
          setgetAll(
              doc,
              ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName()
                  + filerefs[i]
                  + "_"
                  + RelationField.RELATION.solrName());

      String[] targets =
          setgetAll(
              doc,
              ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName()
                  + filerefs[i]
                  + "_"
                  + RelationField.TARGET.solrName());

      for (int j = 0; j < relations.length; j++) {
        if (relations[j] != null && targets[j] != null) {
          DcsRelation rel = new DcsRelation(relations[j], targets[j]);
          mf.addRel(rel);
        }
      }

      set.add(mf);
    }

    return set;
  }
Ejemplo n.º 2
0
  private static void addManifestationFileSet(
      SolrInputDocument doc, Collection<DcsManifestationFile> set, ArchiveStore store)
      throws IOException {
    for (DcsManifestationFile mf : set) {

      final String fileRef = mf.getRef() == null ? null : mf.getRef().getRef();
      setadd(doc, ManifestationFileField.FILE_REF, fileRef);
      setadd(doc, ManifestationFileField.PATH, mf.getPath());

      final Collection<DcsRelation> rels = mf.getRelSet();

      if (rels != null && !rels.isEmpty() && fileRef != null) {

        addRelationSet(doc, rels);

        for (DcsRelation rel : rels) {

          // <doc
          // field="mf_rel_urn:dataconservancy.org:file/4326762_hasRelationship">urn:dataconservancy.org:rel/isMetadataFor</doc>
          setadd(
              doc,
              ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName()
                  + fileRef
                  + "_"
                  + RelationField.RELATION.solrName(),
              rel.getRelUri());

          // <doc
          // field="mf_rel_urn:dataconservancy.org:file/4326762_relatedTo">http://dataconservancy.org/dcs/entity/article_du</doc>
          setadd(
              doc,
              ManifestationFileField.DYNAMIC_MF_REL_PREFIX.solrName()
                  + fileRef
                  + "_"
                  + RelationField.TARGET.solrName(),
              rel.getRef().getRef());
        }
      }
    }
  }