当前位置: 首页>>代码示例>>Java>>正文


Java Observation类代码示例

本文整理汇总了Java中de.fraunhofer.iosb.ilt.sta.model.Observation的典型用法代码示例。如果您正苦于以下问题:Java Observation类的具体用法?Java Observation怎么用?Java Observation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Observation类属于de.fraunhofer.iosb.ilt.sta.model包,在下文中一共展示了Observation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValid

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的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.Observation; //导入依赖的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: getTimeForMultiDatastream

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
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;
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:20,代码来源:ValidatorNewer.java

示例4: addToDataArray

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
private void addToDataArray(Observation obs) throws ServiceFailureException, ProcessException {
    if (!validator.isValid(obs)) {
        return;
    }
    Entity ds = obs.getDatastream();
    if (ds == null) {
        ds = obs.getMultiDatastream();
    }
    if (ds == null) {
        throw new IllegalArgumentException("Observation must have a (Multi)Datastream.");
    }
    if (ds != lastDatastream) {
        findDataArrayValue(ds, obs);
    }
    lastDav.addObservation(obs);
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:17,代码来源:Service.java

示例5: getDefinedProperties

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
private Set<DataArrayValue.Property> getDefinedProperties(Observation o) {
    Set<DataArrayValue.Property> value = new HashSet<>();
    value.add(DataArrayValue.Property.Result);
    if (o.getPhenomenonTime() != null) {
        value.add(DataArrayValue.Property.PhenomenonTime);
    }
    if (o.getResultTime() != null) {
        value.add(DataArrayValue.Property.ResultTime);
    }
    if (o.getResultQuality() != null) {
        value.add(DataArrayValue.Property.ResultQuality);
    }
    if (o.getParameters() != null) {
        value.add(DataArrayValue.Property.Parameters);
    }
    if (o.getValidTime() != null) {
        value.add(DataArrayValue.Property.ValidTime);
    }
    return value;
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:21,代码来源:Service.java

示例6: getObservationsForSource

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
public List<Observation> getObservationsForSource(Instant start, Instant end) {
    List<Observation> result = new ArrayList<>();
    if (hasSource()) {
        try {
            StringBuilder filter = new StringBuilder();
            filter.append("overlaps(phenomenonTime,")
                    .append(start.toString())
                    .append("/")
                    .append(end.toString())
                    .append(")");
            EntityList<Observation> entityList = getObsDaoForSource()
                    .query()
                    .filter(filter.toString())
                    .orderBy("phenomenonTime asc")
                    .top(1000)
                    .list();
            for (Iterator<Observation> it = entityList.fullIterator(); it.hasNext();) {
                Observation entity = it.next();
                result.add(entity);
            }
        } catch (ServiceFailureException ex) {
            LOGGER.error("Failed to fetch observations.", ex);
        }
    }
    return result;
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:27,代码来源:ProcessorBatchAggregate.java

示例7: init

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Override
public void init(SensorThingsService service, Observation entity, GridPane gridProperties, Accordion accordionLinks, Label labelId, boolean editable) {
    this.labelId = labelId;
    this.entity = entity;
    int i = 0;
    textPhenomenonTime = addFieldTo(gridProperties, i, "PhenomenonTime", new TextField(), false, editable);
    textResultTime = addFieldTo(gridProperties, ++i, "ResultTime", new TextField(), false, editable);
    textResult = addFieldTo(gridProperties, ++i, "Result", new TextArea(), true, editable);
    textResultQuality = addFieldTo(gridProperties, ++i, "ResultQuality", new TextField(), false, editable);
    textValidTime = addFieldTo(gridProperties, ++i, "ValidTime", new TextField(), false, editable);
    textParameters = addFieldTo(gridProperties, ++i, "Parameters", new TextArea(), true, editable);

    if (accordionLinks != null) {
        try {
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getDatastream(), service.datastreams().query(), entity::setDatastream));
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getMultiDatastream(), service.multiDatastreams().query(), entity::setMultiDatastream));
            accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getFeatureOfInterest(), service.featuresOfInterest().query(), entity::setFeatureOfInterest));
        } catch (IOException | ServiceFailureException ex) {
            LOGGER.error("Failed to create panel.", ex);
        }
    }
}
 
开发者ID:hylkevds,项目名称:SensorThingsManager,代码行数:23,代码来源:EntityGuiController.java

