Skip to content
Snippets Groups Projects
Commit 00e70f21 authored by tfli's avatar tfli
Browse files

Fixed bug to parse the correct flows

parent f53113cc
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,6 @@ public class PrioritizationService {
HashMap<String, List<String>> changesReadVariables = this.checkVariables(readVariablesOldDSL, readVariablesNewDSL);
HashMap<String, List<String>> changesWriteVariables = this.checkVariables(writeVariablesOldDSL, writeVariablesNewDSL);
System.out.println("================================================");
System.out.println("PRIORIZTION => OLD TO NEW");
......@@ -75,11 +74,13 @@ public class PrioritizationService {
System.out.println(changesWriteVariablesOLD);
System.out.println("================================================");
HashMap<String, List<String>> differentReadVariables = this.checkDifferences(changesReadVariablesOLD, changesReadVariables);
HashMap<String, List<String>> differentWriteVariables = this.checkDifferences(changesWriteVariablesOLD, changesWriteVariables);
HashMap<String, Integer> dependenciesRead = this.checkFlowsWhereVariableExists(differentReadVariables);
HashMap<String, Integer> dependenciesWrite = this.checkFlowsWhereVariableExists(differentWriteVariables);
dependenciesNew = this.parseFlowsForDependencies(changesReadVariables, changesWriteVariables);
dependenciesOld = this.parseFlowsForDependencies(changesReadVariablesOLD, changesWriteVariablesOLD);
this.sumDependencies(dependenciesNew, dependenciesOld);
this.sumDependencies(dependenciesRead, dependenciesWrite);
this.dumpDependencyList(this.newDSL.getFlows());
try {
......@@ -90,6 +91,55 @@ public class PrioritizationService {
}
}
// Here, the changes of the variables are compared to the flowelements
private HashMap<String, Integer> checkFlowsWhereVariableExists(HashMap<String, List<String>> differentVariables) {
HashMap<String, Integer> dependencyList = new HashMap<>();
if(differentVariables != null) {
List<Flow> flows = this.newDSL.getFlows();
for(Flow f: flows)
{
int countDependency = 0;
List<FlowElementReference> fer = f.getInclElements();
for(int i = 0; i < fer.size(); i++)
{
String currentFlowElement = fer.get(i).getRef().getName();
for (Entry<String, List<String>> differentVariableMap : differentVariables.entrySet()) {
String variableEntry = differentVariableMap.getKey(); // Since the variableentrys are called the same as the flowelements, you can compare those
if(variableEntry.equals(currentFlowElement)) {
countDependency++;
}
}
}
dependencyList.put(f.getName(), countDependency); // Put the flowname and the dependency into the returned map
}
}
return dependencyList;
}
private HashMap<String, List<String>> checkDifferences(HashMap<String, List<String>> changeVariablesOLD,
HashMap<String, List<String>> changesVariablesNEW) {
HashMap<String, List<String>> differentVariables = new HashMap<>();
if(changeVariablesOLD != null && changesVariablesNEW != null) {
for (Entry<String, List<String>> oldVariableMap : changeVariablesOLD.entrySet()) {
String oldVariablesKey = oldVariableMap.getKey();
List<String> oldVariablesValue = oldVariableMap.getValue();
for (Entry<String, List<String>> newVariableMap : changesVariablesNEW.entrySet()) {
String newVariablesKey = newVariableMap.getKey();
List<String> newVariablesValue = newVariableMap.getValue();
if(oldVariablesKey.equals(newVariablesKey)) {
if(oldVariablesValue.equals(newVariablesValue) == false) {
differentVariables.put(oldVariablesKey, oldVariablesValue);
}
}
}
}
}
return differentVariables;
}
private void dumpDependencyList(List<Flow> flows)
{
for(Flow f: flows) {
......@@ -122,7 +172,7 @@ public class PrioritizationService {
String flowElement = elem2.getKey();
Integer flowDependency = elem2.getValue();
if(currentFlowElement == flowElement)
if(currentFlowElement.equals(flowElement))
{
// Sum the dependencies
int sum = dependencyFlow + flowDependency;
......@@ -132,109 +182,6 @@ public class PrioritizationService {
}
}
/**
* Search in all flows for dependencies. If it founds an dependency the dependencyList will be extended
* @param changesReadVariables
* @param changesWriteVariables
* @return HashMap<String, Integer> dependencyList
*/
private HashMap<String, Integer> parseFlowsForDependencies(HashMap<String, List<String>> changesReadVariables, HashMap<String, List<String>> changesWriteVariables)
{
HashMap<String, Integer> dependencyList = new HashMap<>();
List<Flow> flows = this.newDSL.getFlows();
for(Flow f: flows)
{
List<FlowElementReference> fer = f.getInclElements();
int countDependency = 0;
for(int i = 0; i < fer.size(); i++)
{
String currentFlowElement = fer.get(i).getRef().getName();
try
{
if(changesReadVariables.get(currentFlowElement) != null)
{
for(String checkReadDependencyVar : changesReadVariables.get(currentFlowElement)) // Kundennummer in checkDependencyVar
{
for(int j = i+1; j < fer.size(); j++)
{
String nextFlowElement = fer.get(j).getRef().getName(); // Innerhalb des gleichen Flows nächtes FlowElement auswählen
for(Map.Entry<String, List<VariableReference>> entry : this.readVariables.entrySet()) // Liste mit allen ReadVariablen durchlaufen bspw. "Kundennummer_ermitteln" => vorname, nachname, kundennumer
{
String flowElement = entry.getKey();
if(nextFlowElement == flowElement) // FlowElement mit dem aus der readVariables-Liste abgleichen
{
List<VariableReference> reads = entry.getValue();
for(VariableReference read : reads)
{
String currentRead = read.getRef().getName();
if(currentRead.equals(checkReadDependencyVar)) // Variable existiert in dem Flow, Dependency gefunden
{
countDependency++;
}
}
}
}
}
}
dependencyList.put(f.getName(), countDependency);
}
}
catch (Exception e)
{
//System.out.println("[ERROR] ReadVariables: " + e);
}
try
{
if(changesWriteVariables.get(currentFlowElement) != null)
{
for(String checkWriteDependencyVar : changesWriteVariables.get(currentFlowElement)) // Kundennummer in checkDependencyVar
{
for(int j = i+1; j < fer.size(); j++)
{
String nextFlowElement = fer.get(j).getRef().getName(); // Innerhalb des gleichen Flows nächtes FlowElement auswählen
for(Map.Entry<String, List<VariableReference>> entry : this.writeVariables.entrySet()) // Liste mit allen ReadVariablen durchlaufen bspw. "Kundennummer_ermitteln" => vorname, nachname, kundennumer
{
String flowElement = entry.getKey();
if(nextFlowElement == flowElement) // FlowElement mit dem aus der readVariables-Liste abgleichen
{
List<VariableReference> writes = entry.getValue();
for(VariableReference write : writes)
{
String currentWrite = write.getRef().getName();
if(currentWrite == checkWriteDependencyVar) // Variable existiert in dem Flow, Dependency gefunden
{
countDependency++;
}
}
}
}
}
}
dependencyList.put(f.getName(), countDependency);
}
}
catch (Exception e)
{
//System.out.println("[ERROR] WriteVariables: " + e);
}
}
}
return dependencyList;
}
/**
* Function to check VariableChanges in DSL
* @param oldDSL
......@@ -289,7 +236,6 @@ public class PrioritizationService {
{
listNewVars.addAll(entry.getValue());
}
// System.out.println("TEST LIST: " + testList);
if(mapNEW.equals(mapOLD) == false)
{
......@@ -330,7 +276,6 @@ public class PrioritizationService {
{
return null;
}
return returnMap;
}
......
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