Skip to content
Snippets Groups Projects
Commit 01795bc8 authored by tfli's avatar tfli
Browse files

Fixed setting data dependencies for write variables

parent 04815e70
No related branches found
No related tags found
No related merge requests found
package de.fhmuenster.masterthesis.Testgenerator.prioritization; package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -44,7 +45,7 @@ public class PrioritizationService { ...@@ -44,7 +45,7 @@ public class PrioritizationService {
readVariablesOldDSL = this.getReadVariables(this.oldDSL); readVariablesOldDSL = this.getReadVariables(this.oldDSL);
writeVariablesOldDSL = this.getWriteVariables(this.oldDSL); writeVariablesOldDSL = this.getWriteVariables(this.oldDSL);
readVariablesNewDSL = this.getReadVariables(this.newDSL); readVariablesNewDSL = this.getReadVariables(this.newDSL);
writeVariablesNewDSL = this.getWriteVariables(this.newDSL); writeVariablesNewDSL = this.getWriteVariables(this.newDSL);
...@@ -80,17 +81,33 @@ public class PrioritizationService { ...@@ -80,17 +81,33 @@ public class PrioritizationService {
this.sumDependencies(dependenciesNew, dependenciesOld); this.sumDependencies(dependenciesNew, dependenciesOld);
this.dumpDependencyList(); this.dumpDependencyList(this.newDSL.getFlows());
try {
this.newDSL.serialize();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
private void dumpDependencyList() private void dumpDependencyList(List<Flow> flows)
{ {
for (Entry<String, Integer> entry : this.dependencyList.entrySet()) { for(Flow f: flows) {
String flowName = entry.getKey(); for (Entry<String, Integer> entry : this.dependencyList.entrySet()) {
Integer weight = entry.getValue();
String flowName = entry.getKey();
System.out.println("Flow " + flowName + " with Dependency " + weight); Integer weight = entry.getValue();
if(f.getName().equals(flowName)) {
f.setDependency(weight);
System.out.println("Flow " + flowName + " with Dependency " + f.getDependency());
}
}
if(this.dependencyList.entrySet().isEmpty()) {
f.setDependency(0);
}
} }
} }
private void sumDependencies(HashMap<String, Integer> firstList, HashMap<String, Integer> secondList) private void sumDependencies(HashMap<String, Integer> firstList, HashMap<String, Integer> secondList)
...@@ -196,7 +213,6 @@ public class PrioritizationService { ...@@ -196,7 +213,6 @@ public class PrioritizationService {
String currentWrite = write.getRef().getName(); String currentWrite = write.getRef().getName();
if(currentWrite == checkWriteDependencyVar) // Variable existiert in dem Flow, Dependency gefunden if(currentWrite == checkWriteDependencyVar) // Variable existiert in dem Flow, Dependency gefunden
{ {
System.out.println("Dependcy found!");
countDependency++; countDependency++;
} }
} }
...@@ -229,7 +245,6 @@ public class PrioritizationService { ...@@ -229,7 +245,6 @@ public class PrioritizationService {
HashMap<String, List<String>> mapOLD = new HashMap<>(); HashMap<String, List<String>> mapOLD = new HashMap<>();
HashMap<String, List<String>> mapNEW = new HashMap<>(); HashMap<String, List<String>> mapNEW = new HashMap<>();
for(Map.Entry<String, List<VariableReference>> entry : newDSL.entrySet()) for(Map.Entry<String, List<VariableReference>> entry : newDSL.entrySet())
{ {
String key = entry.getKey(); String key = entry.getKey();
...@@ -238,9 +253,9 @@ public class PrioritizationService { ...@@ -238,9 +253,9 @@ public class PrioritizationService {
for(VariableReference var : vars) for(VariableReference var : vars)
{ {
list.add(var.getRef().getName()); if(var != null)
} list.add(var.getRef().getName());
}
mapNEW.put(key, list); mapNEW.put(key, list);
} }
...@@ -252,37 +267,51 @@ public class PrioritizationService { ...@@ -252,37 +267,51 @@ public class PrioritizationService {
for(VariableReference var : vars) for(VariableReference var : vars)
{ {
list.add(var.getRef().getName()); if(var != null) {
list.add(var.getRef().getName());
}
} }
mapOLD.put(key, list); mapOLD.put(key, list);
} }
HashMap<String, List<String>> returnMap = new HashMap<>(); HashMap<String, List<String>> returnMap = new HashMap<>();
List<String> listOldVars = new ArrayList<String>();
for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
{
listOldVars.addAll(entry.getValue());
}
List<String> listNewVars = new ArrayList<String>();
for(Map.Entry<String, List<String>> entry : mapOLD.entrySet())
{
listNewVars.addAll(entry.getValue());
}
// System.out.println("TEST LIST: " + testList);
if(mapNEW.equals(mapOLD) == false) if(mapNEW.equals(mapOLD) == false)
{ {
for(Map.Entry<String, List<String>> entry : mapNEW.entrySet()) for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
{ {
String flowElementNew = entry.getKey(); String flowElementNew = entry.getKey();
List<String> listNewVars = entry.getValue();
if(mapOLD.containsKey(flowElementNew)) if(mapOLD.containsKey(flowElementNew))
{ {
for(int i = 0; i < listNewVars.size(); i++) for(int i = 0; i < listOldVars.size(); i++)
{ {
String varNEW = listNewVars.get(i); String varNEW = listOldVars.get(i);
for(Map.Entry<String, List<String>> entryOld : mapOLD.entrySet()) for(Map.Entry<String, List<String>> entryOld : mapOLD.entrySet())
{ {
if(entryOld.getKey().equals(flowElementNew)) if(entryOld.getKey().equals(flowElementNew))
{ {
List<String> listOldVars = entryOld.getValue(); for(int j = 0; j < listNewVars.size(); j++)
for(int j = 0; j < listOldVars.size(); j++)
{
String varOLD = listOldVars.get(j);
{
String varOLD = listNewVars.get(j);
if(varOLD.equals(varNEW)) if(varOLD.equals(varNEW))
{ {
listOldVars.remove(varOLD); listOldVars.remove(varOLD);
...@@ -294,7 +323,6 @@ public class PrioritizationService { ...@@ -294,7 +323,6 @@ public class PrioritizationService {
} }
} }
} }
returnMap.putAll(mapOLD); returnMap.putAll(mapOLD);
returnMap.putAll(mapNEW); returnMap.putAll(mapNEW);
} }
...@@ -320,7 +348,7 @@ public class PrioritizationService { ...@@ -320,7 +348,7 @@ public class PrioritizationService {
for(Flow f: flows) for(Flow f: flows)
{ {
List<FlowElementReference> fer = f.getInclElements(); List<FlowElementReference> fer = f.getInclElements();
for(FlowElementReference flowElementReference: fer) for(FlowElementReference flowElementReference: fer)
{ {
FlowElement flowElement = flowElementReference.getRef(); FlowElement flowElement = flowElementReference.getRef();
......
...@@ -218,7 +218,6 @@ public class TestService { ...@@ -218,7 +218,6 @@ public class TestService {
variables.forEach(var -> serializer.addVariable(var)); variables.forEach(var -> serializer.addVariable(var));
externalTopics.forEach(externalTopic -> serializer.addExternalTopic(externalTopic)); externalTopics.forEach(externalTopic -> serializer.addExternalTopic(externalTopic));
flows.forEach(flow -> serializer.addFlow(flow)); flows.forEach(flow -> serializer.addFlow(flow));
setDataDependencies(flows, bpmnIOParameters);
serializer.serialize(); serializer.serialize();
} }
...@@ -227,24 +226,6 @@ public class TestService { ...@@ -227,24 +226,6 @@ public class TestService {
} }
} }
public void setDataDependencies(List<Flow> flows, BPMNIOParameters bpmnIOParams) {
for(Flow f: flows) {
int dependencies = 0;
List<FlowElementReference> fer = f.getInclElements();
for(FlowElementReference flowElementReference: fer) {
FlowElement flowElement = flowElementReference.getRef();
int inputVariableSize = bpmnIOParams.getInputVariables(flowElement.getName()).size();
int outputVariableSize = bpmnIOParams.getOutputVariables(flowElement.getName()).size();
if(inputVariableSize != 0) {
dependencies += inputVariableSize;
}
if(outputVariableSize != 0) {
dependencies += outputVariableSize;
}
}
f.setDependency(dependencies);
}
}
public void addTest(BPMNTestcase testcase, ProjectDirectories projectDirectories) { public void addTest(BPMNTestcase testcase, ProjectDirectories projectDirectories) {
Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories); Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
......
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