@Override public IDeviceLocation addDeviceLocation(String assignmentToken, IDeviceLocationCreateRequest request) throws SiteWhereException { return delegate.addDeviceLocation(assignmentToken, request); }
public AssignmentScope persist(DeviceLocationCreateRequest.Builder builder) throws SiteWhereException { DeviceLocationCreateRequest request = builder.build(); events.addDeviceLocation(getAssignmentToken(), request); return this; }
@Override public void createLocation(String assignmentToken, double latitude, double longitude, double elevation, boolean updateState) throws SiteWhereException { DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setLatitude(latitude); location.setLongitude(longitude); location.setElevation(elevation); location.setEventDate(new Date()); location.setUpdateState(updateState); getDeviceEventManagement().addDeviceLocation(assignmentToken, location); }
@Override public void onDeviceLocationCreateRequest(String hardwareId, String originator, IDeviceLocationCreateRequest request) throws SiteWhereException { IDeviceAssignment assignment = getCurrentAssignment(hardwareId); IDeviceLocation location = getDeviceEventManagement().addDeviceLocation(assignment.getToken(), request); handleLinkResponseToInvocation(originator, location.getId(), assignment); }
/** * Executes logic to process a batch of device events. * * @param assignmentToken * @param batch * @param management * @return * @throws SiteWhereException */ public static DeviceEventBatchResponse deviceEventBatchLogic(String assignmentToken, IDeviceEventBatch batch, IDeviceEventManagement management) throws SiteWhereException { DeviceEventBatchResponse response = new DeviceEventBatchResponse(); for (IDeviceMeasurementsCreateRequest measurements : batch.getMeasurements()) { response.getCreatedMeasurements().add(management.addDeviceMeasurements(assignmentToken, measurements)); } for (IDeviceLocationCreateRequest location : batch.getLocations()) { response.getCreatedLocations().add(management.addDeviceLocation(assignmentToken, location)); } for (IDeviceAlertCreateRequest alert : batch.getAlerts()) { response.getCreatedAlerts().add(management.addDeviceAlert(assignmentToken, alert)); } return response; }
/** * Create location to be associated with a device assignment. * * @param input * @param token * @param updateState * @return * @throws SiteWhereException */ @RequestMapping(value = "/{token}/locations", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "Create location event for device assignment") @Secured({ SiteWhereRoles.REST }) @Documented(examples = { @Example(stage = Stage.Request, json = Assignments.CreateAssignmentLocationRequest.class, description = "createLocationRequest.md"), @Example(stage = Stage.Response, json = Assignments.CreateAssignmentLocationResponse.class, description = "createLocationResponse.md") }) public DeviceLocation createLocation(@RequestBody DeviceLocationCreateRequest input, @ApiParam(value = "Assignment token", required = true) @PathVariable String token, HttpServletRequest servletRequest) throws SiteWhereException { Tracer.start(TracerCategory.RestApiCall, "createLocation", LOGGER); try { IDeviceLocation result = SiteWhere.getServer().getDeviceEventManagement(getTenant(servletRequest)) .addDeviceLocation(token, input); return DeviceLocation.copy(result); } finally { Tracer.stop(LOGGER); } }