private static SeadEvent getEvent(SolrDocument doc) { SeadEvent event = new SeadEvent(); event.setId(get(doc, EntityField.ID)); Date date = (Date) doc.getFirstValue(EventField.DATE.solrName()); if (date != null) { event.setDate(DateUtil.getThreadLocalDateFormat().format(date)); } event.setDetail(getFirst(doc, EventField.DETAIL)); event.setOutcome(getFirst(doc, EventField.OUTCOME)); event.setEventType(getFirst(doc, EventField.TYPE)); event.setTargets(getEntityRefSet(doc, EventField.TARGET)); event.setAlternateIds(getResourceIdentifierSet(doc)); SeadLogDetail logDetail = new SeadLogDetail(); // if (has(doc, DetailLogField.IPADDRESS)) { logDetail.setIpAddress( (String) doc.getFieldValue(SeadSolrField.DetailLogField.IPADDRESS.solrName())); // } if (has(doc, SeadSolrField.DetailLogField.USERAGENT)) { logDetail.setUserAgent( (String) doc.getFieldValue(SeadSolrField.DetailLogField.USERAGENT.solrName())); } if (has(doc, SeadSolrField.DetailLogField.SUBJECT)) { logDetail.setSubject( (String) doc.getFieldValue(SeadSolrField.DetailLogField.SUBJECT.solrName())); } if (has(doc, SeadSolrField.DetailLogField.NODEIDENTIFIER)) { logDetail.setNodeIdentifier( (String) doc.getFieldValue(SeadSolrField.DetailLogField.NODEIDENTIFIER.solrName())); } event.setLogDetail(logDetail); return event; }
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; }