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


Java Observation.setMultiDatastream方法代碼示例

本文整理匯總了Java中de.fraunhofer.iosb.ilt.sta.model.Observation.setMultiDatastream方法的典型用法代碼示例。如果您正苦於以下問題:Java Observation.setMultiDatastream方法的具體用法?Java Observation.setMultiDatastream怎麽用?Java Observation.setMultiDatastream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在de.fraunhofer.iosb.ilt.sta.model.Observation的用法示例。


在下文中一共展示了Observation.setMultiDatastream方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: insertMultiDatastream

import de.fraunhofer.iosb.ilt.sta.model.Observation; //導入方法依賴的package包/類
public boolean insertMultiDatastream(MultiDatastream ds) throws NoSuchEntityException, IncompleteEntityException {
    // First check Sensor and Thing
    Sensor s = ds.getSensor();
    entityExistsOrCreate(s);

    Thing t = ds.getThing();
    entityExistsOrCreate(t);

    SQLQueryFactory qFactory = pm.createQueryFactory();

    QMultiDatastreams qd = QMultiDatastreams.multiDatastreams;
    SQLInsertClause insert = qFactory.insert(qd);
    insert.set(qd.name, ds.getName());
    insert.set(qd.description, ds.getDescription());
    insert.set(qd.observationTypes, objectToJson(ds.getMultiObservationDataTypes()));
    insert.set(qd.unitOfMeasurements, objectToJson(ds.getUnitOfMeasurements()));
    insert.set(qd.properties, objectToJson(ds.getProperties()));

    insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
    insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));
    insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
    insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));

    insert.set(qd.sensorId, (UUID) s.getId().getValue());
    insert.set(qd.thingId, (UUID) t.getId().getValue());

    UUID multiDatastreamId = insert.executeWithKey(qd.id);
    LOGGER.info("Inserted multiDatastream. Created id = {}.", multiDatastreamId);
    ds.setId(new UuidId(multiDatastreamId));

    // Create new Locations, if any.
    EntitySet<ObservedProperty> ops = ds.getObservedProperties();
    int rank = 0;
    for (ObservedProperty op : ops) {
        entityExistsOrCreate(op);
        UUID opId = (UUID) op.getId().getValue();

        QMultiDatastreamsObsProperties qMdOp = QMultiDatastreamsObsProperties.multiDatastreamsObsProperties;
        insert = qFactory.insert(qMdOp);
        insert.set(qMdOp.multiDatastreamId, multiDatastreamId);
        insert.set(qMdOp.obsPropertyId, opId);
        insert.set(qMdOp.rank, rank);
        insert.execute();
        LOGGER.debug("Linked MultiDatastream {} to ObservedProperty {} with rank {}.", multiDatastreamId, opId, rank);
        rank++;
    }

    // Create Observations, if any.
    for (Observation o : ds.getObservations()) {
        o.setMultiDatastream(new MultiDatastreamBuilder().setId(ds.getId()).build());
        o.complete();
        pm.insert(o);
    }

    return true;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:57,代碼來源:EntityInserter.java

示例2: insertMultiDatastream

