private static SolrInputDocument toSolr(SeadDeliverableUnit du, ArchiveStore store)
      throws IOException {
    SolrInputDocument doc = new SolrInputDocument();

    add(doc, EntityField.ID, du.getId());
    add(doc, EntityField.TYPE, EntityTypeValue.DELIVERABLE_UNIT.solrValue());
    // add(doc, EntityField.MDUPDATE_DATE, du.getMetadataUpdateDate());

    // if(du.getMetadataUpdateDate()==null)
    add(doc, SeadSolrField.EntityField.MDUPDATE_DATE, toIso8601(now()));
    //        else
    //            add(doc, EntityField.MDUPDATE_DATE, du.getMetadataUpdateDate());

    add(doc, CoreMetadataField.TITLE, du.getTitle());

    if (du.getRights() != null) {
      add(doc, CoreMetadataField.RIGHTS, du.getRights());
    }

    addRefSet(doc, du.getCollections(), DeliverableUnitField.COLLECTIONS);
    addRefSet(doc, du.getParents(), DeliverableUnitField.PARENT);
    addMetadataRefSet(doc, du.getMetadataRef(), EntityField.METADATA_REF, store);

    addStrings(doc, du.getFormerExternalRefs(), DeliverableUnitField.FORMER_REFS);

    // addStrings(doc, du.getCreators(), CoreMetadataField.CREATOR);
    if (du.getSubmitter() != null) addSubmitter(doc, du.getSubmitter());
    addCreatorSet(doc, du.getDataContributors());
    addStrings(doc, du.getSubjects(), CoreMetadataField.SUBJECT);

    addMetadataSet(doc, du.getMetadata());
    addRelationSet(doc, du.getRelations());
    addResourceIdentifierSet(doc, du.getAlternateIds());
    SeadDataLocation primaryDataLocation = new SeadDataLocation();
    primaryDataLocation.setLocation(du.getPrimaryLocation().getLocation());
    primaryDataLocation.setName(du.getPrimaryLocation().getName());
    primaryDataLocation.setType(du.getPrimaryLocation().getType());
    addPrimaryDataLocation(doc, primaryDataLocation);
    addSecondaryDataLocationSet(doc, du.getSecondaryDataLocations());
    // addFgdcMetadata(doc,du.getMetadata());

    add(doc, CoreMetadataField.TYPE, du.getType());

    if (du.getAbstrct() != null) {
      add(doc, SeadSolrField.EntityField.ABSTRACT, du.getAbstrct());
    }

    String pubDate = du.getPubdate();
    if (pubDate == null) { // use current date
      DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
      Date date = new Date();
      pubDate = dateFormat.format(date);
    }
    add(doc, SeadSolrField.EntityField.PUBDATE, pubDate);

    if (du.getContact() != null) {
      add(doc, SeadSolrField.CoreMetadataField.CONTACT, du.getContact());
    }

    if (du.getSites() != null) {
      add(doc, SeadSolrField.DeliverableUnitField.LOCATION, du.getSites());
    }

    if (du.isDigitalSurrogate() != null) {
      doc.addField(DeliverableUnitField.DIGITAL_SURROGATE.solrName(), du.isDigitalSurrogate());
    }

    return doc;
  }
  private static DcsEntity getDeliverableUnit(SolrDocument doc) {
    SeadDeliverableUnit du = new SeadDeliverableUnit();

    du.setId(get(doc, EntityField.ID));

    if (has(doc, CoreMetadataField.RIGHTS)) {
      du.setRights(get(doc, CoreMetadataField.RIGHTS));
    }

    du.setCollections(getCollectionRefSet(doc, DeliverableUnitField.COLLECTIONS));
    du.setFormerExternalRefs(getStringSet(doc, DeliverableUnitField.FORMER_REFS));

    if (has(doc, CoreMetadataField.TITLE)) {
      du.setTitle(getFirst(doc, CoreMetadataField.TITLE));
    }

    if (has(doc, SeadSolrField.EntityField.ABSTRACT)) {
      String abstrct = get(doc, SeadSolrField.EntityField.ABSTRACT);
      abstrct = StringEscapeUtils.unescapeHtml(abstrct);
      du.setAbstrct(abstrct);
    }

    if (has(doc, SeadSolrField.EntityField.PUBDATE)) {
      String pubdate = getFirst(doc, SeadSolrField.EntityField.PUBDATE);
      du.setPubdate(pubdate);
    }

    if (has(doc, SeadSolrField.EntityField.MDUPDATE_DATE)) {
      Date date = (Date) doc.getFirstValue(SeadSolrField.EntityField.MDUPDATE_DATE.solrName());

      if (date != null) {
        du.setMetadataUpdateDate(DateUtil.getThreadLocalDateFormat().format(date));
      }
    }

    //        if (has(doc, DeliverableUnitField.LOCATION)) {
    //            String location = getFirst(doc, DeliverableUnitField.LOCATION);
    //            du.addSite(location);
    //        }

    du.setSites(getStringSet(doc, SeadSolrField.DeliverableUnitField.LOCATION));

    if (has(doc, SeadSolrField.DeliverableUnitField.SIZEBYTES)) {
      long size = (Long) doc.getFirstValue(SeadSolrField.DeliverableUnitField.SIZEBYTES.solrName());
      if (size > 0) {
        du.setSizeBytes(size);
      }
    }

    if (has(doc, SeadSolrField.DeliverableUnitField.FILENO)) {
      long fileNo = (Long) doc.getFirstValue(SeadSolrField.DeliverableUnitField.FILENO.solrName());
      if (fileNo > 0) {
        du.setFileNo(fileNo);
      }
    }

    if (has(doc, SeadSolrField.CoreMetadataField.CONTACT)) {
      String contact = getFirst(doc, SeadSolrField.CoreMetadataField.CONTACT);
      du.setContact(contact);
    }

    du.setCollections(getCollectionRefSet(doc, DeliverableUnitField.COLLECTIONS));
    du.setFormerExternalRefs(getStringSet(doc, DeliverableUnitField.FORMER_REFS));

    if (has(doc, DeliverableUnitField.DIGITAL_SURROGATE)) {
      du.setDigitalSurrogate(
          (Boolean) doc.getFieldValue(DeliverableUnitField.DIGITAL_SURROGATE.solrName()));
    }

    du.setMetadataRef(getMetadataRefSet(doc, EntityField.METADATA_REF));
    du.setMetadata(getMetadataSet(doc));
    du.setRelations(getRelations(doc));
    du.setParents(getDeliverableUnitRefSet(doc, DeliverableUnitField.PARENT));

    du.setSubjects(getStringSet(doc, CoreMetadataField.SUBJECT));
    du.setDataContributors(getCreatorSet(doc));
    du.setSubmitter(getSubmitter(doc));
    du.setAlternateIds(getResourceIdentifierSet(doc));
    SeadDataLocation primaryDataLocation = getPrimaryDataLocation(doc);
    du.setPrimaryLocation(primaryDataLocation);
    du.setSecondaryDataLocations(getSecondaryDataLocationSet(doc));

    if (has(doc, CoreMetadataField.TYPE)) {
      du.setType(getFirst(doc, CoreMetadataField.TYPE));
    }

    return du;
  }