@Override public IDevice createDeviceElementMapping(String hardwareId, IDeviceElementMapping mapping) throws SiteWhereException { return delegate.createDeviceElementMapping(hardwareId, mapping); }
@Override public IDevice createDeviceElementMapping(UUID id, IDeviceElementMapping mapping) throws SiteWhereException { return getDelegate().createDeviceElementMapping(id, mapping); }
/** * Create a new device element mapping. * * @param request * @return */ @RequestMapping(value = "/{hardwareId}/mappings", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "Create new device element mapping") @Secured({ SiteWhereRoles.REST }) @Documented(examples = { @Example(stage = Stage.Request, json = Devices.AddMappingRequest.class, description = "addDeviceElementMappingRequest.md"), @Example(stage = Stage.Response, json = Devices.AddMappingResponse.class, description = "addDeviceElementMappingResponse.md") }) public IDevice addDeviceElementMapping( @ApiParam(value = "Hardware id", required = true) @PathVariable String hardwareId, @RequestBody DeviceElementMapping request, HttpServletRequest servletRequest) throws SiteWhereException { Tracer.start(TracerCategory.RestApiCall, "addDeviceElementMapping", LOGGER); try { IDevice updated = SiteWhere.getServer().getDeviceManagement(getTenant(servletRequest)) .createDeviceElementMapping(hardwareId, request); DeviceMarshalHelper helper = new DeviceMarshalHelper(getTenant(servletRequest)); helper.setIncludeAsset(false); helper.setIncludeAssignment(false); return helper.convert(updated, SiteWhere.getServer().getAssetModuleManager(getTenant(servletRequest))); } finally { Tracer.stop(LOGGER); } }
@Override public void createDeviceElementMapping(GCreateDeviceElementMappingRequest request, StreamObserver<GCreateDeviceElementMappingResponse> responseObserver) { try { GrpcUtils.handleServerMethodEntry(this, DeviceManagementGrpc.getCreateDeviceElementMappingMethod()); IDeviceElementMapping apiRequest = DeviceModelConverter.asApiDeviceElementMapping(request.getMapping()); IDevice apiResult = getDeviceManagement() .createDeviceElementMapping(CommonModelConverter.asApiUuid(request.getId()), apiRequest); GCreateDeviceElementMappingResponse.Builder response = GCreateDeviceElementMappingResponse.newBuilder(); response.setDevice(DeviceModelConverter.asGrpcDevice(apiResult)); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } catch (Throwable e) { GrpcUtils.handleServerMethodException(DeviceManagementGrpc.getCreateDeviceElementMappingMethod(), e, responseObserver); } finally { GrpcUtils.handleServerMethodExit(DeviceManagementGrpc.getCreateDeviceElementMappingMethod()); } }
@Override public void handleDeviceMapping(String hardwareId, IDeviceMappingCreateRequest request) throws SiteWhereException { DeviceElementMapping mapping = new DeviceElementMapping(); mapping.setHardwareId(hardwareId); mapping.setDeviceElementSchemaPath(request.getMappingPath()); DeviceMappingAckCommand command = new DeviceMappingAckCommand(); try { SiteWhere.getServer().getDeviceManagement(getTenant()) .createDeviceElementMapping(request.getCompositeDeviceHardwareId(), mapping); command.setResult(DeviceMappingResult.MappingCreated); } catch (SiteWhereException e) { command.setResult(DeviceMappingResult.MappingFailedDueToExisting); } SiteWhere.getServer().getDeviceCommunication(getTenant()).deliverSystemCommand(hardwareId, command); }