當前位置: 首頁>>代碼示例>>Java>>正文


Java Datastream類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:hylkevds,項目名稱:SensorThingsProcessor,代碼行數:27,代碼來源:ValidatorNewer.java

示例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;
}
 
開發者ID:hylkevds,項目名稱:SensorThingsProcessor,代碼行數:20,代碼來源:ValidatorNewer.java

示例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;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:25,代碼來源:EntityInserter.java

示例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;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:25,代碼來源:EntityInserter.java

示例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();
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:21,代碼來源:DataArrayValueSerializer.java

示例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;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:22,代碼來源:DatastreamBuilder.java

示例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)));
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:24,代碼來源:EntityFormatterTest.java

示例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)));
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:23,代碼來源:EntityFormatterTest.java

示例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)));
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:22,代碼來源:EntityFormatterTest.java

示例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;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:25,代碼來源:EntityInserter.java

示例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;
}
 
開發者ID:hylkevds,項目名稱:SensorThingsProcessor,代碼行數:14,代碼來源:Service.java

示例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);
}
 
開發者ID:hylkevds,項目名稱:SensorThingsProcessor,代碼行數:10,代碼來源:ProcessorBatchAggregate.java

示例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;
}
 
開發者ID:hylkevds,項目名稱:SensorThingsManager,代碼行數:36,代碼來源:FactoryEntityPanel.java

示例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;
}
 
開發者ID:hylkevds,項目名稱:SensorThingsManager,代碼行數:11,代碼來源:FactoryEntityPanel.java

示例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);
        }
    }
}
 
開發者ID:hylkevds,項目名稱:SensorThingsManager,代碼行數:30,代碼來源:EntityGuiController.java


注:本文中的de.fraunhofer.iosb.ilt.sta.model.Datastream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。