/** * Parses a {@link SolrDocument} into a {@link IDeviceEvent}. * * @param document * @return * @throws SiteWhereException */ public static IDeviceEvent parseDocument(SolrDocument document) throws SiteWhereException { String type = (String) document.getFieldValue(ISolrFields.EVENT_TYPE); if (type == null) { throw new SiteWhereException("Solr event does not contain an event type indicator."); } SolrEventType eventType = SolrEventType.valueOf(type); switch (eventType) { case Location: { return parseLocationFromDocument(document); } case Measurement: { return parseMeasurementFromDocument(document); } case Alert: { return parseAlertFromDocument(document); } default: { throw new SiteWhereException("Solr docuemnt contained unknown device event type."); } } }
/** * Parses a {@link SolrDocument} into a {@link IDeviceEvent}. * * @param document * @return * @throws SiteWhereException */ public static IDeviceEvent parseDocument(SolrDocument document) throws SiteWhereException { String type = (String) document.getFieldValue(ISolrFields.EVENT_TYPE); if (type == null) { throw new SiteWhereException("Solr event does not contain an event type indicator."); } SolrEventType eventType = SolrEventType.valueOf(type); switch (eventType) { case Location: { return parseLocationFromDocument(document); } case Measurements: { return parseMeasurementsFromDocument(document); } case Alert: { return parseAlertFromDocument(document); } default: { throw new SiteWhereException("Solr docuemnt contained unknown device event type."); } } }