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(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;
  }