public Builder(String deviceTypeToken, String token) { request.setDeviceTypeToken(deviceTypeToken); request.setToken(token); request.setStatus(null); request.setComments(""); }
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(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()); } }
/** * 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; }
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());