示例8: fromObservation

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
public List<Object> fromObservation(Observation o) {
    List<Object> value = new ArrayList<>();
    if (id) {
        value.add(o.getId().getValue());
    }
    if (phenomenonTime) {
        value.add(o.getPhenomenonTime());
    }
    if (result) {
        value.add(o.getResult());
    }
    if (resultTime) {
        value.add(o.getResultTime());
    }
    if (resultQuality) {
        value.add(o.getResultQuality());
    }
    if (validTime) {
        value.add(o.getValidTime());
    }
    if (parameters) {
        value.add(o.getParameters());
    }
    return value;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:26,代码来源:DefaultResultFormater.java

示例9: build

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Override
public Observation build() {
    Observation o = new Observation(
            id,
            selfLink,
            navigationLink,
            phenomenonTime,
            resultTime,
            result,
            resultQuality,
            validTime,
            parameters,
            datastream,
            multiDatastream,
            featureOfInterest);
    o.setExportObject(isExportObject());
    return o;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:19,代码来源:ObservationBuilder.java

示例10: handleObservationCreateEvent

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
private void handleObservationCreateEvent(ObservationCreateEvent e) {
    // check path?
    if (!e.getTopic().endsWith("Observations")) {
        LOGGER.info("received message on topic '{}' which is no valid topic to create an observation.");
        return;
    }
    String url = e.getTopic().replaceFirst(settings.getApiVersion(), "");
    ServiceResponse<Observation> response = new Service(settings).execute(new ServiceRequestBuilder()
            .withRequestType(RequestType.Create)
            .withContent(e.getPayload())
            .withUrlPath(url)
            .build());
    if (response.isSuccessful()) {
        LOGGER.info("Observation (ID {}) created via MQTT", response.getResult().getId().getValue());
    } else {
        LOGGER.error("Creating observation via MQTT failed (topic: {}, payload: {}, code: {}, message: {})",
                e.getTopic(), e.getPayload(), response.getCode(), response.getMessage());
    }
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:20,代码来源:MqttManager.java

示例11: readObservation_WithAllValuesPresent_Success

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Test
public void readObservation_WithAllValuesPresent_Success() throws IOException {
    String json = "{\n"
            + "  \"phenomenonTime\": \"2015-04-13T00:00:00Z\",\n"
            + "  \"resultTime\" : \"2015-04-13T00:00:05Z\",\n"
            + "  \"result\" : 38,\n"
            + "  \"Datastream\":{\"@iot.id\":100},\n"
            + "  \"FeatureOfInterest\":{\"@iot.id\": 14269},\n"
            + "  \"parameters\":{\"param1\": \"some value1\", \"param2\": \"some value2\"},\n"
            + "  \"phenomenonTime\": \"2015-09-01T14:22:05.149Z\",\n"
            + "  \"resultQuality\": \"none\",\n"
            + "  \"validTime\": \"2014-03-01T13:00:00Z/2015-05-11T15:30:00Z\"\n"
            + "}";
    Observation result = entityParser.parseObservation(json);
    assert (result.isSetPhenomenonTime()
            && result.isSetResultTime()
            && result.isSetResult()
            && result.isSetDatastream()
            && result.isSetFeatureOfInterest()
            && result.isSetParameters()
            && result.isSetPhenomenonTime()
            && result.isSetResultQuality()
            && result.isSetValidTime());
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:25,代码来源:EntityParserTest.java

示例12: readObservation_WithLinkedFeatureOfInterest_Success

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Test
public void readObservation_WithLinkedFeatureOfInterest_Success() throws IOException {
    String json = "{\n"
            + "  \"phenomenonTime\": \"2015-04-13T00:00:00Z\",\n"
            + "  \"resultTime\" : \"2015-04-13T00:00:05Z\",\n"
            + "  \"result\" : 38,\n"
            + "  \"FeatureOfInterest\":{\"@iot.id\": 14269}\n"
            + "}";
    Observation expectedResult = new ObservationBuilder()
            .setPhenomenonTime(TimeInstant.create(new DateTime(2015, 04, 13, 0, 0, 0, DateTimeZone.UTC).getMillis()))
            .setResultTime(TimeInstant.create(new DateTime(2015, 04, 13, 0, 0, 05, DateTimeZone.UTC).getMillis()))
            .setResult(38)
            .setFeatureOfInterest(new FeatureOfInterestBuilder().setId(new LongId(14269)).build())
            .build();
    assertEquals(expectedResult, entityParser.parseObservation(json));
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:17,代码来源:EntityParserTest.java

示例13: isValid

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Override
public boolean isValid(Observation obs) throws ProcessException {
    for (Validator validator : validators) {
        if (!validator.isValid(obs)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:10,代码来源:ValidatorMulti.java

示例14: isValid

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Override
public boolean isValid(Observation obs) throws ProcessException {
    TimeObject phenomenonTime = obs.getPhenomenonTime();
    Instant obsInstant;
    if (phenomenonTime.isInterval()) {
        obsInstant = phenomenonTime.getAsInterval().getStart();
    } else {
        obsInstant = phenomenonTime.getAsDateTime().toInstant();
    }
    return refTime.isBefore(obsInstant);
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:12,代码来源:ValidatorAfter.java

示例15: isValid

import de.fraunhofer.iosb.ilt.sta.model.Observation; //导入依赖的package包/类
@Override
public boolean isValid(Observation obs) throws ProcessException {
    TimeObject phenomenonTime = obs.getPhenomenonTime();
    Instant obsInstant;
    if (phenomenonTime.isInterval()) {
        obsInstant = phenomenonTime.getAsInterval().getStart();
    } else {
        obsInstant = phenomenonTime.getAsDateTime().toInstant();
    }
    return refTime.isAfter(obsInstant);
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:12,代码来源:ValidatorBefore.java


注:本文中的de.fraunhofer.iosb.ilt.sta.model.Observation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。