/** * Find {@link IDeviceElementMapping} for the given nested device token. * * @param device * @param nestedDeviceToken * @return */ public static IDeviceElementMapping findMappingFor(IDevice device, String nestedDeviceToken) { if (device.getDeviceElementMappings() != null) { for (IDeviceElementMapping mapping : device.getDeviceElementMappings()) { if (mapping.getDeviceToken().equals(nestedDeviceToken)) { return mapping; } } } return null; } }
/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target */ public static void toDocument(IDeviceElementMapping source, Document target) { target.append(PROP_DEVICE_ELEMENT_SCHEMA_PATH, source.getDeviceElementSchemaPath()); target.append(PROP_DEVICE_TOKEN, source.getDeviceToken()); }
public static DeviceElementMapping copy(IDeviceElementMapping input) { DeviceElementMapping result = new DeviceElementMapping(); result.setDeviceElementSchemaPath(input.getDeviceElementSchemaPath()); result.setDeviceToken(input.getDeviceToken()); return result; } }
/** * Convert device element mapping from API to GRPC. * * @param api * @return * @throws SiteWhereException */ public static GDeviceElementMapping asGrpcDeviceElementMapping(IDeviceElementMapping api) throws SiteWhereException { GDeviceElementMapping.Builder grpc = GDeviceElementMapping.newBuilder(); grpc.setDeviceToken(api.getDeviceToken()); grpc.setSchemaPath(api.getDeviceElementSchemaPath()); return grpc.build(); }
IDevice mapped = management.getDeviceByToken(match.getDeviceToken()); if (mapped != null) { DeviceCreateRequest nested = new DeviceCreateRequest();
throw new SiteWhereSystemException(ErrorCode.InvalidDeviceId, ErrorLevel.ERROR); IDevice mapped = management.getDeviceByToken(request.getDeviceToken()); if (mapped == null) { throw new SiteWhereException("Device referenced by mapping does not exist.");
DeviceElementMapping cnvMapping = DeviceElementMapping.copy(mapping); if (isIncludeNested()) { IDevice device = getDeviceManagement().getDeviceByToken(mapping.getDeviceToken()); cnvMapping.setDevice(getNestedHelper().convert(device, assetManagement));