public Object generate() throws SiteWhereException { DeviceCreateRequest request = new DeviceCreateRequest(); request.setSiteToken(ExampleData.SITE_CONSTRUCTION.getToken()); request.setSpecificationToken(ExampleData.SPEC_MEITRACK.getToken()); request.setHardwareId(ExampleData.TRACKER.getHardwareId()); request.setComments(ExampleData.TRACKER.getComments()); return request; } }
public Builder metadata(String name, String value) { if (request.getMetadata() == null) { request.setMetadata(new HashMap<String, String>()); } request.getMetadata().put(name, value); return this; }
public Builder(String siteToken, String specificationToken, String hardwareId) { request.setSiteToken(siteToken); request.setSpecificationToken(specificationToken); request.setHardwareId(hardwareId); request.setStatus(DeviceStatus.Ok); request.setComments(""); }
public Builder(String deviceTypeToken, String token) { request.setDeviceTypeToken(deviceTypeToken); request.setToken(token); request.setStatus(null); request.setComments(""); }
/** * Convert device create request from GRPC to API. * * @param grpc * @return * @throws SiteWhereException */ public static DeviceCreateRequest asApiDeviceCreateRequest(GDeviceCreateRequest grpc) throws SiteWhereException { DeviceCreateRequest api = new DeviceCreateRequest(); api.setToken(grpc.hasToken() ? grpc.getToken().getValue() : null); api.setParentDeviceToken(grpc.hasParentDeviceToken() ? grpc.getParentDeviceToken().getValue() : null); api.setDeviceTypeToken(grpc.hasDeviceTypeToken() ? grpc.getDeviceTypeToken().getValue() : null); api.setStatus(grpc.hasStatus() ? grpc.getStatus().getValue() : null); api.setComments(grpc.hasComments() ? grpc.getComments().getValue() : null); api.setDeviceElementMappings( DeviceModelConverter.asApiDeviceElementMappings(grpc.getDeviceElementMappingsList())); api.setMetadata(grpc.getMetadataMap()); return api; }
public Builder(IDevice api) { request.setSiteToken(api.getSiteToken()); request.setSpecificationToken(api.getSpecificationToken()); request.setHardwareId(api.getHardwareId()); request.setStatus(api.getStatus()); request.setComments(api.getComments()); request.setParentHardwareId(api.getParentHardwareId()); if (api.getDeviceElementMappings() != null) { request.setDeviceElementMappings(new ArrayList<DeviceElementMapping>()); request.getDeviceElementMappings().addAll(api.getDeviceElementMappings()); } if (api.getMetadata() != null) { request.setMetadata(new HashMap<String, String>()); request.getMetadata().putAll(api.getMetadata()); } }
DeviceCreateRequest nested = new DeviceCreateRequest(); nested.setRemoveParentHardwareId(true); management.updateDevice(mapped.getId(), nested); DeviceCreateRequest update = new DeviceCreateRequest(); update.setDeviceElementMappings(newMappings); IDevice updated = management.updateDevice(device.getId(), update); return updated;
public Object generate() throws SiteWhereException { DeviceCreateRequest request = new DeviceCreateRequest(); request.setComments(ExampleData.TRACKER.getComments() + " Updated."); return request; } }
DeviceCreateRequest nested = new DeviceCreateRequest(); nested.setParentDeviceToken(device.getToken()); management.updateDevice(mapped.getId(), nested); DeviceCreateRequest update = new DeviceCreateRequest(); update.setDeviceElementMappings(newMappings); IDevice updated = management.updateDevice(device.getId(), update); return updated;
DeviceCreateRequest nested = new DeviceCreateRequest(); nested.setParentHardwareId(hardwareId); management.updateDevice(mapped.getHardwareId(), nested); DeviceCreateRequest update = new DeviceCreateRequest(); update.setDeviceElementMappings(newMappings); IDevice updated = management.updateDevice(hardwareId, update); return updated;
public Builder withComment(String comments) { request.setComments(comments); return this; }
DeviceCreateRequest deviceCreate = new DeviceCreateRequest(); deviceCreate.setToken(request.getToken() != null ? request.getToken() : registration.getDeviceToken()); deviceCreate.setDeviceTypeToken(request.getDeviceTypeToken()); deviceCreate.setStatus(request.getStatus()); deviceCreate.setDeviceElementMappings(request.getDeviceElementMappings()); deviceCreate.setParentDeviceToken(request.getParentDeviceToken()); deviceCreate.setComments(request.getComments() != null ? request.getComments() : "Device created by on-demand registration."); deviceCreate.setMetadata(request.getMetadata()); return getDeviceManagement().createDevice(deviceCreate); } else {
DeviceCreateRequest nested = new DeviceCreateRequest(); nested.setRemoveParentHardwareId(true); management.updateDevice(mapped.getHardwareId(), nested); DeviceCreateRequest update = new DeviceCreateRequest(); update.setDeviceElementMappings(newMappings); IDevice updated = management.updateDevice(hardwareId, update); return updated;
public Builder withComment(String comments) { request.setComments(comments); return this; }
DeviceCreateRequest deviceCreate = new DeviceCreateRequest(); deviceCreate.setHardwareId(request.getHardwareId()); deviceCreate.setSpecificationToken(request.getSpecificationToken()); deviceCreate.setSiteToken(siteToken); deviceCreate.setComments("Device created by on-demand registration."); deviceCreate.setMetadata(request.getMetadata()); device = SiteWhere.getServer().getDeviceManagement(getTenant()).createDevice(deviceCreate); } else if (!device.getSpecificationToken().equals(request.getSpecificationToken())) { } else { LOGGER.info("Found existing device registration. Updating metadata."); DeviceCreateRequest deviceUpdate = new DeviceCreateRequest(); deviceUpdate.setMetadata(request.getMetadata()); device = SiteWhere.getServer().getDeviceManagement(getTenant()).updateDevice(request.getHardwareId(), deviceUpdate);
public Builder metadata(String name, String value) { if (request.getMetadata() == null) { request.setMetadata(new HashMap<String, String>()); } request.getMetadata().put(name, value); return this; }