Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
  private static DcsFile getFile(SolrDocument doc) {
    SeadFile file = new SeadFile();

    file.setId(get(doc, EntityField.ID));
    file.setFixity(getFixitySet(doc));
    file.setFormats(getFormatSet(doc));
    file.setExtant((Boolean) doc.getFieldValue(FileField.EXTANT.solrName()));

    if (has(doc, FileField.VALID)) {
      file.setValid((Boolean) doc.getFieldValue(FileField.VALID.solrName()));
    }

    if (has(doc, FileField.NAME)) {
      file.setName(getFirst(doc, FileField.NAME));
    }

    if (has(doc, FileField.SOURCE)) {
      file.setSource(getFirst(doc, FileField.SOURCE));
    }

    if (has(doc, SeadSolrField.EntityField.IMMEDIATEANCESTRY)) {
      file.setParent(getFirst(doc, SeadSolrField.EntityField.IMMEDIATEANCESTRY));
    }

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

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

        if (object != null) {
          file.setMetadataUpdateDate(object.toString());
        }
      }
    } else {
      file.setMetadataUpdateDate("2012-10-27T22:05:20.809Z");
    }

    if (has(doc, SeadSolrField.FileField.DEPOSITDATE)) {

      Object object = doc.getFirstValue(SeadSolrField.FileField.DEPOSITDATE.solrName());
      if (object instanceof Date) {
        Date date = (Date) object; // doc.getFirstValue(FileField.DEPOSITDATE.solrName());

        if (date != null) {
          file.setDepositDate(DateUtil.getThreadLocalDateFormat().format(date));
        }
      } else {

        if (object != null) {
          file.setDepositDate(object.toString());
        }
      }
    } else {
      file.setDepositDate("2012-10-27T22:05:20.809Z");
    }

    long size = (Long) doc.getFirstValue(FileField.SIZE.solrName());
    if (size > 0) {
      file.setSizeBytes(size);
    }

    file.setMetadata(getMetadataSet(doc));
    file.setMetadataRef(getMetadataRefSet(doc, EntityField.METADATA_REF));
    file.setAlternateIds(getResourceIdentifierSet(doc));
    SeadDataLocation primaryDataLocation = getPrimaryDataLocation(doc);
    file.setPrimaryLocation(primaryDataLocation);

    file.setSecondaryDataLocations(getSecondaryDataLocationSet(doc));

    return file;
  }