/** * 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_HARDWARE_ID, source.getHardwareId()); }
/** * 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()); }
nested.setPath(mapping.getDeviceElementSchemaPath()); return nested;
/** * 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; } }
/** * Find {@link IDeviceElementMapping} for the given nested device hardware * id. * * @param device * @param nestedHardwareId * @return */ public static IDeviceElementMapping findMappingFor(IDevice device, String nestedHardwareId) { if (device.getDeviceElementMappings() != null) { for (IDeviceElementMapping mapping : device.getDeviceElementMappings()) { if (mapping.getHardwareId().equals(nestedHardwareId)) { return mapping; } } } return null; } }
nested.setPath(mapping.getDeviceElementSchemaPath()); return nested;
DeviceElementMapping cnvMapping = DeviceElementMapping.copy(mapping); if (isIncludeNested()) { IDevice device = getDeviceManagement().getDeviceByToken(mapping.getDeviceToken()); cnvMapping.setDevice(getNestedHelper().convert(device, assetManagement));
DeviceElementMapping cnvMapping = DeviceElementMapping.copy(mapping); if (isIncludeNested()) { IDevice device = getDeviceManagement(tenant).getDeviceByHardwareId(mapping.getHardwareId()); cnvMapping.setDevice(getNestedHelper().convert(device, manager));
public static DeviceElementMapping copy(IDeviceElementMapping input) { DeviceElementMapping result = new DeviceElementMapping(); result.setDeviceElementSchemaPath(input.getDeviceElementSchemaPath()); result.setHardwareId(input.getHardwareId()); return result; } }
public static DeviceElementMapping copy(IDeviceElementMapping input) { DeviceElementMapping result = new DeviceElementMapping(); result.setDeviceElementSchemaPath(input.getDeviceElementSchemaPath()); result.setDeviceToken(input.getDeviceToken()); return result; } }
throw new SiteWhereSystemException(ErrorCode.InvalidHardwareId, ErrorLevel.ERROR); IDevice mapped = management.getDeviceByHardwareId(request.getHardwareId()); if (mapped == null) { throw new SiteWhereException("Device referenced by mapping does not exist."); DeviceSpecificationUtils.getDeviceSlotByPath(specification, request.getDeviceElementSchemaPath()); List<DeviceElementMapping> newMappings = new ArrayList<DeviceElementMapping>(); for (IDeviceElementMapping mapping : existing) { if (mapping.getDeviceElementSchemaPath().equals(request.getDeviceElementSchemaPath())) { throw new SiteWhereSystemException(ErrorCode.DeviceElementMappingExists, ErrorLevel.ERROR);
/** * 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(); }
IDeviceElementMapping match = null; for (IDeviceElementMapping mapping : existing) { if (mapping.getDeviceElementSchemaPath().equals(path)) { match = mapping; } else { IDevice mapped = management.getDeviceByHardwareId(match.getHardwareId()); 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."); DeviceTypeUtils.getDeviceSlotByPath(deviceType, request.getDeviceElementSchemaPath()); List<DeviceElementMapping> newMappings = new ArrayList<DeviceElementMapping>(); for (IDeviceElementMapping mapping : existing) { if (mapping.getDeviceElementSchemaPath().equals(request.getDeviceElementSchemaPath())) { throw new SiteWhereSystemException(ErrorCode.DeviceElementMappingExists, ErrorLevel.ERROR);
ProtobufMarshaler.DeviceElementMapping.Builder ebuilder = ProtobufMarshaler.DeviceElementMapping .newBuilder(); ebuilder.setDeviceElementSchemaPath(mapping.getDeviceElementSchemaPath()); ebuilder.setHardwareId(mapping.getHardwareId()); builder.addDeviceElementMappings(ebuilder.build());
IDeviceElementMapping match = null; for (IDeviceElementMapping mapping : existing) { if (mapping.getDeviceElementSchemaPath().equals(path)) { match = mapping; } else { IDevice mapped = management.getDeviceByToken(match.getDeviceToken()); if (mapped != null) { DeviceCreateRequest nested = new DeviceCreateRequest();