Skip to content
Snippets Groups Projects
Commit 76757662 authored by Florian Lambers's avatar Florian Lambers
Browse files

updated flow matching check, refactored resultwrapper

parent 50f83c79
No related branches found
No related tags found
No related merge requests found
package de.fhmuenster.masterthesis.Testgenerator.migration; package de.fhmuenster.masterthesis.Testgenerator.migration;
public enum ActionType { public enum ActionType {
ACTIVITY_ADD_MANUAL_TASK, ACTIVITY_ADD_USER_TASK, ACTIVITY_ADD_BUSINESS_RULE_TASK, ACTIVITY_ADD_MANUAL_TASK, ACTIVITY_ADD_USER_TASK, ACTIVITY_ADD_BUSINESS_RULE_TASK_WITH_OUTPUT,
ACTIVITY_ADD_SCRIPT_TASK, ACTIVITY_ADD_SERVICE_TASK ACTIVITY_ADD_BUSINESS_RULE_TASK_WITHOUT_OUTPUT, ACTIVITY_ADD_SCRIPT_TASK, ACTIVITY_ADD_SERVICE_TASK,
ACTIVITY_DELETE_MANUAL_TASK, ACTIVITY_DELETE_USER_TASK, ACTIVITY_DELETE_BUSINESS_RULE_TASK,
ACTIVITY_DELETE_SCRIPT_TASK, ACTIVITY_DELETE_SERVICE_TASK
} }
...@@ -11,11 +11,13 @@ import org.springframework.stereotype.Service; ...@@ -11,11 +11,13 @@ import org.springframework.stereotype.Service;
import de.fhmuenster.masterthesis.Testgenerator.rest.dto.MigrationResultWrapperDTO; import de.fhmuenster.masterthesis.Testgenerator.rest.dto.MigrationResultWrapperDTO;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.change.ChangeService; import de.fhmuenster.masterthesis.Testgenerator.rest.service.change.ChangeService;
import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationResult;
import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationResultStatus; import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationResultStatus;
import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationYaml; import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationYaml;
import de.fhmuenster.masterthesis.Testgenerator.yaml.YamlReader; import de.fhmuenster.masterthesis.Testgenerator.yaml.YamlReader;
import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer; import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
import de.fhmuenster.masterthesis.testgeneratorDSL.Flow; import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference; import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement;
...@@ -92,6 +94,9 @@ public class MigrationService { ...@@ -92,6 +94,9 @@ public class MigrationService {
Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows); Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows);
for(int i=0; i < matchingFlows.length; i++) { for(int i=0; i < matchingFlows.length; i++) {
//Wenn kein alter Flow vorhanden ist, konnte das Matching nicht durchgeführt werden
if(matchingFlows[i][1] == null) continue;
result.addAll(compareFlowsForAddAction(matchingFlows[i][1], matchingFlows[i][0])); result.addAll(compareFlowsForAddAction(matchingFlows[i][1], matchingFlows[i][0]));
} }
...@@ -105,6 +110,9 @@ public class MigrationService { ...@@ -105,6 +110,9 @@ public class MigrationService {
Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows); Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows);
for(int i=0; i < matchingFlows.length; i++) { for(int i=0; i < matchingFlows.length; i++) {
//Wenn kein alter Flow vorhanden ist, konnte das Matching nicht durchgeführt werden
if(matchingFlows[i][1] == null) continue;
result.addAll(compareFlowsForDeleteAction(matchingFlows[i][1], matchingFlows[i][0])); result.addAll(compareFlowsForDeleteAction(matchingFlows[i][1], matchingFlows[i][0]));
} }
...@@ -134,44 +142,25 @@ public class MigrationService { ...@@ -134,44 +142,25 @@ public class MigrationService {
for(FlowElementReference e : addedFlowElements) { for(FlowElementReference e : addedFlowElements) {
if(e.getRef() instanceof ManualTaskFlowElement) { if(e.getRef() instanceof ManualTaskFlowElement) {
FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_MANUAL_TASK, result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_MANUAL_TASK, e.getRef(), yaml));
e.getRef(), yaml.getActivity().getAdd().getManualTask());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
} }
if(e.getRef() instanceof UserTaskFlowElement) { if(e.getRef() instanceof UserTaskFlowElement) {
FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK, result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK, e.getRef(), yaml));
e.getRef(), yaml.getActivity().getAdd().getUserTask());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
} }
if(e.getRef() instanceof BusinessRuleTaskFlowElement) { if(e.getRef() instanceof BusinessRuleTaskFlowElement) {
BusinessRuleTaskFlowElement element = (BusinessRuleTaskFlowElement) e.getRef(); BusinessRuleTaskFlowElement element = (BusinessRuleTaskFlowElement) e.getRef();
FlowChangeWrapper fcw = null; FlowChangeWrapper fcw = null;
if(element.getResultVariable() != "") { if(element.getResultVariable() != "") {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK, result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK_WITH_OUTPUT,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithOutput()); e.getRef(), yaml));
} }
else { else {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK, result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK_WITHOUT_OUTPUT,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput()); e.getRef(), yaml));
}
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
} }
result.add(fcw);
} }
if(e.getRef() instanceof ServiceTaskFlowElement) { if(e.getRef() instanceof ServiceTaskFlowElement) {
ServiceTaskFlowElement element = (ServiceTaskFlowElement) e.getRef(); ServiceTaskFlowElement element = (ServiceTaskFlowElement) e.getRef();
FlowChangeWrapper fcw = null;
//erstmal als todo gelassen //erstmal als todo gelassen
/* /*
if(element.get != "") { if(element.get != "") {
...@@ -183,18 +172,11 @@ public class MigrationService { ...@@ -183,18 +172,11 @@ public class MigrationService {
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput()); e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput());
} }
*/ */
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SERVICE_TASK,
e.getRef(), yaml.getActivity().getAdd().getServiceTask().getWithoutOutput());
if(fcw.getMigrationResult().getPriority() == null) { result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SERVICE_TASK, e.getRef(), yaml));
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
} }
if(e.getRef() instanceof ScriptTaskFlowElement) { if(e.getRef() instanceof ScriptTaskFlowElement) {
ScriptTaskFlowElement element = (ScriptTaskFlowElement) e.getRef(); ScriptTaskFlowElement element = (ScriptTaskFlowElement) e.getRef();
FlowChangeWrapper fcw = null;
//erstmal als todo gelassen //erstmal als todo gelassen
/* /*
...@@ -207,14 +189,7 @@ public class MigrationService { ...@@ -207,14 +189,7 @@ public class MigrationService {
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput()); e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput());
} }
*/ */
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SCRIPT_TASK, result.add(this.prepareFlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SCRIPT_TASK, e.getRef(), yaml));
e.getRef(), yaml.getActivity().getAdd().getScriptTask().getWithoutOutput());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
} }
} }
...@@ -244,7 +219,15 @@ public class MigrationService { ...@@ -244,7 +219,15 @@ public class MigrationService {
MigrationYaml yaml = yamlReader.loadMigrationYaml(); MigrationYaml yaml = yamlReader.loadMigrationYaml();
for(FlowElementReference e : deletedFlowElements) { for(FlowElementReference e : deletedFlowElements) {
if(e.getRef() instanceof ManualTaskFlowElement) {
FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_DELETE_MANUAL_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
}
} }
...@@ -356,4 +339,40 @@ public class MigrationService { ...@@ -356,4 +339,40 @@ public class MigrationService {
score += yaml.getConfiguration().getRed(); score += yaml.getConfiguration().getRed();
return score; return score;
} }
private FlowChangeWrapper prepareFlowChangeWrapper(Flow flow, ActionType actionType,
FlowElement element, MigrationYaml yaml) {
MigrationResult migrationResult = null;
switch(actionType) {
case ACTIVITY_ADD_MANUAL_TASK:
migrationResult = yaml.getActivity().getAdd().getManualTask();
break;
case ACTIVITY_ADD_USER_TASK:
migrationResult = yaml.getActivity().getAdd().getUserTask();
break;
case ACTIVITY_ADD_BUSINESS_RULE_TASK_WITH_OUTPUT:
migrationResult = yaml.getActivity().getAdd().getBusinessRuleTask().getWithOutput();
break;
case ACTIVITY_ADD_BUSINESS_RULE_TASK_WITHOUT_OUTPUT:
migrationResult = yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput();
break;
case ACTIVITY_ADD_SERVICE_TASK:
//TODO: Muss noch unterschieden werden ob mit oder ohne Output
migrationResult = yaml.getActivity().getAdd().getServiceTask().getWithOutput();
break;
case ACTIVITY_ADD_SCRIPT_TASK:
//TODO: Muss noch unterschieden werden ob mit oder ohne Output
migrationResult = yaml.getActivity().getAdd().getScriptTask().getWithOutput();
break;
}
if(migrationResult.getPriority() == null) {
migrationResult.setPriority(this.loadGlobalPriority(migrationResult.getStatus(), yaml));
}
FlowChangeWrapper fcw = new FlowChangeWrapper(flow, actionType, element, migrationResult);
return fcw;
}
} }
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