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 {
dto.setFlowElement(flowElementDTO);
MigrationResultDTO migrationResultDTO = new MigrationResultDTO();
migrationResultDTO.setPriority(this.getMigrationResult().getPriority());
migrationResultDTO.setPriority(this.getMigrationResult().getPriority());
migrationResultDTO.setStatus(this.getMigrationResult().getStatus().name());
dto.setMigrationResult(migrationResultDTO);
......
......@@ -9,9 +9,13 @@ import javax.annotation.PostConstruct;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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.YamlReader;
import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
......@@ -33,6 +37,9 @@ public class MigrationService {
private MigrationYaml yaml;
@Autowired
private ChangeService changeService;
public MigrationService() {
}
......@@ -47,8 +54,6 @@ public class MigrationService {
MigrationResultWrapper migrationResultWrapper = new MigrationResultWrapper();
List<FlowChangeWrapper> result = new ArrayList<>();
//oldDSL.getVariables().get(0).
// 1. Schritt: Prüfen, ob in einem Flow neue Elemente hinzugekommen sind
List<FlowChangeWrapper> activityAddActionResults = detectActivityAddActions(oldDSL.getFlows(), newDSL.getFlows());
transferResultsToCorrespondingCategory(migrationResultWrapper, activityAddActionResults);
......@@ -64,10 +69,20 @@ public class MigrationService {
private List<FlowChangeWrapper> detectActivityAddActions(List<Flow> oldFlows, List<Flow> newFlows) {
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
/*
for(int i=0; i < oldFlows.size(); i++) {
result.addAll(compareFlowsForAddAction(oldFlows.get(i), newFlows.get(i)));
}
*/
return result;
}
......@@ -95,12 +110,22 @@ public class MigrationService {
for(FlowElementReference e : addedFlowElements) {
if(e.getRef() instanceof ManualTaskFlowElement) {
result.add(new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_MANUAL_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask()));
FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_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);
}
if(e.getRef() instanceof UserTaskFlowElement) {
result.add(new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask()));
FlowChangeWrapper fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK,
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) {
BusinessRuleTaskFlowElement element = (BusinessRuleTaskFlowElement) e.getRef();
......@@ -153,4 +178,24 @@ public class MigrationService {
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;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -57,6 +59,8 @@ public class ChangeController {
private ChangeService changeService;
@Autowired
private MigrationService migrationService;
@Autowired
private TestService testService;
@RequestMapping(path = "/project/{projectId}/match", method = RequestMethod.GET)
public void getNewFlows(@PathVariable(required = true) Long projectId) {
......@@ -91,10 +95,33 @@ public class ChangeController {
Project project = projectService.getProjectForId(projectId);
MigrationResultWrapperDTO migrationResultWrapperDTO = new MigrationResultWrapperDTO();
//Alte und neue DSL einlesen
//Alte DSL kopieren und neu generieren
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 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 {
TestgeneratorDSLSerializer oldDSL = new TestgeneratorDSLSerializer(oldDSLFile.toString());
TestgeneratorDSLSerializer newDSL = new TestgeneratorDSLSerializer(newDSLFile.toString());
......
......@@ -372,7 +372,9 @@ public class TestService {
} else if (flowElement instanceof ScriptTask) {
return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId());
} 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) {
String delegate = getDelegate((ServiceTask) flowElement);
String externalTopicTextual = getExternalTopic((ServiceTask) flowElement);
......
......@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
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.dmn.DmnModelInstance;
......@@ -223,6 +224,11 @@ public class BPMNParseUtils {
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,
BPMNIOParameters bpmnIOParameters) {
List<VariableDeclaration> hardcodedVariables = new ArrayList<>();
......
......@@ -26,5 +26,4 @@ activity:
status: RED
priority: 0
manualTask:
status: GREEN
priority: 0
\ No newline at end of file
status: GREEN
\ No newline at end of file
......@@ -16,7 +16,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje
import { LoopsComponent } from './components/loops/loops.component';
import { LoopComponent } from './components/loop/loop.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 = [
......
......@@ -30,7 +30,7 @@ import { DeleteProjectComponent } from './components/delete-project/delete-proje
import { LoopsComponent } from './components/loops/loops.component';
import { LoopComponent } from './components/loop/loop.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({
declarations: [
......
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MigrationResultWrapper } from '../models/migration-result-wrapper';
import { MigrationService } from '../services/migration-service';
import { MigrationResultWrapper } from '../../models/migration-result-wrapper';
import { MigrationService } from '../../services/migration-service';
@Component({
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