示例#1
0
  /**
   * Copy information from SPI into Mongo DBObject.
   *
   * @param source
   * @param target
   * @param isNested
   */
  public static void toDBObject(IDeviceStreamData source, BasicDBObject target, boolean isNested) {
    MongoDeviceEvent.toDBObject(source, target, isNested);

    target.append(PROP_STREAM_ID, source.getStreamId());
    target.append(PROP_SEQUENCE_NUMBER, source.getSequenceNumber());
    target.append(PROP_DATA, source.getData());
  }
示例#2
0
  /**
   * Copy information from Mongo DBObject to model object.
   *
   * @param source
   * @param target
   * @param isNested
   */
  public static void fromDBObject(DBObject source, DeviceStreamData target, boolean isNested) {
    MongoDeviceEvent.fromDBObject(source, target, isNested);

    String streamId = (String) source.get(PROP_STREAM_ID);
    Long sequenceNumber = (Long) source.get(PROP_SEQUENCE_NUMBER);
    byte[] data = (byte[]) source.get(PROP_DATA);

    target.setStreamId(streamId);
    target.setSequenceNumber(sequenceNumber);
    target.setData(data);
  }