コード例 #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);
    }
  }
コード例 #2
0
  private static SolrInputDocument toSolr(SeadEvent event) {
    SolrInputDocument doc = new SolrInputDocument();

    add(doc, EntityField.ID, event.getId());
    add(doc, EntityField.TYPE, EntityTypeValue.EVENT.solrValue());
    add(doc, EventField.DATE, event.getDate());
    add(doc, EventField.DETAIL, event.getDetail());
    add(doc, EventField.OUTCOME, event.getOutcome());
    add(doc, EventField.TYPE, event.getEventType());
    addResourceIdentifierSet(doc, event.getAlternateIds());

    addRefSet(doc, event.getTargets(), EventField.TARGET);

    if (event.getLogDetail() != null) {
      SeadLogDetail log = event.getLogDetail();
      add(doc, SeadSolrField.DetailLogField.IPADDRESS, log.getIpAddress());
      add(doc, SeadSolrField.DetailLogField.USERAGENT, log.getUserAgent());
      add(doc, SeadSolrField.DetailLogField.SUBJECT, log.getSubject());
      add(doc, SeadSolrField.DetailLogField.NODEIDENTIFIER, log.getNodeIdentifier());
    }

    return doc;
  }