/** * 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; } }
/** * 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()); }
public static DeviceElementMapping copy(IDeviceElementMapping input) { DeviceElementMapping result = new DeviceElementMapping(); result.setDeviceElementSchemaPath(input.getDeviceElementSchemaPath()); result.setHardwareId(input.getHardwareId()); return result; } }
IDevice mapped = management.getDeviceByHardwareId(match.getHardwareId()); if (mapped != null) { DeviceCreateRequest nested = new DeviceCreateRequest();
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.");
.newBuilder(); ebuilder.setDeviceElementSchemaPath(mapping.getDeviceElementSchemaPath()); ebuilder.setHardwareId(mapping.getHardwareId()); builder.addDeviceElementMappings(ebuilder.build());
DeviceElementMapping cnvMapping = DeviceElementMapping.copy(mapping); if (isIncludeNested()) { IDevice device = getDeviceManagement(tenant).getDeviceByHardwareId(mapping.getHardwareId()); cnvMapping.setDevice(getNestedHelper().convert(device, manager));