/** * Create an instance of {@link JobSignalRequest } * */ public JobSignalRequest createJobSignalRequest() { return new JobSignalRequest(); }
/** * Validates the job signal request. This method also trims request parameters. * * @param request the request * * @throws IllegalArgumentException if any validation errors were found */ private void validateJobSignalRequest(JobSignalRequest request) { // Validate required elements Assert.hasText(request.getId(), "A job id must be specified."); Assert.hasText(request.getReceiveTaskId(), "A receive task id must be specified."); // Validate that parameter names are there and not duplicate parameterHelper.validateParameters(request.getParameters()); if (request.getS3PropertiesLocation() != null) { s3PropertiesLocationHelper.validate(request.getS3PropertiesLocation()); } // Remove leading and trailing spaces. request.setId(request.getId().trim()); request.setReceiveTaskId(request.getReceiveTaskId().trim()); } }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof JobSignalRequest) { final JobSignalRequest copy = ((JobSignalRequest) draftCopy); if (idShouldBeCopiedAndSet == Boolean.TRUE) { String sourceId; sourceId = this.getId(); String copyId = ((String) strategy.copy(LocatorUtils.property(locator, "id", sourceId), sourceId, (this.id!= null))); copy.setId(copyId); } else { if (idShouldBeCopiedAndSet == Boolean.FALSE) { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.TRUE) { String sourceReceiveTaskId; sourceReceiveTaskId = this.getReceiveTaskId(); String copyReceiveTaskId = ((String) strategy.copy(LocatorUtils.property(locator, "receiveTaskId", sourceReceiveTaskId), sourceReceiveTaskId, (this.receiveTaskId!= null))); copy.setReceiveTaskId(copyReceiveTaskId); } else { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.FALSE) { if (parametersShouldBeCopiedAndSet == Boolean.TRUE) { List<Parameter> sourceParameters; sourceParameters = ((this.parameters!= null)?this.getParameters():null); @SuppressWarnings("unchecked") List<Parameter> copyParameters = ((List<Parameter> ) strategy.copy(LocatorUtils.property(locator, "parameters", sourceParameters), sourceParameters, (this.parameters!= null))); copy.parameters = null; if (copyParameters!= null) { copy.setParameters(copyParameters);
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theId; theId = this.getId(); strategy.appendField(locator, this, "id", buffer, theId, (this.id!= null)); } { String theReceiveTaskId; theReceiveTaskId = this.getReceiveTaskId(); strategy.appendField(locator, this, "receiveTaskId", buffer, theReceiveTaskId, (this.receiveTaskId!= null)); } { List<Parameter> theParameters; theParameters = ((this.parameters!= null)?this.getParameters():null); strategy.appendField(locator, this, "parameters", buffer, theParameters, (this.parameters!= null)); } { S3PropertiesLocation theS3PropertiesLocation; theS3PropertiesLocation = this.getS3PropertiesLocation(); strategy.appendField(locator, this, "s3PropertiesLocation", buffer, theS3PropertiesLocation, (this.s3PropertiesLocation!= null)); } return buffer; }
/** * Signals job with both S3 properties and request parameters set. If there are name clashes, the request parameter should take precedence. * * @throws Exception */ @Test public void testSignalJobWithS3PropertiesPrecedenceRequestParamsOverridesS3() throws Exception { jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH); Parameter s3Parameter = new Parameter("testName", "testValue"); Parameter requestParameter = new Parameter("testName", "expectedValue"); S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation("s3BucketName", "s3ObjectKey", s3Parameter); // Start the job. Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME)); JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", null, null); jobSignalRequest.setS3PropertiesLocation(s3PropertiesLocation); jobSignalRequest.setParameters(Arrays.asList(requestParameter)); Job signalJob = jobService.signalJob(jobSignalRequest); assertParameterEquals(requestParameter, signalJob.getParameters()); }
/** * Signals job with S3 properties set. Parameters should be populated from the properties. * * @throws Exception */ @Test public void testSignalJobWithS3Properties() throws Exception { jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH); Parameter parameter = new Parameter("testName", "testValue"); S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation("s3BucketName", "s3ObjectKey", parameter); // Start the job. Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME)); JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", null, null); jobSignalRequest.setS3PropertiesLocation(s3PropertiesLocation); Job signalJob = jobService.signalJob(jobSignalRequest); assertParameterEquals(parameter, signalJob.getParameters()); }
/** * Gets the parameters from the given {@link JobSignalRequest} and the S3 location provided. * * @param jobSignalRequest {@link JobSignalRequest} * * @return parameters */ private Map<String, Object> getParameters(JobSignalRequest jobSignalRequest) { Map<String, Object> signalParameters = new HashMap<>(); // Get parameters from S3 S3PropertiesLocation s3PropertiesLocation = jobSignalRequest.getS3PropertiesLocation(); if (s3PropertiesLocation != null) { putParametersFromS3(s3PropertiesLocation.getBucketName(), s3PropertiesLocation.getKey(), signalParameters); } // Get parameters from request signalParameters.putAll(toMap(jobSignalRequest.getParameters())); return signalParameters; }
@Override public Job signalJob(JobSignalRequest request) throws Exception { // Perform the validation. validateJobSignalRequest(request); Execution execution = activitiService.getExecutionByProcessInstanceIdAndActivitiId(request.getId(), request.getReceiveTaskId()); if (execution == null) { throw new ObjectNotFoundException( String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", request.getId(), request.getReceiveTaskId())); } String processDefinitionKey = activitiService.getProcessInstanceById(execution.getProcessInstanceId()).getProcessDefinitionKey(); checkPermissions(processDefinitionKey, new NamespacePermissionEnum[] {NamespacePermissionEnum.EXECUTE}); // Retrieve the job before signaling. Job job = getJob(request.getId(), false, false); // Build the parameters map Map<String, Object> signalParameters = getParameters(request); // Signal the workflow. activitiService.signal(execution.getId(), signalParameters); // Build the parameters map merged with job and signal parameters. Map<String, Object> mergedParameters = new HashMap<>(); for (Parameter jobParam : job.getParameters()) { mergedParameters.put(jobParam.getName(), jobParam.getValue()); } mergedParameters.putAll(signalParameters); // Update the parameters in job populateWorkflowParameters(job, mergedParameters); return job; }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof JobSignalRequest) { final JobSignalRequest copy = ((JobSignalRequest) draftCopy); if (idShouldBeCopiedAndSet == Boolean.TRUE) { String sourceId; sourceId = this.getId(); String copyId = ((String) strategy.copy(LocatorUtils.property(locator, "id", sourceId), sourceId, (this.id!= null))); copy.setId(copyId); } else { if (idShouldBeCopiedAndSet == Boolean.FALSE) { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.TRUE) { String sourceReceiveTaskId; sourceReceiveTaskId = this.getReceiveTaskId(); String copyReceiveTaskId = ((String) strategy.copy(LocatorUtils.property(locator, "receiveTaskId", sourceReceiveTaskId), sourceReceiveTaskId, (this.receiveTaskId!= null))); copy.setReceiveTaskId(copyReceiveTaskId); } else { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.FALSE) { if (parametersShouldBeCopiedAndSet == Boolean.TRUE) { List<Parameter> sourceParameters; sourceParameters = ((this.parameters!= null)?this.getParameters():null); @SuppressWarnings("unchecked") List<Parameter> copyParameters = ((List<Parameter> ) strategy.copy(LocatorUtils.property(locator, "parameters", sourceParameters), sourceParameters, (this.parameters!= null))); copy.parameters = null; if (copyParameters!= null) { copy.setParameters(copyParameters);
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theId; theId = this.getId(); strategy.appendField(locator, this, "id", buffer, theId, (this.id!= null)); } { String theReceiveTaskId; theReceiveTaskId = this.getReceiveTaskId(); strategy.appendField(locator, this, "receiveTaskId", buffer, theReceiveTaskId, (this.receiveTaskId!= null)); } { List<Parameter> theParameters; theParameters = ((this.parameters!= null)?this.getParameters():null); strategy.appendField(locator, this, "parameters", buffer, theParameters, (this.parameters!= null)); } { S3PropertiesLocation theS3PropertiesLocation; theS3PropertiesLocation = this.getS3PropertiesLocation(); strategy.appendField(locator, this, "s3PropertiesLocation", buffer, theS3PropertiesLocation, (this.s3PropertiesLocation!= null)); } return buffer; }
/** * Gets the parameters from the given {@link JobSignalRequest} and the S3 location provided. * * @param jobSignalRequest {@link JobSignalRequest} * * @return parameters */ private Map<String, Object> getParameters(JobSignalRequest jobSignalRequest) { Map<String, Object> signalParameters = new HashMap<>(); // Get parameters from S3 S3PropertiesLocation s3PropertiesLocation = jobSignalRequest.getS3PropertiesLocation(); if (s3PropertiesLocation != null) { putParametersFromS3(s3PropertiesLocation.getBucketName(), s3PropertiesLocation.getKey(), signalParameters); } // Get parameters from request signalParameters.putAll(toMap(jobSignalRequest.getParameters())); return signalParameters; }
@Override public Job signalJob(JobSignalRequest request) throws Exception { // Perform the validation. validateJobSignalRequest(request); Execution execution = activitiService.getExecutionByProcessInstanceIdAndActivitiId(request.getId(), request.getReceiveTaskId()); if (execution == null) { throw new ObjectNotFoundException( String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", request.getId(), request.getReceiveTaskId())); } String processDefinitionKey = activitiService.getProcessInstanceById(execution.getProcessInstanceId()).getProcessDefinitionKey(); checkPermissions(processDefinitionKey, new NamespacePermissionEnum[] {NamespacePermissionEnum.EXECUTE}); // Retrieve the job before signaling. Job job = getJob(request.getId(), false, false); // Build the parameters map Map<String, Object> signalParameters = getParameters(request); // Signal the workflow. activitiService.signal(execution.getId(), signalParameters); // Build the parameters map merged with job and signal parameters. Map<String, Object> mergedParameters = new HashMap<>(); for (Parameter jobParam : job.getParameters()) { mergedParameters.put(jobParam.getName(), jobParam.getValue()); } mergedParameters.putAll(signalParameters); // Update the parameters in job populateWorkflowParameters(job, mergedParameters); return job; }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof JobSignalRequest) { final JobSignalRequest copy = ((JobSignalRequest) draftCopy); if (idShouldBeCopiedAndSet == Boolean.TRUE) { String sourceId; sourceId = this.getId(); String copyId = ((String) strategy.copy(LocatorUtils.property(locator, "id", sourceId), sourceId, (this.id!= null))); copy.setId(copyId); } else { if (idShouldBeCopiedAndSet == Boolean.FALSE) { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.TRUE) { String sourceReceiveTaskId; sourceReceiveTaskId = this.getReceiveTaskId(); String copyReceiveTaskId = ((String) strategy.copy(LocatorUtils.property(locator, "receiveTaskId", sourceReceiveTaskId), sourceReceiveTaskId, (this.receiveTaskId!= null))); copy.setReceiveTaskId(copyReceiveTaskId); } else { if (receiveTaskIdShouldBeCopiedAndSet == Boolean.FALSE) { if (parametersShouldBeCopiedAndSet == Boolean.TRUE) { List<Parameter> sourceParameters; sourceParameters = ((this.parameters!= null)?this.getParameters():null); @SuppressWarnings("unchecked") List<Parameter> copyParameters = ((List<Parameter> ) strategy.copy(LocatorUtils.property(locator, "parameters", sourceParameters), sourceParameters, (this.parameters!= null))); copy.parameters = null; if (copyParameters!= null) { copy.setParameters(copyParameters);
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theId; theId = this.getId(); strategy.appendField(locator, this, "id", buffer, theId, (this.id!= null)); } { String theReceiveTaskId; theReceiveTaskId = this.getReceiveTaskId(); strategy.appendField(locator, this, "receiveTaskId", buffer, theReceiveTaskId, (this.receiveTaskId!= null)); } { List<Parameter> theParameters; theParameters = ((this.parameters!= null)?this.getParameters():null); strategy.appendField(locator, this, "parameters", buffer, theParameters, (this.parameters!= null)); } { S3PropertiesLocation theS3PropertiesLocation; theS3PropertiesLocation = this.getS3PropertiesLocation(); strategy.appendField(locator, this, "s3PropertiesLocation", buffer, theS3PropertiesLocation, (this.s3PropertiesLocation!= null)); } return buffer; }
/** * Validates the job signal request. This method also trims request parameters. * * @param request the request * * @throws IllegalArgumentException if any validation errors were found */ private void validateJobSignalRequest(JobSignalRequest request) { // Validate required elements Assert.hasText(request.getId(), "A job id must be specified."); Assert.hasText(request.getReceiveTaskId(), "A receive task id must be specified."); // Validate that parameter names are there and not duplicate parameterHelper.validateParameters(request.getParameters()); if (request.getS3PropertiesLocation() != null) { s3PropertiesLocationHelper.validate(request.getS3PropertiesLocation()); } // Remove leading and trailing spaces. request.setId(request.getId().trim()); request.setReceiveTaskId(request.getReceiveTaskId().trim()); } }
/** * Create an instance of {@link JobSignalRequest } * */ public JobSignalRequest createJobSignalRequest() { return new JobSignalRequest(); }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
lhsId = this.getId(); String rhsId; rhsId = that.getId(); if (!strategy.equals(LocatorUtils.property(thisLocator, "id", lhsId), LocatorUtils.property(thatLocator, "id", rhsId), lhsId, rhsId, (this.id!= null), (that.id!= null))) { return false; lhsReceiveTaskId = this.getReceiveTaskId(); String rhsReceiveTaskId; rhsReceiveTaskId = that.getReceiveTaskId(); if (!strategy.equals(LocatorUtils.property(thisLocator, "receiveTaskId", lhsReceiveTaskId), LocatorUtils.property(thatLocator, "receiveTaskId", rhsReceiveTaskId), lhsReceiveTaskId, rhsReceiveTaskId, (this.receiveTaskId!= null), (that.receiveTaskId!= null))) { return false; lhsParameters = ((this.parameters!= null)?this.getParameters():null); List<Parameter> rhsParameters; rhsParameters = ((that.parameters!= null)?that.getParameters():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "parameters", lhsParameters), LocatorUtils.property(thatLocator, "parameters", rhsParameters), lhsParameters, rhsParameters, (this.parameters!= null), (that.parameters!= null))) { return false; lhsS3PropertiesLocation = this.getS3PropertiesLocation(); S3PropertiesLocation rhsS3PropertiesLocation; rhsS3PropertiesLocation = that.getS3PropertiesLocation(); if (!strategy.equals(LocatorUtils.property(thisLocator, "s3PropertiesLocation", lhsS3PropertiesLocation), LocatorUtils.property(thatLocator, "s3PropertiesLocation", rhsS3PropertiesLocation), lhsS3PropertiesLocation, rhsS3PropertiesLocation, (this.s3PropertiesLocation!= null), (that.s3PropertiesLocation!= null))) { return false;
/** * Create an instance of {@link JobSignalRequest } * */ public JobSignalRequest createJobSignalRequest() { return new JobSignalRequest(); }