Skip to content
Snippets Groups Projects
Commit 68089ef2 authored by Till Josef Brinkhus's avatar Till Josef Brinkhus
Browse files
parents 804c8d2d d57c30a6
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 16 deletions
...@@ -87,9 +87,9 @@ public class FlowChangeWrapper { ...@@ -87,9 +87,9 @@ public class FlowChangeWrapper {
dto.setFlowElement(flowElementDTO); dto.setFlowElement(flowElementDTO);
MigrationResultDTO migrationResultDTO = new MigrationResultDTO(); MigrationResultDTO migrationResultDTO = new MigrationResultDTO();
migrationResultDTO.setPriority(this.getMigrationResult().getPriority());
migrationResultDTO.setPriority(this.getMigrationResult().getPriority()); migrationResultDTO.setPriority(this.getMigrationResult().getPriority());
migrationResultDTO.setStatus(this.getMigrationResult().getStatus().name()); migrationResultDTO.setStatus(this.getMigrationResult().getStatus().name());
dto.setMigrationResult(migrationResultDTO); dto.setMigrationResult(migrationResultDTO);
......
...@@ -9,9 +9,13 @@ import javax.annotation.PostConstruct; ...@@ -9,9 +9,13 @@ import javax.annotation.PostConstruct;
import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.test.TestService;
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;
...@@ -33,6 +37,9 @@ public class MigrationService { ...@@ -33,6 +37,9 @@ public class MigrationService {
private MigrationYaml yaml; private MigrationYaml yaml;
@Autowired
private ChangeService changeService;
public MigrationService() { public MigrationService() {
} }
...@@ -47,8 +54,6 @@ public class MigrationService { ...@@ -47,8 +54,6 @@ public class MigrationService {
MigrationResultWrapper migrationResultWrapper = new MigrationResultWrapper(); MigrationResultWrapper migrationResultWrapper = new MigrationResultWrapper();
List<FlowChangeWrapper> result = new ArrayList<>(); List<FlowChangeWrapper> result = new ArrayList<>();
//oldDSL.getVariables().get(0).
// 1. Schritt: Prüfen, ob in einem Flow neue Elemente hinzugekommen sind // 1. Schritt: Prüfen, ob in einem Flow neue Elemente hinzugekommen sind
List<FlowChangeWrapper> activityAddActionResults = detectActivityAddActions(oldDSL.getFlows(), newDSL.getFlows()); List<FlowChangeWrapper> activityAddActionResults = detectActivityAddActions(oldDSL.getFlows(), newDSL.getFlows());
transferResultsToCorrespondingCategory(migrationResultWrapper, activityAddActionResults); transferResultsToCorrespondingCategory(migrationResultWrapper, activityAddActionResults);
...@@ -64,10 +69,20 @@ public class MigrationService { ...@@ -64,10 +69,20 @@ public class MigrationService {
private List<FlowChangeWrapper> detectActivityAddActions(List<Flow> oldFlows, List<Flow> newFlows) { private List<FlowChangeWrapper> detectActivityAddActions(List<Flow> oldFlows, List<Flow> newFlows) {
List<FlowChangeWrapper> result = new ArrayList<>(); List<FlowChangeWrapper> result = new ArrayList<>();
//Flow Matching
Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows);
for(int i=0; i < matchingFlows.length; i++) {
result.addAll(compareFlowsForAddAction(matchingFlows[i][1], matchingFlows[i][0]));
}
//Flows miteinander vergleichen //Flows miteinander vergleichen
/*
for(int i=0; i < oldFlows.size(); i++) { for(int i=0; i < oldFlows.size(); i++) {
result.addAll(compareFlowsForAddAction(oldFlows.get(i), newFlows.get(i))); result.addAll(compareFlowsForAddAction(oldFlows.get(i), newFlows.get(i)));
} }
*/
return result; return result;
} }
...@@ -95,12 +110,22 @@ public class MigrationService { ...@@ -95,12 +110,22 @@ public class MigrationService {
for(FlowElementReference e : addedFlowElements) { for(FlowElementReference e : addedFlowElements) {
if(e.getRef() instanceof ManualTaskFlowElement) { if(e.getRef() instanceof ManualTaskFlowElement) {
result.add(new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_MANUAL_TASK, FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_MANUAL_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask())); 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) {
result.add(new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK, FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask())); 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();
...@@ -153,4 +178,24 @@ public class MigrationService { ...@@ -153,4 +178,24 @@ public class MigrationService {
return dto; return dto;
} }
private Integer loadGlobalPriority(MigrationResultStatus status, MigrationYaml yaml) {
Integer globalPriority = 0;
switch(status) {
case GREEN:
globalPriority = yaml.getConfiguration().getGreen();
break;
case YELLOW:
globalPriority = yaml.getConfiguration().getYellow();
break;
case RED:
globalPriority = yaml.getConfiguration().getRed();
break;
default:
globalPriority = yaml.getConfiguration().getGreen();
break;
}
return globalPriority;
}
} }
...@@ -4,8 +4,10 @@ import java.io.BufferedReader; ...@@ -4,8 +4,10 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -57,6 +59,8 @@ public class ChangeController { ...@@ -57,6 +59,8 @@ public class ChangeController {
private ChangeService changeService; private ChangeService changeService;
@Autowired @Autowired
private MigrationService migrationService; private MigrationService migrationService;
@Autowired
private TestService testService;
@RequestMapping(path = "/project/{projectId}/match", method = RequestMethod.GET) @RequestMapping(path = "/project/{projectId}/match", method = RequestMethod.GET)
public void getNewFlows(@PathVariable(required = true) Long projectId) { public void getNewFlows(@PathVariable(required = true) Long projectId) {
...@@ -91,10 +95,33 @@ public class ChangeController { ...@@ -91,10 +95,33 @@ public class ChangeController {
Project project = projectService.getProjectForId(projectId); Project project = projectService.getProjectForId(projectId);
MigrationResultWrapperDTO migrationResultWrapperDTO = new MigrationResultWrapperDTO(); MigrationResultWrapperDTO migrationResultWrapperDTO = new MigrationResultWrapperDTO();
//Alte und neue DSL einlesen
//Alte DSL kopieren und neu generieren
Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories()); Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
Path source = Paths.get(testFilePath.toString());
Path target = Paths.get(project.getProjectDirectories().getProjectRootPath().toString(),
project.getProjectDirectories().getModelPath(), this.projectService.getBackupFolderName(),
"Testcollection.bpmn-testgen");
try {
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
}
catch(Exception e) {
}
//Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
Path newDSLFile = Paths.get(testFilePath.toString()); Path newDSLFile = Paths.get(testFilePath.toString());
Path oldDSLFile = Paths.get(project.getProjectDirectories().resolveTestPath(), "Testcollection-old.bpmn-testgen"); //Path oldDSLFile = Paths.get(project.getProjectDirectories().resolveTestPath(), "Testcollection-old.bpmn-testgen");
Path oldDSLFile = Paths.get(project.getProjectDirectories().getProjectRootPath().toString(),
project.getProjectDirectories().getModelPath(), this.projectService.getBackupFolderName(),
"Testcollection.bpmn-testgen");
testService.initLoops(project);
testService.initTestcollection(project);
try { try {
TestgeneratorDSLSerializer oldDSL = new TestgeneratorDSLSerializer(oldDSLFile.toString()); TestgeneratorDSLSerializer oldDSL = new TestgeneratorDSLSerializer(oldDSLFile.toString());
TestgeneratorDSLSerializer newDSL = new TestgeneratorDSLSerializer(newDSLFile.toString()); TestgeneratorDSLSerializer newDSL = new TestgeneratorDSLSerializer(newDSLFile.toString());
......
...@@ -372,7 +372,9 @@ public class TestService { ...@@ -372,7 +372,9 @@ public class TestService {
} else if (flowElement instanceof ScriptTask) { } else if (flowElement instanceof ScriptTask) {
return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId()); return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId());
} else if (flowElement instanceof BusinessRuleTask) { } else if (flowElement instanceof BusinessRuleTask) {
return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId()); String resultVariable = BPMNParseUtils.getResultVariable((BusinessRuleTask) flowElement);
return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId(), resultVariable);
} else if (flowElement instanceof ServiceTask) { } else if (flowElement instanceof ServiceTask) {
String delegate = getDelegate((ServiceTask) flowElement); String delegate = getDelegate((ServiceTask) flowElement);
String externalTopicTextual = getExternalTopic((ServiceTask) flowElement); String externalTopicTextual = getExternalTopic((ServiceTask) flowElement);
......
...@@ -10,6 +10,7 @@ import java.util.stream.Collectors; ...@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.camunda.bpm.model.bpmn.BpmnModelInstance; import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
import org.camunda.bpm.model.bpmn.instance.ServiceTask; import org.camunda.bpm.model.bpmn.instance.ServiceTask;
import org.camunda.bpm.model.dmn.DmnModelInstance; import org.camunda.bpm.model.dmn.DmnModelInstance;
...@@ -223,6 +224,11 @@ public class BPMNParseUtils { ...@@ -223,6 +224,11 @@ public class BPMNParseUtils {
return externalTopic; return externalTopic;
} }
public static String getResultVariable(BusinessRuleTask businessRuleTask) {
String resultVariable = businessRuleTask.getAttributeValueNs(NAMESPACE_URI_BPMN, "resultVariable");
return resultVariable;
}
public static List<VariableDeclaration> getHardcodedVariables(String flowElementId, List<Variable> variables, public static List<VariableDeclaration> getHardcodedVariables(String flowElementId, List<Variable> variables,
BPMNIOParameters bpmnIOParameters) { BPMNIOParameters bpmnIOParameters) {
List<VariableDeclaration> hardcodedVariables = new ArrayList<>(); List<VariableDeclaration> hardcodedVariables = new ArrayList<>();
......
...@@ -26,5 +26,4 @@ activity: ...@@ -26,5 +26,4 @@ activity:
status: RED status: RED
priority: 0 priority: 0
manualTask: manualTask:
status: GREEN status: GREEN
priority: 0 \ No newline at end of file
\ No newline at end of file
...@@ -16,7 +16,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje ...@@ -16,7 +16,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje
import { LoopsComponent } from './components/loops/loops.component'; import { LoopsComponent } from './components/loops/loops.component';
import { LoopComponent } from './components/loop/loop.component'; import { LoopComponent } from './components/loop/loop.component';
import { UpdateProjectComponent } from './components/update-project/update-project.component'; import { UpdateProjectComponent } from './components/update-project/update-project.component';
import { MigrationOverviewComponent } from './migration-overview/migration-overview.component'; import { MigrationOverviewComponent } from './components/migration-overview/migration-overview.component';
const routes: Routes = [ const routes: Routes = [
......
...@@ -30,7 +30,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje ...@@ -30,7 +30,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje
import { LoopsComponent } from './components/loops/loops.component'; import { LoopsComponent } from './components/loops/loops.component';
import { LoopComponent } from './components/loop/loop.component'; import { LoopComponent } from './components/loop/loop.component';
import { UpdateProjectComponent } from './components/update-project/update-project.component'; import { UpdateProjectComponent } from './components/update-project/update-project.component';
import { MigrationOverviewComponent } from './migration-overview/migration-overview.component'; import { MigrationOverviewComponent } from './components/migration-overview/migration-overview.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { MigrationResultWrapper } from '../models/migration-result-wrapper'; import { MigrationResultWrapper } from '../../models/migration-result-wrapper';
import { MigrationService } from '../services/migration-service'; import { MigrationService } from '../../services/migration-service';
@Component({ @Component({
selector: 'app-migration-overview', selector: 'app-migration-overview',
......
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