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());
        }
      }
    }
  }
  private static void addRelationSet(SolrInputDocument doc, Collection<DcsRelation> set) {
    if (set == null || set.size() == 0) {
      return;
    }

    for (DcsRelation rel : set) {
      setadd(doc, RelationField.TARGET, rel.getRef() == null ? null : rel.getRef().getRef());
      setadd(doc, RelationField.RELATION, rel.getRelUri());

      if (rel.getRef() != null && rel.getRelUri() != null) {
        doc.addField(RELATION_FIELD_PREFIX + rel.getRelUri(), rel.getRef());
      }
    }
  }
  private static Set<DcsRelation> getRelations(SolrDocument doc) {
    Set<DcsRelation> set = new HashSet<DcsRelation>();

    String[] rels = setgetAll(doc, RelationField.RELATION);
    String[] targets = setgetAll(doc, RelationField.TARGET);

    for (int i = 0; i < rels.length; i++) {
      DcsRelation rel = new DcsRelation();

      if (rels[i] != null) {
        rel.setRelUri(rels[i]);
      }

      if (targets[i] != null) {
        rel.setRef(new DcsEntityReference(targets[i]));
      }

      set.add(rel);
    }

    return set;
  }