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


Java Thing.setId方法代码示例

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


在下文中一共展示了Thing.setId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    UUID id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new UuidId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例2: create

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    Long id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new LongId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例3: create

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    String id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new StringId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例4: thingFromId

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
private static Thing thingFromId(UUID id) {
    if (id == null) {
        return null;
    }
    Thing thing = new Thing();
    thing.setId(new UuidId(id));
    thing.setExportObject(false);
    return thing;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:10,代码来源:PropertyHelper.java

示例5: thingFromId

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
private static Thing thingFromId(Long id) {
    if (id == null) {
        return null;
    }
    Thing thing = new Thing();
    thing.setId(new LongId(id));
    thing.setExportObject(false);
    return thing;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:10,代码来源:PropertyHelper.java

示例6: thingFromId

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
private static Thing thingFromId(String id) {
    if (id == null) {
        return null;
    }
    Thing thing = new Thing();
    thing.setId(new StringId(id));
    thing.setExportObject(false);
    return thing;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:10,代码来源:PropertyHelper.java

示例7: insertThing

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
public boolean insertThing(Thing t) throws NoSuchEntityException, IncompleteEntityException {
    SQLQueryFactory qFactory = pm.createQueryFactory();
    QThings qt = QThings.things;
    SQLInsertClause insert = qFactory.insert(qt);
    insert.set(qt.name, t.getName());
    insert.set(qt.description, t.getDescription());
    insert.set(qt.properties, objectToJson(t.getProperties()));

    UUID thingId = insert.executeWithKey(qt.id);
    LOGGER.info("Inserted Thing. Created id = {}.", thingId);
    t.setId(new UuidId(thingId));

    // Create new Locations, if any.
    List<UUID> locationIds = new ArrayList<>();
    for (Location l : t.getLocations()) {
        entityExistsOrCreate(l);
        UUID lId = (UUID) l.getId().getValue();

        QThingsLocations qtl = QThingsLocations.thingsLocations;
        insert = qFactory.insert(qtl);
        insert.set(qtl.thingId, thingId);
        insert.set(qtl.locationId, lId);
        insert.execute();
        LOGGER.debug("Linked Location {} to Thing {}.", lId, thingId);
        locationIds.add(lId);
    }

    // Now link the new locations also to a historicalLocation.
    if (!locationIds.isEmpty()) {
        QHistLocations qhl = QHistLocations.histLocations;
        insert = qFactory.insert(qhl);
        insert.set(qhl.thingId, thingId);
        insert.set(qhl.time, new Timestamp(Calendar.getInstance().getTimeInMillis()));
        UUID histLocationId = insert.executeWithKey(qhl.id);
        LOGGER.debug("Created historicalLocation {}", histLocationId);

        QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
        for (UUID locId : locationIds) {
            qFactory.insert(qlhl)
                    .set(qlhl.histLocationId, histLocationId)
                    .set(qlhl.locationId, locId)
                    .execute();
            LOGGER.info("Linked location {} to historicalLocation {}.", locId, histLocationId);
        }
    }

    // Create new datastreams, if any.
    for (Datastream ds : t.getDatastreams()) {
        ds.setThing(new ThingBuilder().setId(t.getId()).build());
        ds.complete();
        pm.insert(ds);
    }

    // TODO: if we allow the creation of historicalLocations through Things
    // then we have to be able to link those to Locations we might have just created.
    // However, id juggling will be needed!
    return true;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:59,代码来源:EntityInserter.java

示例8: insertThing

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
public boolean insertThing(Thing t) throws NoSuchEntityException, IncompleteEntityException {
    SQLQueryFactory qFactory = pm.createQueryFactory();
    QThings qt = QThings.things;
    SQLInsertClause insert = qFactory.insert(qt);
    insert.set(qt.name, t.getName());
    insert.set(qt.description, t.getDescription());
    insert.set(qt.properties, objectToJson(t.getProperties()));

    Long thingId = insert.executeWithKey(qt.id);
    LOGGER.info("Inserted Thing. Created id = {}.", thingId);
    t.setId(new LongId(thingId));

    // Create new Locations, if any.
    List<Long> locationIds = new ArrayList<>();
    for (Location l : t.getLocations()) {
        entityExistsOrCreate(l);
        Long lId = (Long) l.getId().getValue();

        QThingsLocations qtl = QThingsLocations.thingsLocations;
        insert = qFactory.insert(qtl);
        insert.set(qtl.thingId, thingId);
        insert.set(qtl.locationId, lId);
        insert.execute();
        LOGGER.debug("Linked Location {} to Thing {}.", lId, thingId);
        locationIds.add(lId);
    }

    // Now link the new locations also to a historicalLocation.
    if (!locationIds.isEmpty()) {
        QHistLocations qhl = QHistLocations.histLocations;
        insert = qFactory.insert(qhl);
        insert.set(qhl.thingId, thingId);
        insert.set(qhl.time, new Timestamp(Calendar.getInstance().getTimeInMillis()));
        Long histLocationId = insert.executeWithKey(qhl.id);
        LOGGER.debug("Created historicalLocation {}", histLocationId);

        QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
        for (Long locId : locationIds) {
            qFactory.insert(qlhl)
                    .set(qlhl.histLocationId, histLocationId)
                    .set(qlhl.locationId, locId)
                    .execute();
            LOGGER.info("Linked location {} to historicalLocation {}.", locId, histLocationId);
        }
    }

    // Create new datastreams, if any.
    for (Datastream ds : t.getDatastreams()) {
        ds.setThing(new ThingBuilder().setId(t.getId()).build());
        ds.complete();
        pm.insert(ds);
    }

    // TODO: if we allow the creation of historicalLocations through Things
    // then we have to be able to link those to Locations we might have just created.
    // However, id juggling will be needed!
    return true;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:59,代码来源:EntityInserter.java

示例9: insertThing

import de.fraunhofer.iosb.ilt.sta.model.Thing; //导入方法依赖的package包/类
public boolean insertThing(Thing t) throws NoSuchEntityException, IncompleteEntityException {
    SQLQueryFactory qFactory = pm.createQueryFactory();
    QThings qt = QThings.things;
    SQLInsertClause insert = qFactory.insert(qt);
    insert.set(qt.name, t.getName());
    insert.set(qt.description, t.getDescription());
    insert.set(qt.properties, objectToJson(t.getProperties()));

    String thingId = insert.executeWithKey(qt.id);
    LOGGER.info("Inserted Thing. Created id = {}.", thingId);
    t.setId(new StringId(thingId));

    // Create new Locations, if any.
    List<String> locationIds = new ArrayList<>();
    for (Location l : t.getLocations()) {
        entityExistsOrCreate(l);
        String lId = (String) l.getId().getValue();

        QThingsLocations qtl = QThingsLocations.thingsLocations;
        insert = qFactory.insert(qtl);
        insert.set(qtl.thingId, thingId);
        insert.set(qtl.locationId, lId);
        insert.execute();
        LOGGER.debug("Linked Location {} to Thing {}.", lId, thingId);
        locationIds.add(lId);
    }

    // Now link the new locations also to a historicalLocation.
    if (!locationIds.isEmpty()) {
        QHistLocations qhl = QHistLocations.histLocations;
        insert = qFactory.insert(qhl);
        insert.set(qhl.thingId, thingId);
        insert.set(qhl.time, new Timestamp(Calendar.getInstance().getTimeInMillis()));
        String histLocationId = insert.executeWithKey(qhl.id);
        LOGGER.debug("Created historicalLocation {}", histLocationId);

        QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
        for (String locId : locationIds) {
            qFactory.insert(qlhl)
                    .set(qlhl.histLocationId, histLocationId)
                    .set(qlhl.locationId, locId)
                    .execute();
            LOGGER.info("Linked location {} to historicalLocation {}.", locId, histLocationId);
        }
    }

    // Create new datastreams, if any.
    for (Datastream ds : t.getDatastreams()) {
        ds.setThing(new ThingBuilder().setId(t.getId()).build());
        ds.complete();
        pm.insert(ds);
    }

    // TODO: if we allow the creation of historicalLocations through Things
    // then we have to be able to link those to Locations we might have just created.
    // However, id juggling will be needed!
    return true;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:59,代码来源:EntityInserter.java


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