From efa41dd733bc7f2e1b86de943cc0a63ab9cabc24 Mon Sep 17 00:00:00 2001 From: Florian Lambers <fl462057@fh-muenster.de> Date: Tue, 9 Nov 2021 15:16:44 +0100 Subject: [PATCH] added global migration priority --- .../migration/FlowChangeWrapper.java | 2 +- .../migration/MigrationService.java | 39 +++++++++++++++++-- .../src/main/resources/migration.yaml | 3 +- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/FlowChangeWrapper.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/FlowChangeWrapper.java index 43f943a..49ec449 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/FlowChangeWrapper.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/FlowChangeWrapper.java @@ -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); diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java index 70a08eb..d48a93f 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java @@ -12,6 +12,7 @@ import org.eclipse.emf.common.util.EList; import org.springframework.stereotype.Service; import de.fhmuenster.masterthesis.Testgenerator.rest.dto.MigrationResultWrapperDTO; +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; @@ -95,12 +96,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 +164,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; + } } diff --git a/Testgenerator/src/main/resources/migration.yaml b/Testgenerator/src/main/resources/migration.yaml index 8781b0b..55fe010 100644 --- a/Testgenerator/src/main/resources/migration.yaml +++ b/Testgenerator/src/main/resources/migration.yaml @@ -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 -- GitLab