public Object generate() throws SiteWhereException { DeviceCommandInvocationCreateRequest request = new DeviceCommandInvocationCreateRequest(); request.setInitiator(ExampleData.INVOCATION_SET_RPT_INTV.getInitiator()); request.setInitiatorId(ExampleData.INVOCATION_SET_RPT_INTV.getInitiatorId()); request.setTarget(ExampleData.INVOCATION_SET_RPT_INTV.getTarget()); request.setCommandToken(ExampleData.INVOCATION_SET_RPT_INTV.getCommandToken()); request.getParameterValues().putAll(ExampleData.INVOCATION_SET_RPT_INTV.getParameterValues()); request.setEventDate(ExampleData.INVOCATION_SET_RPT_INTV.getEventDate()); return request; } }
request.setCommandToken(command.getToken()); request.setInitiator(CommandInitiator.BatchOperation); request.setInitiatorId(operation.getId().toString()); request.setTarget(CommandTarget.Assignment); request.setTargetId(assignment.getToken());
request.setCommandToken(commandToken); request.setInitiator(CommandInitiator.BatchOperation); request.setInitiatorId(systemUser.getName()); request.setTarget(CommandTarget.Assignment); request.setTargetId(assignment.getToken());
@Override public void execute(JobExecutionContext context) throws JobExecutionException { parse(context); if (getAssignmentToken() == null) { throw new JobExecutionException("Assignment token not provided."); } if (getCommandToken() == null) { throw new JobExecutionException("Command token not provided."); } try { ITenant tenant = getTenantManagement().getTenantByToken(context.getScheduler().getSchedulerName()); IDeviceEventManagement events = getDeviceEventManagement(tenant); DeviceCommandInvocationCreateRequest create = new DeviceCommandInvocationCreateRequest(); create.setCommandToken(getCommandToken()); create.setParameterValues(getParameters()); create.setInitiator(CommandInitiator.Scheduler); create.setInitiatorId(context.getJobDetail().getKey().getName()); create.setTarget(CommandTarget.Assignment); create.setTargetId(getAssignmentToken()); create.setEventDate(new Date()); events.addDeviceCommandInvocations(null, create); LOGGER.info("Executed command invocation job."); } catch (SiteWhereException e) { throw new JobExecutionException("Unable to create command invocation.", e); } catch (SchedulerException e) { throw new JobExecutionException("Unable to get scheduler name.", e); } }
create.setParameterValues(getParameters()); create.setInitiator(CommandInitiator.Scheduler); create.setInitiatorId(context.getJobDetail().getKey().getName()); create.setTarget(CommandTarget.Assignment); create.setTargetId(getAssignmentToken());
/** * Convert device command invocation create request from GRPC to API. * * @param grpc * @return * @throws SiteWhereException */ public static DeviceCommandInvocationCreateRequest asApiDeviceCommandInvocationCreateRequest( GDeviceCommandInvocationCreateRequest grpc) throws SiteWhereException { DeviceCommandInvocationCreateRequest api = new DeviceCommandInvocationCreateRequest(); api.setInitiator(EventModelConverter.asApiCommandInitiator(grpc.getInitiator())); api.setInitiatorId(grpc.getInitiatorId()); api.setTarget(EventModelConverter.asApiCommandTarget(grpc.getTarget())); if (grpc.hasTargetId()) { api.setTargetId(grpc.getTargetId().getValue()); } api.setCommandToken(grpc.getCommandToken()); api.setParameterValues(grpc.getParameterValuesMap()); EventModelConverter.copyApiDeviceEventCreateRequest(grpc.getEvent(), api); return api; }