List of usage examples for com.mongodb BasicDBObject append
@Override public BasicDBObject append(final String key, final Object val)
From source file:com.sitewhere.mongodb.asset.MongoAssetCategory.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //from w w w . j a v a 2s.c o m * @param source * @param target */ public static void toDBObject(IAssetCategory source, BasicDBObject target) { target.append(PROP_ID, source.getId()); target.append(PROP_NAME, source.getName()); target.append(PROP_ASSET_TYPE, source.getAssetType().name()); }
From source file:com.sitewhere.mongodb.asset.MongoHardwareAsset.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //from w ww . ja v a 2s. c om * @param source * @param target */ public static void toDBObject(IHardwareAsset source, BasicDBObject target) { MongoAsset.toDBObject(source, target); target.append(PROP_SKU, source.getSku()); target.append(PROP_DESCRIPTION, source.getDescription()); }
From source file:com.sitewhere.mongodb.asset.MongoLocationAsset.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * // ww w.ja v a2s . com * @param source * @param target */ public static void toDBObject(ILocationAsset source, BasicDBObject target) { MongoAsset.toDBObject(source, target); target.append(PROP_LATITUDE, source.getLatitude()); target.append(PROP_LONGITUDE, source.getLongitude()); target.append(PROP_ELEVATION, source.getElevation()); }
From source file:com.sitewhere.mongodb.asset.MongoPersonAsset.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //w w w . java2 s. c o m * @param source * @param target */ public static void toDBObject(IPersonAsset source, BasicDBObject target) { MongoAsset.toDBObject(source, target); target.append(PROP_USER_NAME, source.getUserName()); target.append(PROP_EMAIL, source.getEmailAddress()); target.append(PROP_ROLES, source.getRoles()); }
From source file:com.sitewhere.mongodb.common.MongoSiteWhereEntity.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * /* w w w . j av a 2 s. co m*/ * @param source * @param target */ public static void toDBObject(ISiteWhereEntity source, BasicDBObject target) { target.append(PROP_CREATED_DATE, source.getCreatedDate()); target.append(PROP_CREATED_BY, source.getCreatedBy()); target.append(PROP_UPDATED_DATE, source.getUpdatedDate()); target.append(PROP_UPDATED_BY, source.getUpdatedBy()); target.append(PROP_DELETED, source.isDeleted()); }
From source file:com.sitewhere.mongodb.device.MongoBatchElement.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //from ww w .j a va2 s. c om * @param source * @param target */ public static void toDBObject(IBatchElement source, BasicDBObject target) { target.append(PROP_BATCH_OPERATION_TOKEN, source.getBatchOperationToken()); target.append(PROP_HARDWARE_ID, source.getHardwareId()); target.append(PROP_INDEX, source.getIndex()); if (source.getProcessingStatus() != null) { target.append(PROP_PROCESSING_STATUS, source.getProcessingStatus().name()); } if (source.getProcessedDate() != null) { target.append(PROP_PROCESSED_DATE, source.getProcessedDate()); } MongoMetadataProvider.toDBObject(source, target); }
From source file:com.sitewhere.mongodb.device.MongoBatchOperation.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * /*w w w . j a v a2 s. c o m*/ * @param source * @param target */ public static void toDBObject(IBatchOperation source, BasicDBObject target) { target.append(PROP_TOKEN, source.getToken()); if (source.getOperationType() != null) { target.append(PROP_OPERATION_TYPE, source.getOperationType().name()); } if (source.getProcessingStatus() != null) { target.append(PROP_PROC_STATUS, source.getProcessingStatus().name()); } if (source.getProcessingStartedDate() != null) { target.append(PROP_PROC_START_DATE, source.getProcessingStartedDate()); } if (source.getProcessingEndedDate() != null) { target.append(PROP_PROC_END_DATE, source.getProcessingEndedDate()); } // Set parameters as nested object. BasicDBObject params = new BasicDBObject(); for (String key : source.getParameters().keySet()) { params.put(key, source.getParameters().get(key)); } target.put(PROP_PARAMETERS, params); MongoSiteWhereEntity.toDBObject(source, target); MongoMetadataProvider.toDBObject(source, target); }
From source file:com.sitewhere.mongodb.device.MongoDevice.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * /*from w ww. ja v a 2 s . c o m*/ * @param source * @param target */ public static void toDBObject(IDevice source, BasicDBObject target) { target.append(PROP_HARDWARE_ID, source.getHardwareId()); target.append(PROP_SPECIFICATION_TOKEN, source.getSpecificationToken()); target.append(PROP_PARENT_HARDWARE_ID, source.getParentHardwareId()); target.append(PROP_COMMENTS, source.getComments()); target.append(PROP_ASSIGNMENT_TOKEN, source.getAssignmentToken()); // Save nested list of mappings. List<BasicDBObject> mappings = new ArrayList<BasicDBObject>(); for (IDeviceElementMapping mapping : source.getDeviceElementMappings()) { mappings.add(MongoDeviceElementMapping.toDBObject(mapping)); } target.append(PROP_DEVICE_ELEMENT_MAPPINGS, mappings); MongoSiteWhereEntity.toDBObject(source, target); MongoMetadataProvider.toDBObject(source, target); }
From source file:com.sitewhere.mongodb.device.MongoDeviceAlert.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //from w ww .j a v a 2s . c om * @param source * @param target * @param isNested */ public static void toDBObject(IDeviceAlert source, BasicDBObject target, boolean isNested) { MongoDeviceEvent.toDBObject(source, target, isNested); target.append(PROP_SOURCE, source.getSource().name()); target.append(PROP_LEVEL, source.getLevel().name()); target.append(PROP_TYPE, source.getType()); target.append(PROP_MESSAGE, source.getMessage()); }
From source file:com.sitewhere.mongodb.device.MongoDeviceAssignment.java
License:Open Source License
/** * Copy information from SPI into Mongo DBObject. * //w w w. j a v a 2s. com * @param source * @param target */ public static void toDBObject(IDeviceAssignment source, BasicDBObject target) { if (source.getActiveDate() != null) { target.append(PROP_ACTIVE_DATE, source.getActiveDate()); } target.append(PROP_ASSET_MODULE_ID, source.getAssetModuleId()); target.append(PROP_ASSET_ID, source.getAssetId()); if (source.getAssignmentType() != null) { target.append(PROP_ASSIGNMENT_TYPE, source.getAssignmentType().name()); } if (source.getReleasedDate() != null) { target.append(PROP_RELEASED_DATE, source.getReleasedDate()); } if (source.getStatus() != null) { target.append(PROP_STATUS, source.getStatus().name()); } target.append(PROP_TOKEN, source.getToken()); target.append(PROP_DEVICE_HARDWARE_ID, source.getDeviceHardwareId()); target.append(PROP_SITE_TOKEN, source.getSiteToken()); if (source.getState() != null) { setState(source.getState(), target); } MongoSiteWhereEntity.toDBObject(source, target); MongoMetadataProvider.toDBObject(source, target); }