コード例 #1
0
  private static SeadDataLocation getPrimaryDataLocation(SolrDocument doc) {
    SeadDataLocation primaryDataLocation = new SeadDataLocation();

    primaryDataLocation.setName(getFirst(doc, SeadSolrField.PrimaryDataLocationField.NAME));
    primaryDataLocation.setType(getFirst(doc, SeadSolrField.PrimaryDataLocationField.TYPE));
    primaryDataLocation.setLocation(getFirst(doc, SeadSolrField.PrimaryDataLocationField.LOCATION));

    return primaryDataLocation;
  }
コード例 #2
0
  private static Set<SeadDataLocation> getSecondaryDataLocationSet(SolrDocument doc) {
    Set<SeadDataLocation> locSet = new HashSet<SeadDataLocation>();

    String[] name = setgetAll(doc, SeadSolrField.DataLocationField.NAME);
    String[] types = setgetAll(doc, SeadSolrField.DataLocationField.TYPE);
    String[] locations = setgetAll(doc, SeadSolrField.DataLocationField.LOCATION);

    for (int i = 0; i < locations.length; i++) {

      SeadDataLocation dataLocation = new SeadDataLocation();

      dataLocation.setName(name[i]);
      dataLocation.setType(types[i]);
      dataLocation.setLocation(locations[i]);

      locSet.add(dataLocation);
    }

    return locSet;
  }
コード例 #3
0
  private static SolrInputDocument toSolr(SeadFile file, ArchiveStore store) throws IOException {
    SolrInputDocument doc = new SolrInputDocument();
    add(doc, EntityField.ID, file.getId());
    add(doc, EntityField.TYPE, EntityTypeValue.FILE.solrValue());

    add(doc, FileField.NAME, file.getName());
    add(doc, FileField.SOURCE, file.getSource());
    add(doc, FileField.SIZE, file.getSizeBytes());

    if (file.getMetadataUpdateDate() == null || file.getMetadataUpdateDate().length() == 0)
      add(
          doc,
          SeadSolrField.EntityField.MDUPDATE_DATE,
          toIso8601(now())); // file.getMetadataUpdateDate());
    else add(doc, SeadSolrField.EntityField.MDUPDATE_DATE, file.getMetadataUpdateDate());

    if (file.getValid() != null) {
      doc.addField(FileField.VALID.solrName(), file.getValid());
    }

    doc.addField(FileField.EXTANT.solrName(), file.isExtant());

    addFixitySet(doc, file.getFixity());
    addFormatSet(doc, file.getFormats());
    addResourceIdentifierSet(doc, file.getAlternateIds());

    SeadDataLocation primaryDataLocation = new SeadDataLocation();
    primaryDataLocation.setLocation(file.getPrimaryLocation().getLocation());
    primaryDataLocation.setName(file.getPrimaryLocation().getName());
    primaryDataLocation.setType(file.getPrimaryLocation().getType());
    addPrimaryDataLocation(doc, primaryDataLocation);
    addSecondaryDataLocationSet(doc, file.getSecondaryDataLocations());

    addMetadataSet(doc, file.getMetadata());
    addMetadataRefSet(doc, file.getMetadataRef(), EntityField.METADATA_REF, store);

    return doc;
  }
コード例 #4
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;
  }