/** * If an originator was assocaited with the event, create a * {@link IDeviceCommandResponse} that links back to the original * invocation. * * @param originator * @param eventId * @param assignment * @throws SiteWhereException */ protected void handleLinkResponseToInvocation(String originator, String eventId, IDeviceAssignment assignment) throws SiteWhereException { if ((originator != null) && (!originator.isEmpty())) { DeviceCommandResponseCreateRequest response = new DeviceCommandResponseCreateRequest(); response.setOriginatingEventId(originator); response.setResponseEventId(eventId); getDeviceEventManagement().addDeviceCommandResponse(assignment.getToken(), response); } }
public Object generate() throws SiteWhereException { DeviceCommandResponseCreateRequest request = new DeviceCommandResponseCreateRequest(); request.setOriginatingEventId(ExampleData.RESPONSE_SET_RPT_INTV.getOriginatingEventId()); request.setResponseEventId(ExampleData.RESPONSE_SET_RPT_INTV.getResponseEventId()); request.setEventDate(ExampleData.RESPONSE_SET_RPT_INTV.getEventDate()); return request; } }
/** * Convert device command response create request from GRPC to API. * * @param grpc * @return * @throws SiteWhereException */ public static DeviceCommandResponseCreateRequest asApiDeviceCommandResponseCreateRequest( GDeviceCommandResponseCreateRequest grpc) throws SiteWhereException { DeviceCommandResponseCreateRequest api = new DeviceCommandResponseCreateRequest(); api.setOriginatingEventId( grpc.hasOriginatingEventId() ? CommonModelConverter.asApiUuid(grpc.getOriginatingEventId()) : null); api.setResponseEventId( grpc.hasResponseEventId() ? CommonModelConverter.asApiUuid(grpc.getResponseEventId()) : null); api.setResponse(grpc.hasResponse() ? grpc.getResponse().getValue() : null); EventModelConverter.copyApiDeviceEventCreateRequest(grpc.getEvent(), api); return api; }