本文整理汇总了Java中de.fraunhofer.iosb.ilt.sta.model.Datastream类的典型用法代码示例。如果您正苦于以下问题:Java Datastream类的具体用法?Java Datastream怎么用?Java Datastream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Datastream类属于de.fraunhofer.iosb.ilt.sta.model包,在下文中一共展示了Datastream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValid
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Override
public boolean isValid(Observation obs) throws ProcessException {
try {
Instant latest;
Datastream ds = obs.getDatastream();
if (ds == null) {
MultiDatastream mds = obs.getMultiDatastream();
if (mds == null) {
throw new ProcessException("Observation has no Datastream of Multidatastream set!");
}
latest = getTimeForMultiDatastream(mds);
} else {
latest = getTimeForDatastream(ds);
}
TimeObject phenomenonTime = obs.getPhenomenonTime();
Instant obsInstant;
if (phenomenonTime.isInterval()) {
obsInstant = phenomenonTime.getAsInterval().getStart();
} else {
obsInstant = phenomenonTime.getAsDateTime().toInstant();
}
return latest.isBefore(obsInstant);
} catch (ServiceFailureException ex) {
throw new ProcessException("Failed to validate.", ex);
}
}
示例2: getTimeForDatastream
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
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;
}
示例3: insertSensor
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
public boolean insertSensor(Sensor s) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLInsertClause insert = qFactory.insert(qs);
insert.set(qs.name, s.getName());
insert.set(qs.description, s.getDescription());
insert.set(qs.encodingType, s.getEncodingType());
// TODO: Check metadata serialisation.
insert.set(qs.metadata, s.getMetadata().toString());
insert.set(qs.properties, objectToJson(s.getProperties()));
UUID generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new UuidId(generatedId));
// Create new datastreams, if any.
for (Datastream ds : s.getDatastreams()) {
ds.setSensor(new SensorBuilder().setId(s.getId()).build());
ds.complete();
pm.insert(ds);
}
return true;
}
示例4: insertSensor
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
public boolean insertSensor(Sensor s) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLInsertClause insert = qFactory.insert(qs);
insert.set(qs.name, s.getName());
insert.set(qs.description, s.getDescription());
insert.set(qs.encodingType, s.getEncodingType());
// TODO: Check metadata serialisation.
insert.set(qs.metadata, s.getMetadata().toString());
insert.set(qs.properties, objectToJson(s.getProperties()));
Long generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new LongId(generatedId));
// Create new datastreams, if any.
for (Datastream ds : s.getDatastreams()) {
ds.setSensor(new SensorBuilder().setId(s.getId()).build());
ds.complete();
pm.insert(ds);
}
return true;
}
示例5: serialize
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Override
public void serialize(DataArrayValue value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException {
gen.writeStartObject();
Datastream datastream = value.getDatastream();
if (datastream != null) {
gen.writeStringField("[email protected]", datastream.getNavigationLink());
}
MultiDatastream multiDatastream = value.getMultiDatastream();
if (multiDatastream != null) {
gen.writeStringField("[email protected]", multiDatastream.getNavigationLink());
}
gen.writeObjectField("components", value.getComponents());
int count = value.getDataArray().size();
if (count >= 0) {
gen.writeNumberField("[email protected]", count);
}
gen.writeFieldName("dataArray");
gen.writeObject(value.getDataArray());
gen.writeEndObject();
}
示例6: build
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Override
public Datastream build() {
Datastream ds = new Datastream(
id,
selfLink,
navigationLink,
name,
description,
observationType,
properties,
unitOfMeasurement,
observedArea,
phenomenonTime,
resultTime,
sensor,
observedProperty,
thing,
observations);
ds.setExportObject(isExportObject());
return ds;
}
示例7: writeSensor_Basic_Success
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Test
public void writeSensor_Basic_Success() throws Exception {
String expResult
= "{\n"
+ " \"@iot.id\": 1,\n"
+ " \"@iot.selfLink\": \"http://example.org/v1.0/Sensors(1)\",\n"
+ " \"[email protected]\": \"Sensors(1)/Datastreams\",\n"
+ " \"name\": \"TMP36 - Analog Temperature sensor\",\n"
+ " \"description\": \"TMP36 - Analog Temperature sensor\",\n"
+ " \"encodingType\": \"application/pdf\",\n"
+ " \"metadata\": \"http://example.org/TMP35_36_37.pdf\"\n"
+ "}";
Entity entity = new SensorBuilder()
.setId(new LongId(1))
.setSelfLink("http://example.org/v1.0/Sensors(1)")
.setDatastreams(new EntitySetImpl(EntityType.Datastream, "Sensors(1)/Datastreams"))
.setName("TMP36 - Analog Temperature sensor")
.setDescription("TMP36 - Analog Temperature sensor")
.setEncodingType("application/pdf")
.setMetadata("http://example.org/TMP35_36_37.pdf")
.build();
assert (jsonEqual(expResult, new EntityFormatter().writeEntity(entity)));
}
示例8: writeSensor_EmptyDatastreamsCollection_Success
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Test
public void writeSensor_EmptyDatastreamsCollection_Success() throws Exception {
String expResult
= "{\n"
+ " \"@iot.id\": 1,\n"
+ " \"@iot.selfLink\": \"http://example.org/v1.0/Sensors(1)\",\n"
+ " \"name\": \"TMP36 - Analog Temperature sensor\",\n"
+ " \"description\": \"TMP36 - Analog Temperature sensor\",\n"
+ " \"encodingType\": \"application/pdf\",\n"
+ " \"metadata\": \"http://example.org/TMP35_36_37.pdf\"\n"
+ "}";
Entity entity = new SensorBuilder()
.setId(new LongId(1))
.setSelfLink("http://example.org/v1.0/Sensors(1)")
.setDatastreams(new EntitySetImpl(EntityType.Datastream))
.setName("TMP36 - Analog Temperature sensor")
.setDescription("TMP36 - Analog Temperature sensor")
.setEncodingType("application/pdf")
.setMetadata("http://example.org/TMP35_36_37.pdf")
.build();
assert (jsonEqual(expResult, new EntityFormatter().writeEntity(entity)));
}
示例9: writeObservedPropertyBasic_Success
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Test
public void writeObservedPropertyBasic_Success() throws Exception {
String expResult
= "{\n"
+ " \"@iot.id\": 1,\n"
+ " \"@iot.selfLink\": \"http://example.org/v1.0/ObservedProperties(1)\",\n"
+ " \"[email protected]\": \"ObservedProperties(1)/Datastreams\",\n"
+ " \"description\": \"The dewpoint temperature is the temperature to which the air must be cooled, at constant pressure, for dew to form. As the grass and other objects near the ground cool to the dewpoint, some of the water vapor in the atmosphere condenses into liquid water on the objects.\",\n"
+ " \"name\": \"DewPoint Temperature\",\n"
+ " \"definition\": \"http://dbpedia.org/page/Dew_point\"\n"
+ "}";
Entity entity = new ObservedPropertyBuilder()
.setId(new LongId(1))
.setSelfLink("http://example.org/v1.0/ObservedProperties(1)")
.setDatastreams(new EntitySetImpl(EntityType.Datastream, "ObservedProperties(1)/Datastreams"))
.setDescription("The dewpoint temperature is the temperature to which the air must be cooled, at constant pressure, for dew to form. As the grass and other objects near the ground cool to the dewpoint, some of the water vapor in the atmosphere condenses into liquid water on the objects.")
.setName("DewPoint Temperature")
.setDefinition("http://dbpedia.org/page/Dew_point")
.build();
assert (jsonEqual(expResult, new EntityFormatter().writeEntity(entity)));
}
示例10: insertSensor
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
public boolean insertSensor(Sensor s) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLInsertClause insert = qFactory.insert(qs);
insert.set(qs.name, s.getName());
insert.set(qs.description, s.getDescription());
insert.set(qs.encodingType, s.getEncodingType());
// TODO: Check metadata serialisation.
insert.set(qs.metadata, s.getMetadata().toString());
insert.set(qs.properties, objectToJson(s.getProperties()));
String generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new StringId(generatedId));
// Create new datastreams, if any.
for (Datastream ds : s.getDatastreams()) {
ds.setSensor(new SensorBuilder().setId(s.getId()).build());
ds.complete();
pm.insert(ds);
}
return true;
}
示例11: findDataArrayValue
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
private void findDataArrayValue(Entity ds, Observation o) {
DataArrayValue dav = davMap.get(ds);
if (dav == null) {
if (ds instanceof Datastream) {
dav = new DataArrayValue((Datastream) ds, getDefinedProperties(o));
} else {
dav = new DataArrayValue((MultiDatastream) ds, getDefinedProperties(o));
}
davMap.put(ds, dav);
}
lastDav = dav;
lastDatastream = ds;
}
示例12: checkReference
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
private void checkReference(Datastream source, MultiDatastream aggregate) {
String expectedAggFor;
if (sourceEqualsTarget) {
expectedAggFor = "/Datastreams(" + source.getId().getUrl() + ")";
} else {
expectedAggFor = source.getSelfLink().toString();
}
checkReference(aggregate, expectedAggFor);
}
示例13: getPane
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
public static <T extends Entity<T>> Node getPane(SensorThingsService service, EntityType type, T entity, boolean showNavProps) throws IOException {
if (entity != null && entity.getType() != type) {
throw new IllegalArgumentException("Entity must have given type or be null.");
}
switch (type) {
case DATASTREAM:
return getDatastreamPane(service, (Datastream) entity, showNavProps);
case FEATURE_OF_INTEREST:
return getFeatureOfInterestPane(service, (FeatureOfInterest) entity, showNavProps);
case HISTORICAL_LOCATION:
return getHistoricalLocationPane(service, (HistoricalLocation) entity, showNavProps);
case LOCATION:
return getLocationPane(service, (Location) entity, showNavProps);
case MULTIDATASTREAM:
return getMultiDatastreamPane(service, (MultiDatastream) entity, showNavProps);
case OBSERVATION:
return getObservationPane(service, (Observation) entity, showNavProps);
case OBSERVED_PROPERTY:
return getObsPropPane(service, (ObservedProperty) entity, showNavProps);
case SENSOR:
return getSensorPane(service, (Sensor) entity, showNavProps);
case THING:
return getThingPane(service, (Thing) entity, showNavProps);
}
return null;
}
示例14: getDatastreamPane
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
public static Node getDatastreamPane(SensorThingsService service, Datastream entity, boolean showNavProps) throws IOException {
if (entity == null) {
return new Label("No Datastream.");
}
FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
Node content = (Pane) loader.load();
ControllerEntity<Datastream> controller = loader.<ControllerEntity<Datastream>>getController();
controller.setEntity(service, entity, new EntityGuiController.GuiControllerDatastream(), showNavProps);
return content;
}
示例15: init
import de.fraunhofer.iosb.ilt.sta.model.Datastream; //导入依赖的package包/类
@Override
public void init(SensorThingsService service, Datastream entity, GridPane gridProperties, Accordion accordionLinks, Label labelId, boolean editable) {
this.labelId = labelId;
this.entity = entity;
int i = 0;
textName = addFieldTo(gridProperties, i, "Name", new TextField(), false, editable);
textDescription = addFieldTo(gridProperties, ++i, "Description", new TextArea(), true, editable);
textObservationType = addFieldTo(gridProperties, ++i, "ObservationType", new TextField(), false, editable);
textUomName = addFieldTo(gridProperties, ++i, "UoM: Name", new TextField(), false, editable);
textUomSymbol = addFieldTo(gridProperties, ++i, "UoM: Symbol", new TextField(), false, editable);
textUomDefinition = addFieldTo(gridProperties, ++i, "UoM: Definition", new TextField(), false, editable);
textObservedArea = addFieldTo(gridProperties, ++i, "ObservedArea", new TextField(), false, false);
textPhenomenonTime = addFieldTo(gridProperties, ++i, "PhenomenonTime", new TextField(), false, false);
textResultTime = addFieldTo(gridProperties, ++i, "ResultTime", new TextField(), false, false);
if (accordionLinks != null) {
try {
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getThing(), service.things().query(), entity::setThing));
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getSensor(), service.sensors().query(), entity::setSensor));
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getObservedProperty(), service.observedProperties().query(), entity::setObservedProperty));
accordionLinks.getPanes().add(new TitledPane("Observations", createCollectionPaneFor(entity.observations().query())));
} catch (IOException | ServiceFailureException ex) {
LOGGER.error("Failed to create panel.", ex);
} catch (NullPointerException e) {
// Happens when entity is new.
LOGGER.trace("Failed to create panel.", e);
}
}
}