use of org.activiti.bpmn.model.ScriptTask in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that update job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
element.setAsynchronous(true);
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
jobDefinitionService.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.activiti.bpmn.model.ScriptTask in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that create job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
element.setAsynchronous(true);
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.activiti.bpmn.model.ScriptTask in project Activiti by Activiti.
the class ScriptTaskXMLConverter method convertXMLToElement.
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
ScriptTask scriptTask = new ScriptTask();
BpmnXMLUtil.addXMLLocation(scriptTask, xtr);
scriptTask.setScriptFormat(xtr.getAttributeValue(null, ATTRIBUTE_TASK_SCRIPT_FORMAT));
scriptTask.setResultVariable(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE));
if (StringUtils.isEmpty(scriptTask.getResultVariable())) {
scriptTask.setResultVariable(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE));
}
String autoStoreVariables = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE);
if (StringUtils.isNotEmpty(autoStoreVariables)) {
scriptTask.setAutoStoreVariables(Boolean.valueOf(autoStoreVariables));
}
parseChildElements(getXMLElementName(), scriptTask, childParserMap, model, xtr);
return scriptTask;
}
use of org.activiti.bpmn.model.ScriptTask in project Activiti by Activiti.
the class ScriptTaskXMLConverter method writeAdditionalAttributes.
@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
ScriptTask scriptTask = (ScriptTask) element;
writeDefaultAttribute(ATTRIBUTE_TASK_SCRIPT_FORMAT, scriptTask.getScriptFormat(), xtw);
writeQualifiedAttribute(ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE, scriptTask.getResultVariable(), xtw);
writeQualifiedAttribute(ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE, String.valueOf(scriptTask.isAutoStoreVariables()), xtw);
}
use of org.activiti.bpmn.model.ScriptTask in project Activiti by Activiti.
the class ScriptTaskJsonConverter method convertElementToJson.
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
ScriptTask scriptTask = (ScriptTask) baseElement;
propertiesNode.put(PROPERTY_SCRIPT_FORMAT, scriptTask.getScriptFormat());
propertiesNode.put(PROPERTY_SCRIPT_TEXT, scriptTask.getScript());
}
Aggregations