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);
}
}
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);
}
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);
});
}
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;
}
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;
}
Aggregations