Ejemplo n.º 1
0
  protected static DcsEntity fromSolr(SolrDocument doc) throws IOException {
    String type = get(doc, EntityField.TYPE);
    if (type == null) {
      throw new IOException("Missing field: " + EntityField.TYPE.solrName());
    }

    if (type.equals(EntityTypeValue.COLLECTION.solrValue())) {
      return getCollection(doc);
    } else if (type.equals(EntityTypeValue.DELIVERABLE_UNIT.solrValue())) {
      return getDeliverableUnit(doc);
    } else if (type.equals(EntityTypeValue.FILE.solrValue())) {
      return getFile(doc);
    } else if (type.equals(EntityTypeValue.MANIFESTATION.solrValue())) {
      return getManifestation(doc);
    } else if (type.equals(EntityTypeValue.EVENT.solrValue())) {
      return getEvent(doc);
    } else {
      throw new IOException("Unknown type: " + type);
    }
  }
Ejemplo n.º 2
0
  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;
  }