Skip to content
Snippets Groups Projects
Commit 37d47889 authored by Henning's avatar Henning
Browse files

Added removeVariables to BPMNIOVariableScanner. New Function

getRemoveVariables, added removeVariables to TestService
parent 5102e40d
No related branches found
No related tags found
No related merge requests found
package de.fhmuenster.masterthesis.Testgenerator.bpmn.data; package de.fhmuenster.masterthesis.Testgenerator.bpmn.data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class BPMNIOParameters { public class BPMNIOParameters {
private HashMap<String, List<String>> inputVariables = new HashMap<String, List<String>>(); private HashMap<String, List<String>> inputVariables = new HashMap<String, List<String>>();
private HashMap<String, List<String>> outputVariables = new HashMap<String, List<String>>(); private HashMap<String, List<String>> outputVariables = new HashMap<String, List<String>>();
private HashMap<String, List<String>> innerOutputVariables = new HashMap<String, List<String>>(); private HashMap<String, List<String>> innerOutputVariables = new HashMap<String, List<String>>();
private HashMap<String, List<String>> removeVariables = new HashMap<String, List<String>>();
private HashMap<String, HashMap<String, String>> hardcodedInputParametersString = new HashMap<String, HashMap<String, String>>();
private HashMap<String, HashMap<String, Long>> hardcodedInputParametersLong = new HashMap<String, HashMap<String, Long>>(); private HashMap<String, HashMap<String, String>> hardcodedInputParametersString = new HashMap<String, HashMap<String, String>>();
private HashMap<String, HashMap<String, Boolean>> hardcodedInputParametersBoolean = new HashMap<String, HashMap<String, Boolean>>(); private HashMap<String, HashMap<String, Long>> hardcodedInputParametersLong = new HashMap<String, HashMap<String, Long>>();
private HashMap<String, HashMap<String, Boolean>> hardcodedInputParametersBoolean = new HashMap<String, HashMap<String, Boolean>>();
public BPMNIOParameters() {
} public BPMNIOParameters() {
}
public HashMap<String, List<String>> getInputParameters() {
return inputVariables; public HashMap<String, List<String>> getInputParameters() {
} return inputVariables;
}
public List<String> getInputVariables(String taskId) {
return inputVariables.entrySet().stream() // public List<String> getInputVariables(String taskId) {
.filter(entry -> entry.getKey().equals(taskId)) // return inputVariables.entrySet().stream() //
.flatMap(entry -> entry.getValue().stream()) // .filter(entry -> entry.getKey().equals(taskId)) //
.distinct() // .flatMap(entry -> entry.getValue().stream()) //
.collect(Collectors.toList()); // .distinct() //
} .collect(Collectors.toList()); //
}
public List<String> getOutputVariables(String taskId) {
return outputVariables.entrySet().stream() // public List<String> getOutputVariables(String taskId) {
.filter(entry -> entry.getKey().equals(taskId)) // return outputVariables.entrySet().stream() //
.flatMap(entry -> entry.getValue().stream()) // .filter(entry -> entry.getKey().equals(taskId)) //
.distinct() // .flatMap(entry -> entry.getValue().stream()) //
.collect(Collectors.toList()); // .distinct() //
} .collect(Collectors.toList()); //
}
public HashMap<String, List<String>> getOutputParameters() {
return outputVariables; public HashMap<String, List<String>> getOutputParameters() {
} return outputVariables;
}
public void addInputVariable(String flowElementId, String inputVariableName) {
List<String> existingVariables = this.inputVariables.get(flowElementId); /**
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>(); * 15.12.2021
variables.add(inputVariableName); * getRemoveVariables on BPMNIOParameters
* @param taskId
this.inputVariables.put(flowElementId, variables); */
} public List<String> getRemoveVariables(String taskId) {
return removeVariables.entrySet().stream() //
public void addInputVariables(String flowElementId, List<String> inputVariables) { .filter(entry -> entry.getKey().equals(taskId)) //
List<String> existingVariables = this.inputVariables.get(flowElementId); .flatMap(entry -> entry.getValue().stream()) //
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>(); .distinct() //
variables.addAll(inputVariables); .collect(Collectors.toList()); //
}
this.inputVariables.put(flowElementId, variables);
} /**
* 15.12.2021
public void addOutputVariable(String flowElementId, String outputVariable) { * addRemoveVariable add removeVariable to HashMap removeVariables to use it on BPMNIOParameters
List<String> existingVariables = this.outputVariables.get(flowElementId); * @param taskId
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>(); */
variables.add(outputVariable); public void addRemoveVariable(String flowElementId, String removeVariable) {
List<String> existingVariables = this.removeVariables.get(flowElementId);
this.outputVariables.put(flowElementId, variables); List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
} variables.add(removeVariable);
this.removeVariables.put(flowElementId, variables);
public void addInnerOutputVariable(String flowElementId, String outputVariable) { }
List<String> existingVariables = this.innerOutputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>(); public void addInputVariable(String flowElementId, String inputVariableName) {
variables.add(outputVariable); List<String> existingVariables = this.inputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
this.innerOutputVariables.put(flowElementId, variables); variables.add(inputVariableName);
}
this.inputVariables.put(flowElementId, variables);
public void addOutputVariables(String flowElementId, List<String> outputVariables) { }
List<String> existingVariables = this.outputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>(); public void addInputVariables(String flowElementId, List<String> inputVariables) {
variables.addAll(outputVariables); List<String> existingVariables = this.inputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
this.outputVariables.put(flowElementId, variables); variables.addAll(inputVariables);
}
this.inputVariables.put(flowElementId, variables);
public void addHardcodedInputParameterString(String flowElementId, String inputVariable, String value) { }
HashMap<String, String> existingVariables = this.hardcodedInputParametersString.get(flowElementId);
HashMap<String, String> variables = existingVariables != null ? existingVariables : new HashMap<>(); public void addOutputVariable(String flowElementId, String outputVariable) {
variables.put(inputVariable, value); List<String> existingVariables = this.outputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
this.hardcodedInputParametersString.put(flowElementId, variables); variables.add(outputVariable);
}
this.outputVariables.put(flowElementId, variables);
public void addHardcodedInputParameterLong(String flowElementId, String inputVariable, Long value) { }
HashMap<String, Long> existingVariables = this.hardcodedInputParametersLong.get(flowElementId);
HashMap<String, Long> variables = existingVariables != null ? existingVariables : new HashMap<>(); public void addInnerOutputVariable(String flowElementId, String outputVariable) {
variables.put(inputVariable, value); List<String> existingVariables = this.innerOutputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
this.hardcodedInputParametersLong.put(flowElementId, variables); variables.add(outputVariable);
}
this.innerOutputVariables.put(flowElementId, variables);
public void addHardcodedInputParameterBoolean(String flowElementId, String inputVariable, Boolean value) { }
HashMap<String, Boolean> existingVariables = this.hardcodedInputParametersBoolean.get(flowElementId);
HashMap<String, Boolean> variables = existingVariables != null ? existingVariables : new HashMap<>(); public void addOutputVariables(String flowElementId, List<String> outputVariables) {
variables.put(inputVariable, value); List<String> existingVariables = this.outputVariables.get(flowElementId);
List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
this.hardcodedInputParametersBoolean.put(flowElementId, variables); variables.addAll(outputVariables);
}
this.outputVariables.put(flowElementId, variables);
public List<String> getVariables() { }
return Stream.concat(Stream.concat(inputVariables.values().stream(), outputVariables.values().stream()), innerOutputVariables.values().stream()) //
.flatMap(variableList -> variableList.stream()) // public void addHardcodedInputParameterString(String flowElementId, String inputVariable, String value) {
.distinct() // HashMap<String, String> existingVariables = this.hardcodedInputParametersString.get(flowElementId);
.collect(Collectors.toList()); // HashMap<String, String> variables = existingVariables != null ? existingVariables : new HashMap<>();
} variables.put(inputVariable, value);
public HashMap<String, String> getHardcodedInputParametersString(String flowElementId) { this.hardcodedInputParametersString.put(flowElementId, variables);
return hardcodedInputParametersString.get(flowElementId); }
}
public void addHardcodedInputParameterLong(String flowElementId, String inputVariable, Long value) {
public HashMap<String, Long> getHardcodedInputParametersLong(String flowElementId) { HashMap<String, Long> existingVariables = this.hardcodedInputParametersLong.get(flowElementId);
return hardcodedInputParametersLong.get(flowElementId); HashMap<String, Long> variables = existingVariables != null ? existingVariables : new HashMap<>();
} variables.put(inputVariable, value);
public HashMap<String, Boolean> getHardcodedInputParametersBoolean(String flowElementId) { this.hardcodedInputParametersLong.put(flowElementId, variables);
return hardcodedInputParametersBoolean.get(flowElementId); }
}
public void addHardcodedInputParameterBoolean(String flowElementId, String inputVariable, Boolean value) {
public List<String> getHardcodedInputParametersString() { HashMap<String, Boolean> existingVariables = this.hardcodedInputParametersBoolean.get(flowElementId);
return hardcodedInputParametersString.values().stream() // HashMap<String, Boolean> variables = existingVariables != null ? existingVariables : new HashMap<>();
.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) // variables.put(inputVariable, value);
.distinct() //
.collect(Collectors.toList()); // this.hardcodedInputParametersBoolean.put(flowElementId, variables);
} }
public List<String> getHardcodedInputParametersLong() { public List<String> getVariables() {
return hardcodedInputParametersLong.values().stream() // return Stream.concat(Stream.concat(inputVariables.values().stream(), outputVariables.values().stream()), innerOutputVariables.values().stream()) //
.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) // .flatMap(variableList -> variableList.stream()) //
.distinct() // .distinct() //
.collect(Collectors.toList()); // .collect(Collectors.toList()); //
} }
public List<String> getHardcodedInputParametersBoolean() { public HashMap<String, String> getHardcodedInputParametersString(String flowElementId) {
return hardcodedInputParametersBoolean.values().stream() // return hardcodedInputParametersString.get(flowElementId);
.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) // }
.distinct() //
.collect(Collectors.toList()); // public HashMap<String, Long> getHardcodedInputParametersLong(String flowElementId) {
} return hardcodedInputParametersLong.get(flowElementId);
}
public List<String> getHardcodedInputParameters() {
List<String> hardcodedInputParameters = new ArrayList<>(); public HashMap<String, Boolean> getHardcodedInputParametersBoolean(String flowElementId) {
hardcodedInputParameters.addAll(getHardcodedInputParametersString()); return hardcodedInputParametersBoolean.get(flowElementId);
hardcodedInputParameters.addAll(getHardcodedInputParametersLong()); }
hardcodedInputParameters.addAll(getHardcodedInputParametersBoolean());
public List<String> getHardcodedInputParametersString() {
return hardcodedInputParameters; return hardcodedInputParametersString.values().stream() //
} .flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
.distinct() //
public List<String> getHardcodedInputParameterValuesString(String parameter) { .collect(Collectors.toList()); //
return hardcodedInputParametersString.values().stream() // }
.map(parameterValueMap -> parameterValueMap.get(parameter)) //
.filter(value -> value != null) // public List<String> getHardcodedInputParametersLong() {
.distinct() // return hardcodedInputParametersLong.values().stream() //
.collect(Collectors.toList()); // .flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
} .distinct() //
.collect(Collectors.toList()); //
public List<Long> getHardcodedInputParameterValuesLong(String parameter) { }
return hardcodedInputParametersLong.values().stream() //
.map(parameterValueMap -> parameterValueMap.get(parameter)) // public List<String> getHardcodedInputParametersBoolean() {
.distinct() // return hardcodedInputParametersBoolean.values().stream() //
.collect(Collectors.toList()); // .flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
} .distinct() //
} .collect(Collectors.toList()); //
}
public List<String> getHardcodedInputParameters() {
List<String> hardcodedInputParameters = new ArrayList<>();
hardcodedInputParameters.addAll(getHardcodedInputParametersString());
hardcodedInputParameters.addAll(getHardcodedInputParametersLong());
hardcodedInputParameters.addAll(getHardcodedInputParametersBoolean());
return hardcodedInputParameters;
}
public List<String> getHardcodedInputParameterValuesString(String parameter) {
return hardcodedInputParametersString.values().stream() //
.map(parameterValueMap -> parameterValueMap.get(parameter)) //
.filter(value -> value != null) //
.distinct() //
.collect(Collectors.toList()); //
}
public List<Long> getHardcodedInputParameterValuesLong(String parameter) {
return hardcodedInputParametersLong.values().stream() //
.map(parameterValueMap -> parameterValueMap.get(parameter)) //
.distinct() //
.collect(Collectors.toList()); //
}
}
package de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation; package de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Arrays;
import java.util.regex.Matcher; import java.util.Collection;
import java.util.regex.Pattern; import java.util.HashMap;
import java.util.stream.Collectors; import java.util.List;
import java.util.regex.Matcher;
import org.camunda.bpm.model.bpmn.instance.BaseElement; import java.util.regex.Pattern;
import org.camunda.bpm.model.bpmn.instance.FlowElement; import java.util.stream.Collectors;
import org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter;
import org.camunda.bpm.model.bpmn.instance.camunda.CamundaOutputParameter; import org.camunda.bpm.model.bpmn.instance.BaseElement;
import org.camunda.bpm.model.bpmn.instance.FlowElement;
import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet; import org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter;
import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters; import org.camunda.bpm.model.bpmn.instance.camunda.CamundaOutputParameter;
import org.camunda.bpm.model.xml.instance.ModelElementInstance;
public class BPMNVariableIOScanner {
import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet;
private static final String VARIABLE_MATCH_REGEX = "\\$\\{(.*?)\\}"; import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters;
private static final String INT_MATCH_REGEX = "[0-9]+"; import de.fhmuenster.masterthesis.testgeneratorDSL.Variable;
private static final String BOOLEAN_MATCH_REGEX = "true|false";
public class BPMNVariableIOScanner {
private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
private static final String INPUT_OUTPUT_NAME = "inputOutput"; private static final String VARIABLE_MATCH_REGEX = "\\$\\{(.*?)\\}";
private static final String INT_MATCH_REGEX = "[0-9]+";
private BPMNFlowSet flowSet; private static final String BOOLEAN_MATCH_REGEX = "true|false";
private BPMNIOParameters bpmnIOParameters;
private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
public BPMNVariableIOScanner(BPMNFlowSet flowSet) { private static final String INPUT_OUTPUT_NAME = "inputOutput";
this.flowSet = flowSet; private static final String EXECUTION_LISTENER = "executionListener";
this.bpmnIOParameters = new BPMNIOParameters();
} private BPMNFlowSet flowSet;
private BPMNIOParameters bpmnIOParameters;
public void doScan() {
List<FlowElement> extensionElements = flowSet.getFlowElements().stream() // public BPMNVariableIOScanner(BPMNFlowSet flowSet) {
.filter(baseElement -> ((BaseElement) baseElement).getExtensionElements() != null) // this.flowSet = flowSet;
.collect(Collectors.toList()); // this.bpmnIOParameters = new BPMNIOParameters();
}
extensionElements
.forEach(baseElement -> scanInputs(baseElement)); // public void doScan() {
List<FlowElement> extensionElements = flowSet.getFlowElements().stream() //
extensionElements .filter(baseElement -> ((BaseElement) baseElement).getExtensionElements() != null) //
.forEach(baseElement -> scanOutputs(baseElement)); // .collect(Collectors.toList()); //
}
extensionElements
private void scanInputs(FlowElement baseElement) { .forEach(baseElement -> scanInputs(baseElement)); //
baseElement.getExtensionElements().getElements().stream() //
.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) // extensionElements
.flatMap(formData -> formData.getChildElementsByType(CamundaInputParameter.class).stream()) // .forEach(baseElement -> scanOutputs(baseElement)); //
.map(inputParameter -> ((CamundaInputParameter) inputParameter)) //
.forEach(inputParameter -> insertInputParameter(baseElement, inputParameter)); // /*
} * @Tim @Henning
* added routine to scan in Camunda the removeExpressions
private void insertInputParameter(FlowElement baseElement, CamundaInputParameter inputParameter) { */
//Input-Format --> Text muss verwendet werden extensionElements
//<camunda:inputParameter name="ExternalServiceVariable">${ProcessVariable}</camunda:inputParameter> .forEach(baseElement -> scanRemoveExpressions(baseElement)); //
String textContent = inputParameter.getTextContent();
List<String> variables = extractVariables(textContent); }
if(!variables.isEmpty()) { private void scanInputs(FlowElement baseElement) {
bpmnIOParameters.addInputVariables(baseElement.getId(), variables); baseElement.getExtensionElements().getElements().stream() //
} else { .filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
//If no variables extracted --> it seems to be a hard set value .flatMap(formData -> formData.getChildElementsByType(CamundaInputParameter.class).stream()) //
//Examples for hardcoded values: ${5}, ${true}, Teststring .map(inputParameter -> ((CamundaInputParameter) inputParameter)) //
addHardcodedInputVariable(baseElement.getId(), inputParameter.getCamundaName(), textContent); .forEach(inputParameter -> insertInputParameter(baseElement, inputParameter)); //
} }
}
private void insertInputParameter(FlowElement baseElement, CamundaInputParameter inputParameter) {
private void addHardcodedInputVariable(String flowElementId, String inputParameter, String textContent) { //Input-Format --> Text muss verwendet werden
Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX); //<camunda:inputParameter name="ExternalServiceVariable">${ProcessVariable}</camunda:inputParameter>
Matcher matcherValue = patternVariableMatch.matcher(textContent); String textContent = inputParameter.getTextContent();
List<String> variables = extractVariables(textContent);
if(matcherValue.find()) {
String extractedValue = matcherValue.group(1); if(!variables.isEmpty()) {
bpmnIOParameters.addInputVariables(baseElement.getId(), variables);
if(extractedValue.matches(INT_MATCH_REGEX)) { } else {
bpmnIOParameters.addHardcodedInputParameterLong(flowElementId, inputParameter, Long.valueOf(extractedValue)); //If no variables extracted --> it seems to be a hard set value
} else if(extractedValue.matches(BOOLEAN_MATCH_REGEX)) { //Examples for hardcoded values: ${5}, ${true}, Teststring
bpmnIOParameters.addHardcodedInputParameterBoolean(flowElementId, inputParameter, Boolean.valueOf(extractedValue)); addHardcodedInputVariable(baseElement.getId(), inputParameter.getCamundaName(), textContent);
} }
} else { }
bpmnIOParameters.addHardcodedInputParameterString(flowElementId, inputParameter, textContent);
} private void addHardcodedInputVariable(String flowElementId, String inputParameter, String textContent) {
} Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
Matcher matcherValue = patternVariableMatch.matcher(textContent);
private void scanOutputs(FlowElement baseElement) {
baseElement.getExtensionElements().getElements().stream() // if(matcherValue.find()) {
.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) // String extractedValue = matcherValue.group(1);
.flatMap(formData -> formData.getChildElementsByType(CamundaOutputParameter.class).stream()) //
.map(outputParameter -> ((CamundaOutputParameter) outputParameter)) // if(extractedValue.matches(INT_MATCH_REGEX)) {
.forEach(outputParameter -> insertOutputParameter(baseElement, outputParameter)); // bpmnIOParameters.addHardcodedInputParameterLong(flowElementId, inputParameter, Long.valueOf(extractedValue));
} } else if(extractedValue.matches(BOOLEAN_MATCH_REGEX)) {
bpmnIOParameters.addHardcodedInputParameterBoolean(flowElementId, inputParameter, Boolean.valueOf(extractedValue));
private void insertOutputParameter(FlowElement baseElement, CamundaOutputParameter outputParameter) { }
//Output-Format --> Name muss verwendet werden } else {
//<camunda:outputParameter name="ProcessVariable">${ExternalServiceVariable}</camunda:outputParameter> bpmnIOParameters.addHardcodedInputParameterString(flowElementId, inputParameter, textContent);
String textContent = outputParameter.getCamundaName(); }
bpmnIOParameters.addOutputVariable(baseElement.getId(), textContent); }
//Auf API-Seite wird der TextContent genutzt - für die Mocks relevant private void scanOutputs(FlowElement baseElement) {
String innerAPIParameter = outputParameter.getTextContent(); baseElement.getExtensionElements().getElements().stream() //
List<String> innerAPIVariables = extractVariables(innerAPIParameter); .filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
innerAPIVariables.forEach(innerAPIVariable -> bpmnIOParameters.addInnerOutputVariable(baseElement.getId(), innerAPIVariable)); .flatMap(formData -> formData.getChildElementsByType(CamundaOutputParameter.class).stream()) //
} .map(outputParameter -> ((CamundaOutputParameter) outputParameter)) //
.forEach(outputParameter -> insertOutputParameter(baseElement, outputParameter)); //
public BPMNIOParameters getBpmnIOParameters() { }
return bpmnIOParameters;
} private void insertOutputParameter(FlowElement baseElement, CamundaOutputParameter outputParameter) {
//Output-Format --> Name muss verwendet werden
private List<String> extractVariables(String ioParameter) { //<camunda:outputParameter name="ProcessVariable">${ExternalServiceVariable}</camunda:outputParameter>
List<String> variableMatches = new ArrayList<>(); String textContent = outputParameter.getCamundaName();
bpmnIOParameters.addOutputVariable(baseElement.getId(), textContent);
Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
Matcher matcherVariable = patternVariableMatch.matcher(ioParameter); //Auf API-Seite wird der TextContent genutzt - für die Mocks relevant
String innerAPIParameter = outputParameter.getTextContent();
while (matcherVariable.find()) { List<String> innerAPIVariables = extractVariables(innerAPIParameter);
String extractedVariable = matcherVariable.group(1); innerAPIVariables.forEach(innerAPIVariable -> bpmnIOParameters.addInnerOutputVariable(baseElement.getId(), innerAPIVariable));
if(!extractedVariable.matches(INT_MATCH_REGEX) && !extractedVariable.matches(BOOLEAN_MATCH_REGEX)) { }
variableMatches.add(extractedVariable);
} public BPMNIOParameters getBpmnIOParameters() {
} return bpmnIOParameters;
}
return variableMatches;
} private List<String> extractVariables(String ioParameter) {
} List<String> variableMatches = new ArrayList<>();
Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
Matcher matcherVariable = patternVariableMatch.matcher(ioParameter);
while (matcherVariable.find()) {
String extractedVariable = matcherVariable.group(1);
if(!extractedVariable.matches(INT_MATCH_REGEX) && !extractedVariable.matches(BOOLEAN_MATCH_REGEX)) {
variableMatches.add(extractedVariable);
}
}
return variableMatches;
}
/**
* 15.12.2021
* insert removeVariables to BPMNIOParameters
* @param baseElement
*/
private void insertRemoveVariable(FlowElement baseElement, String removeVar)
{
bpmnIOParameters.addRemoveVariable(baseElement.getId(), removeVar);
}
/**
* 15.12.2021
* Scan for removeExpressions
* @param baseElement
*/
private void scanRemoveExpressions(FlowElement baseElement) {
Collection<ModelElementInstance> elements = baseElement.getExtensionElements().getElements();
for(ModelElementInstance currentElement : elements)
{
if(currentElement.getElementType().getTypeName().equals(EXECUTION_LISTENER))
{
List<org.camunda.bpm.model.xml.type.attribute.Attribute<?>> expressionList = currentElement.getElementType().getAttributes();
for(org.camunda.bpm.model.xml.type.attribute.Attribute expression : expressionList)
{
try
{
List<String> removeVars = new ArrayList<String>();
switch(expression.getAttributeName())
{
case "delegateExpression":
String strExpression = expression.getValue(currentElement).toString();
Pattern pattern = Pattern.compile("\"(.*?)\"", Pattern.DOTALL);
Matcher matcher = pattern.matcher(strExpression);
while (matcher.find()) {
removeVars.add(matcher.group(1)); // Contains String with all variables from removeVar Expression
}
break;
default:
break;
}
if(!removeVars.isEmpty() && removeVars!=null)
{
// add the removeVariables to BPMNIOParameters via. insertRemoveVariables
removeVars.forEach(var -> this.insertRemoveVariable(baseElement, var));
}
}
catch(Exception e)
{
System.out.println("[ERROR] " + e.getMessage());
}
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment