org.activiti.bpmn.model.ScriptTask Java Examples

The following examples show how to use org.activiti.bpmn.model.ScriptTask. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: TextAnnotationConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getFlowElement("_5");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof ScriptTask);
  assertEquals("_5", flowElement.getId());
  ScriptTask scriptTask = (ScriptTask) flowElement;
  assertEquals("_5", scriptTask.getId());
  assertEquals("Send Hello Message", scriptTask.getName());
}
 
Example #3
Source File: ScriptTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
  ScriptTask scriptTask = (ScriptTask) element;
  if (StringUtils.isNotEmpty(scriptTask.getScript())) {
    xtw.writeStartElement(ATTRIBUTE_TASK_SCRIPT_TEXT);
    xtw.writeCData(scriptTask.getScript());
    xtw.writeEndElement();
  }
}
 
Example #4
Source File: ScriptTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #5
Source File: ScriptTaskInfoMapper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void mapProperties(Object element) {
	ScriptTask scriptTask = (ScriptTask) element;
	if (StringUtils.isNotEmpty(scriptTask.getScriptFormat())) {
	    createPropertyNode("Script format", scriptTask.getScriptFormat());
	}
	if (StringUtils.isNotEmpty(scriptTask.getScript())) {
           createPropertyNode("Script", scriptTask.getScript());
       }
	createListenerPropertyNodes("Execution listeners", scriptTask.getExecutionListeners());
}
 
Example #6
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask) {
  String language = scriptTask.getScriptFormat();
  if (language == null) {
    language = ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE;
  }
  return new ScriptTaskActivityBehavior(scriptTask.getId(), scriptTask.getScript(), language, scriptTask.getResultVariable(), scriptTask.isAutoStoreVariables());
}
 
Example #7
Source File: SecureJavascriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void createSecureJavascriptTaskBehavior(BpmnParse bpmnParse, ScriptTask scriptTask, String language) {
  if (StringUtils.isEmpty(scriptTask.getScript())) {
    logger.warn("No script provided for scriptTask " + scriptTask.getId());
  }
  
  scriptTask.setBehavior(new SecureJavascriptTaskActivityBehavior(scriptTask.getId(), 
      scriptTask.getScript(), language, scriptTask.getResultVariable(), scriptTask.isAutoStoreVariables()));
}
 
Example #8
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask) {
  String language = scriptTask.getScriptFormat();
  if (language == null) {
    language = ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE;
  }
  return new ScriptTaskActivityBehavior(scriptTask.getId(), scriptTask.getScript(), language, scriptTask.getResultVariable(), scriptTask.isAutoStoreVariables());
}
 
Example #9
Source File: ScriptTaskValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
  List<ScriptTask> scriptTasks = process.findFlowElementsOfType(ScriptTask.class);
  for (ScriptTask scriptTask : scriptTasks) {
    if (StringUtils.isEmpty(scriptTask.getScript())) {
      addError(errors, Problems.SCRIPT_TASK_MISSING_SCRIPT, process, scriptTask, "No script provided for script task");
    }
  }
}
 
Example #10
Source File: SecureJavascriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {
  String language = scriptTask.getScriptFormat();
  if (LANGUAGE_JAVASCRIPT.equalsIgnoreCase(language)) {
    createSecureJavascriptTaskBehavior(bpmnParse, scriptTask, language);
  } else {
    super.executeParse(bpmnParse, scriptTask);
  }
}
 
Example #11
Source File: TestActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask) {
  return wrappedActivityBehaviorFactory.createScriptTaskActivityBehavior(scriptTask);
}
 
Example #12
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask)
{
	return _source.createScriptTaskActivityBehavior(scriptTask);
}
 
Example #13
Source File: TestActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask) {
	return wrappedActivityBehaviorFactory.createScriptTaskActivityBehavior(scriptTask);
}
 
Example #14
Source File: ScriptTextParser.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
  if (parentElement instanceof ScriptTask == false)
    return;

  ((ScriptTask) parentElement).setScript(xtr.getElementText());
}
 
Example #15
Source File: ScriptTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getBpmnElementType() {
  return ScriptTask.class;
}
 
Example #16
Source File: ScriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getHandledType() {
  return ScriptTask.class;
}
 
Example #17
Source File: ScriptTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
  ScriptTask task = new ScriptTask();
  task.setScriptFormat(getPropertyValueAsString(PROPERTY_SCRIPT_FORMAT, elementNode));
  task.setScript(getPropertyValueAsString(PROPERTY_SCRIPT_TEXT, elementNode));
  return task;
}
 
Example #18
Source File: ScriptTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
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());
}
 
Example #19
Source File: ScriptTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void fillBpmnTypes(Map<Class<? extends BaseElement>, Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {
  convertersToJsonMap.put(ScriptTask.class, ScriptTaskJsonConverter.class);
}
 
Example #20
Source File: ScriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class< ? extends BaseElement> getHandledType() {
  return ScriptTask.class;
}
 
Example #21
Source File: ScriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 3 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {

    if (StringUtils.isEmpty(scriptTask.getScript())) {
      logger.warn("No script provided for scriptTask " + scriptTask.getId());
    }

    scriptTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createScriptTaskActivityBehavior(scriptTask));

  }
 
Example #22
Source File: ScriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 3 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {

    if (StringUtils.isEmpty(scriptTask.getScript())) {
      logger.warn("No script provided for scriptTask " + scriptTask.getId());
    }
    
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, scriptTask, BpmnXMLConstants.ELEMENT_TASK_SCRIPT);
    
    activity.setAsync(scriptTask.isAsynchronous());
    activity.setExclusive(!scriptTask.isNotExclusive());

    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createScriptTaskActivityBehavior(scriptTask));
    
  }
 
Example #23
Source File: ActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 votes vote down vote up
public abstract ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask); 
Example #24
Source File: ActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 votes vote down vote up
public abstract ScriptTaskActivityBehavior createScriptTaskActivityBehavior(ScriptTask scriptTask);