Search in sources :

Example 1 with Id

use of de.fraunhofer.iosb.ilt.sta.model.Id in project SensorThingsProcessor by FraunhoferIOSB.

the class ProcessorBatchAggregate method createOrderFor.

private void createOrderFor(List<AggregateCombo> combos, String message) {
    try {
        AggregateCombo mainCombo = combos.get(0);
        Id sourceId = mainCombo.getSourceId();
        EntityType sourceType = mainCombo.getSourceType();
        Observation obs = parseMessageToObservation(message);
        if (obs.getPhenomenonTime() == null) {
            LOGGER.error("Received Observation with no PhenomenonTime. Message: {}", message);
        } else {
            for (AggregateCombo combo : combos) {
                createOrdersFor(combo, obs, sourceType, sourceId);
            }
        }
    } catch (IOException ex) {
        LOGGER.error("Invalid message.", ex);
    } catch (Exception ex) {
        LOGGER.error("Exception processing!", ex);
    }
}
Also used : EntityType(de.fraunhofer.iosb.ilt.sta.model.EntityType) AggregateCombo(de.fraunhofer.iosb.ilt.stp.processors.aggregation.AggregateCombo) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Id(de.fraunhofer.iosb.ilt.sta.model.Id) ZoneId(java.time.ZoneId) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ServiceFailureException(de.fraunhofer.iosb.ilt.sta.ServiceFailureException) ConfigurationException(de.fraunhofer.iosb.ilt.configurable.ConfigurationException) ProcessException(de.fraunhofer.iosb.ilt.stp.ProcessException) StatusCodeException(de.fraunhofer.iosb.ilt.sta.StatusCodeException) IOException(java.io.IOException)

Example 2 with Id

use of de.fraunhofer.iosb.ilt.sta.model.Id in project FROST-Manager by FraunhoferIOSB.

the class ControllerCollection method createIdColumn.

private void createIdColumn() {
    if (entities.isEmpty() || columnId != null) {
        return;
    }
    Id id = entities.get(0).getEntity().getId();
    if (id == null) {
        return;
    }
    if (id.getValue() instanceof Number) {
        TableColumn<EntityListEntry<T>, Number> column = new TableColumn<>("ID");
        column.setCellValueFactory((TableColumn.CellDataFeatures<EntityListEntry<T>, Number> param) -> {
            if (param.getValue().getEntity().getId() == null) {
                return new ReadOnlyObjectWrapper<>(-1);
            }
            return new ReadOnlyObjectWrapper<>((Number) param.getValue().getEntity().getId().getValue());
        });
        columnId = column;
    } else {
        TableColumn<EntityListEntry<T>, String> column = new TableColumn<>("ID");
        column.setCellValueFactory((TableColumn.CellDataFeatures<EntityListEntry<T>, String> param) -> {
            if (param.getValue().getEntity().getId() == null) {
                return new ReadOnlyObjectWrapper<>("");
            }
            return new ReadOnlyObjectWrapper<>(param.getValue().getEntity().getId().toString());
        });
        columnId = column;
    }
    entityTable.getColumns().add(0, columnId);
}
Also used : Id(de.fraunhofer.iosb.ilt.sta.model.Id) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) TableColumn(javafx.scene.control.TableColumn)

Example 3 with Id

use of de.fraunhofer.iosb.ilt.sta.model.Id in project FROST-Manager by FraunhoferIOSB.

the class ControllerCollection method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    columnName.setCellValueFactory((TableColumn.CellDataFeatures<EntityListEntry<T>, String> param) -> {
        T entity = param.getValue().getEntity();
        Id id = entity.getId();
        String entityString = entity.toString();
        if (id != null && entityString.startsWith(id.toString())) {
            entityString = entityString.substring(id.toString().length()).trim();
        }
        return new ReadOnlyObjectWrapper<>(entityString);
    });
    entityTable.setItems(entities);
    entityTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    entityTable.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends EntityListEntry<T>> observable, EntityListEntry<T> oldValue, EntityListEntry<T> newValue) -> {
        entitySelected(newValue);
    });
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) Id(de.fraunhofer.iosb.ilt.sta.model.Id) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper)