import de.fraunhofer.iosb.ilt.sta.model.Observation; //導入方法依賴的package包/類
public boolean insertMultiDatastream(MultiDatastream ds) throws NoSuchEntityException, IncompleteEntityException {
    // First check Sensor and Thing
    Sensor s = ds.getSensor();
    entityExistsOrCreate(s);

    Thing t = ds.getThing();
    entityExistsOrCreate(t);

    SQLQueryFactory qFactory = pm.createQueryFactory();

    QMultiDatastreams qd = QMultiDatastreams.multiDatastreams;
    SQLInsertClause insert = qFactory.insert(qd);
    insert.set(qd.name, ds.getName());
    insert.set(qd.description, ds.getDescription());
    insert.set(qd.observationTypes, objectToJson(ds.getMultiObservationDataTypes()));
    insert.set(qd.unitOfMeasurements, objectToJson(ds.getUnitOfMeasurements()));
    insert.set(qd.properties, objectToJson(ds.getProperties()));

    insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MAX.getMillis()));
    insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MIN.getMillis()));
    insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MAX.getMillis()));
    insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MIN.getMillis()));

    insert.set(qd.sensorId, (Long) s.getId().getValue());
    insert.set(qd.thingId, (Long) t.getId().getValue());

    Long multiDatastreamId = insert.executeWithKey(qd.id);
    LOGGER.info("Inserted multiDatastream. Created id = {}.", multiDatastreamId);
    ds.setId(new LongId(multiDatastreamId));

    // Create new Locations, if any.
    EntitySet<ObservedProperty> ops = ds.getObservedProperties();
    int rank = 0;
    for (ObservedProperty op : ops) {
        entityExistsOrCreate(op);
        Long opId = (Long) op.getId().getValue();

        QMultiDatastreamsObsProperties qMdOp = QMultiDatastreamsObsProperties.multiDatastreamsObsProperties;
        insert = qFactory.insert(qMdOp);
        insert.set(qMdOp.multiDatastreamId, multiDatastreamId);
        insert.set(qMdOp.obsPropertyId, opId);
        insert.set(qMdOp.rank, rank);
        insert.execute();
        LOGGER.debug("Linked MultiDatastream {} to ObservedProperty {} with rank {}.", multiDatastreamId, opId, rank);
        rank++;
    }

    // Create Observations, if any.
    for (Observation o : ds.getObservations()) {
        o.setMultiDatastream(new MultiDatastreamBuilder().setId(ds.getId()).build());
        o.complete();
        pm.insert(o);
    }

    return true;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:57,代碼來源:EntityInserter.java

示例3: insertMultiDatastream

import de.fraunhofer.iosb.ilt.sta.model.Observation; //導入方法依賴的package包/類
public boolean insertMultiDatastream(MultiDatastream ds) throws NoSuchEntityException, IncompleteEntityException {
    // First check Sensor and Thing
    Sensor s = ds.getSensor();
    entityExistsOrCreate(s);

    Thing t = ds.getThing();
    entityExistsOrCreate(t);

    SQLQueryFactory qFactory = pm.createQueryFactory();

    QMultiDatastreams qd = QMultiDatastreams.multiDatastreams;
    SQLInsertClause insert = qFactory.insert(qd);
    insert.set(qd.name, ds.getName());
    insert.set(qd.description, ds.getDescription());
    insert.set(qd.observationTypes, objectToJson(ds.getMultiObservationDataTypes()));
    insert.set(qd.unitOfMeasurements, objectToJson(ds.getUnitOfMeasurements()));
    insert.set(qd.properties, objectToJson(ds.getProperties()));

    insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerString.DATETIME_MAX.getMillis()));
    insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerString.DATETIME_MIN.getMillis()));
    insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerString.DATETIME_MAX.getMillis()));
    insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerString.DATETIME_MIN.getMillis()));

    insert.set(qd.sensorId, (String) s.getId().getValue());
    insert.set(qd.thingId, (String) t.getId().getValue());

    String multiDatastreamId = insert.executeWithKey(qd.id);
    LOGGER.info("Inserted multiDatastream. Created id = {}.", multiDatastreamId);
    ds.setId(new StringId(multiDatastreamId));

    // Create new Locations, if any.
    EntitySet<ObservedProperty> ops = ds.getObservedProperties();
    int rank = 0;
    for (ObservedProperty op : ops) {
        entityExistsOrCreate(op);
        String opId = (String) op.getId().getValue();

        QMultiDatastreamsObsProperties qMdOp = QMultiDatastreamsObsProperties.multiDatastreamsObsProperties;
        insert = qFactory.insert(qMdOp);
        insert.set(qMdOp.multiDatastreamId, multiDatastreamId);
        insert.set(qMdOp.obsPropertyId, opId);
        insert.set(qMdOp.rank, rank);
        insert.execute();
        LOGGER.debug("Linked MultiDatastream {} to ObservedProperty {} with rank {}.", multiDatastreamId, opId, rank);
        rank++;
    }

    // Create Observations, if any.
    for (Observation o : ds.getObservations()) {
        o.setMultiDatastream(new MultiDatastreamBuilder().setId(ds.getId()).build());
        o.complete();
        pm.insert(o);
    }

    return true;
}
 
開發者ID:FraunhoferIOSB,項目名稱:SensorThingsServer,代碼行數:57,代碼來源:EntityInserter.java


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