Example 4 with Id

use of de.fraunhofer.iosb.ilt.sta.model.Id in project SensorThingsProcessor by FraunhoferIOSB.

the class ValidatorNewer method getTimeForMultiDatastream.

private Instant getTimeForMultiDatastream(MultiDatastream mds) throws ServiceFailureException {
    Id dsId = mds.getId();
    Instant latest = multiDatastreamCache.get(dsId);
    if (latest == null) {
        Observation firstObs = mds.observations().query().select("@iot.id", "phenomenonTime").orderBy("phenomenonTime desc").first();
        if (firstObs == null) {
            latest = Instant.MIN;
        } else {
            TimeObject phenomenonTime = firstObs.getPhenomenonTime();
            if (phenomenonTime.isInterval()) {
                latest = phenomenonTime.getAsInterval().getStart();
            } else {
                latest = phenomenonTime.getAsDateTime().toInstant();
            }
        }
        multiDatastreamCache.put(dsId, latest);
    }
    return latest;
}
Also used : Instant(java.time.Instant) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) TimeObject(de.fraunhofer.iosb.ilt.sta.model.TimeObject) Id(de.fraunhofer.iosb.ilt.sta.model.Id)

Example 5 with Id

use of de.fraunhofer.iosb.ilt.sta.model.Id in project SensorThingsProcessor by FraunhoferIOSB.

the class ValidatorNewer method getTimeForDatastream.

private Instant getTimeForDatastream(Datastream ds) throws ServiceFailureException {
    Id dsId = ds.getId();
    Instant latest = datastreamCache.get(dsId);
    if (latest == null) {
        Observation firstObs = ds.observations().query().select("@iot.id", "phenomenonTime").orderBy("phenomenonTime desc").first();
        if (firstObs == null) {
            latest = Instant.MIN;
        } else {
            TimeObject phenomenonTime = firstObs.getPhenomenonTime();
            if (phenomenonTime.isInterval()) {
                latest = phenomenonTime.getAsInterval().getStart();
            } else {
                latest = phenomenonTime.getAsDateTime().toInstant();
            }
        }
        datastreamCache.put(dsId, latest);
    }
    return latest;
}
Also used : Instant(java.time.Instant) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) TimeObject(de.fraunhofer.iosb.ilt.sta.model.TimeObject) Id(de.fraunhofer.iosb.ilt.sta.model.Id)

Aggregations

Id (de.fraunhofer.iosb.ilt.sta.model.Id)7 Observation (de.fraunhofer.iosb.ilt.sta.model.Observation)5 ServiceFailureException (de.fraunhofer.iosb.ilt.sta.ServiceFailureException)3 IOException (java.io.IOException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FeatureOfInterest (de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest)2 IdString (de.fraunhofer.iosb.ilt.sta.model.IdString)2 MultiDatastream (de.fraunhofer.iosb.ilt.sta.model.MultiDatastream)2 TimeObject (de.fraunhofer.iosb.ilt.sta.model.TimeObject)2 HttpResponse (de.fraunhofer.iosb.ilt.statests.util.HTTPMethods.HttpResponse)2 Instant (java.time.Instant)2 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)2 Point (org.geojson.Point)2 Test (org.junit.Test)2 ConfigurationException (de.fraunhofer.iosb.ilt.configurable.ConfigurationException)1 StatusCodeException (de.fraunhofer.iosb.ilt.sta.StatusCodeException)1 Datastream (de.fraunhofer.iosb.ilt.sta.model.Datastream)1 EntityType (de.fraunhofer.iosb.ilt.sta.model.EntityType)1 ProcessException (de.fraunhofer.iosb.ilt.stp.ProcessException)1