From 1ed25befc94435fc0a2081f4d4ebfba85bcd44a5 Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Fri, 24 Nov 2023 10:40:10 +0100 Subject: [PATCH] Temporarily revert CML rule for coordination between services of different contexts (moved to feature branch) This reverts commit cc42f8d7795a4add111081c83c70a27a8c324152. --- .gitignore | 2 - .../SketchMinerGeneratorCommandTest.xtend | 29 -- ...rdinationInBPMNSketchMinerActionTest.xtend | 54 ---- .../dsl/ide/actions/CMLActionRegistry.java | 3 - ...oordinationInSketchMinerCommandMapper.java | 44 --- .../sketchminer/link-integ-test2.cml | 45 --- .../no-coordination-existing-test-1.cml | 2 - .../simple-coordination-test-1.cml | 28 -- .../simple-coordination-test-2.cml | 41 --- .../dsl/ApplicationLayerDSLParsingTest.xtend | 140 --------- .../dsl/ApplicationLayerValidationTest.xtend | 267 ------------------ .../dsl/UniquenessValidatorTest.xtend | 46 --- ...etchMinerCoordinationModelCreatorTest.java | 68 ----- .../sketchminer/SketchMinerGeneratorTest.java | 26 -- .../SketchMinerLinkCreatorTest.java | 33 --- .../ContextMappingDSLQuickfixProvider.xtend | 9 - .../contextmapper/dsl/ContextMappingDSL.xtext | 13 +- .../dsl/GenerateContextMappingDSL.mwe2 | 3 +- .../cml/CMLModelObjectsResolvingHelper.java | 51 ---- .../ContextMappingDSLFormatter.xtend | 28 -- .../dsl/generator/SketchMinerGenerator.java | 19 +- .../SketchMinerCoordinationModelCreator.java | 49 ---- .../sketchminer/SketchMinerLinkCreator.java | 17 +- .../Coordination2SketchMinerConverter.java | 92 ------ .../converter/SimplifiedCoordinationStep.java | 32 --- .../dsl/scoping/CMLScopingHelper.java | 2 +- .../ContextMappingDSLScopeProvider.xtend | 1 + ...icationCoordinationSemanticsValidator.java | 141 --------- .../dsl/validation/UniquenessValidator.java | 14 - .../dsl/validation/ValidationMessages.java | 9 +- 30 files changed, 12 insertions(+), 1296 deletions(-) delete mode 100644 org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/quickfixes/OpenCoordinationInBPMNSketchMinerActionTest.xtend delete mode 100644 org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/quickfix/impl/OpenCoordinationInSketchMinerCommandMapper.java delete mode 100644 org.contextmapper.dsl.tests/integ-test-files/sketchminer/link-integ-test2.cml delete mode 100644 org.contextmapper.dsl.tests/integ-test-files/sketchminer/no-coordination-existing-test-1.cml delete mode 100644 org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-1.cml delete mode 100644 org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-2.cml delete mode 100644 org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerCoordinationModelCreatorTest.java delete mode 100644 org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerCoordinationModelCreator.java delete mode 100644 org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/Coordination2SketchMinerConverter.java delete mode 100644 org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/SimplifiedCoordinationStep.java delete mode 100644 org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ApplicationCoordinationSemanticsValidator.java diff --git a/.gitignore b/.gitignore index 2fb3aa58..62675a88 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,3 @@ plugin.xml_gen .gradle/ build/ -# MacOS -.DS_Store diff --git a/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/commands/generation/SketchMinerGeneratorCommandTest.xtend b/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/commands/generation/SketchMinerGeneratorCommandTest.xtend index 804997e6..411627ac 100644 --- a/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/commands/generation/SketchMinerGeneratorCommandTest.xtend +++ b/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/commands/generation/SketchMinerGeneratorCommandTest.xtend @@ -64,34 +64,5 @@ class SketchMinerGeneratorCommandTest extends AbstractCMLCommandTest { srcGenFolder.exists.assertTrue new File(srcGenFolder, "test_BC_TestContext_TestFlow.sketch_miner").exists.assertTrue } - - @Test - def void testSketchMinerGeneratorCommandExecutionOnCoordination() { - // given - initializeCommandsDynamically() - val model = ''' - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::TestService::testOperation; - } - Service TestService { - testOperation; - } - } - } - ''' - val fileURI = 'test.cml'.writeFile(model) - - // when - val result = languageServer.executeCommand( - new ExecuteCommandParams("cml.generate.sketchminer", #[new JsonPrimitive(fileURI)])) - val resultVal = result.get as String - - // then - CMLCommandService.COMMAND_EXECUTED_RETURN_VALUE.assertEquals(resultVal) - srcGenFolder.exists.assertTrue - new File(srcGenFolder, "coordinations/test_BC_ContextA_TestCoordination.sketch_miner").exists.assertTrue - } } diff --git a/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/quickfixes/OpenCoordinationInBPMNSketchMinerActionTest.xtend b/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/quickfixes/OpenCoordinationInBPMNSketchMinerActionTest.xtend deleted file mode 100644 index 9920ce2e..00000000 --- a/org.contextmapper.dsl.ide.tests/src/org/contextmapper/dsl/ide/tests/quickfixes/OpenCoordinationInBPMNSketchMinerActionTest.xtend +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.ide.tests.quickfixes - -import org.contextmapper.dsl.ide.tests.commands.AbstractCMLCommandTest -import org.junit.jupiter.api.Test - -class OpenCoordinationInBPMNSketchMinerActionTest extends AbstractCMLCommandTest { - - @Test - def void canOfferCodeAction() { - testCodeAction [ - model = ''' - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::TestService::testOperation; - } - Service TestService { - testOperation; - } - } - } - ''' - expectedCodeActions = ''' - title : Open coordination in BPMN Sketch Miner - kind : quickfix - command : Command [ - title = "Open coordination in BPMN Sketch Miner" - command = "cml.coordination.open.sketch.miner" - arguments = LinkedList ( - "https://www.bpmn-sketch-miner.ai/index.html#EYBwNgdgXAbgjAKALRIQYQPYQC4FMAe2AglAggM64BOMAlgMa4AEAKrudgMrV2MB0eDgHkQ1AIbZaWMkA" - ) - ] - codes : open-coordination-in-sketch-miner - edit : - ''' - ] - } - -} diff --git a/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/actions/CMLActionRegistry.java b/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/actions/CMLActionRegistry.java index 3c49536e..8b8945b8 100644 --- a/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/actions/CMLActionRegistry.java +++ b/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/actions/CMLActionRegistry.java @@ -42,14 +42,12 @@ import org.contextmapper.dsl.ide.actions.impl.SwitchFromSharedKernelToPartnershipAction; import org.contextmapper.dsl.ide.edit.WorkspaceEditRecorder; import org.contextmapper.dsl.ide.quickfix.QuickfixCommandMapper; -import org.contextmapper.dsl.ide.quickfix.impl.OpenCoordinationInSketchMinerCommandMapper; import org.contextmapper.dsl.ide.quickfix.impl.OpenFlowInSketchMinerCommandMapper; import org.contextmapper.dsl.ide.quickfix.impl.SplitStoryByVerbCommandMapper; import org.contextmapper.dsl.quickfixes.CMLQuickFix; import org.contextmapper.dsl.quickfixes.CreateMissingBoundedContextQuickFix; import org.contextmapper.dsl.quickfixes.SplitStoryByVerb; import org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix; -import org.contextmapper.dsl.validation.ApplicationCoordinationSemanticsValidator; import org.contextmapper.dsl.validation.ApplicationFlowSemanticsValidator; import org.contextmapper.dsl.validation.DomainObjectValidator; import org.contextmapper.dsl.validation.UserRequirementsValidator; @@ -121,7 +119,6 @@ private void registerAllQuickFixes() { registerActionQuickFix(DomainObjectValidator.ID_IS_PRIMITIVE_CODE, new ExtractIDValueObjectQuickFix()); registerCommandQuickFix(UserRequirementsValidator.ID_SPLIT_FEATURE_BY_VERB_SUGGESTION, new SplitStoryByVerbCommandMapper(new SplitStoryByVerb())); registerCommandQuickFix(ApplicationFlowSemanticsValidator.SKETCH_MINER_INFO_ID, new OpenFlowInSketchMinerCommandMapper()); - registerCommandQuickFix(ApplicationCoordinationSemanticsValidator.SKETCH_MINER_INFO_ID, new OpenCoordinationInSketchMinerCommandMapper()); } public List getApplicableActionCommands(CMLResource resource, List selectedObjects) { diff --git a/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/quickfix/impl/OpenCoordinationInSketchMinerCommandMapper.java b/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/quickfix/impl/OpenCoordinationInSketchMinerCommandMapper.java deleted file mode 100644 index a9b263f6..00000000 --- a/org.contextmapper.dsl.ide/src/org/contextmapper/dsl/ide/quickfix/impl/OpenCoordinationInSketchMinerCommandMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.ide.quickfix.impl; - -import java.util.Arrays; - -import org.contextmapper.dsl.cml.CMLResource; -import org.contextmapper.dsl.contextMappingDSL.Coordination; -import org.contextmapper.dsl.generator.sketchminer.SketchMinerLinkCreator; -import org.contextmapper.dsl.ide.quickfix.QuickfixCommandMapper; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.lsp4j.CodeAction; -import org.eclipse.lsp4j.CodeActionKind; -import org.eclipse.lsp4j.Command; - -import com.google.common.collect.Lists; - -public class OpenCoordinationInSketchMinerCommandMapper implements QuickfixCommandMapper { - - @Override - public CodeAction getCodeAction(CMLResource cmlResource, EObject selectedObject) { - Coordination coordination = (Coordination) selectedObject; - CodeAction action = new CodeAction("Open coordination in BPMN Sketch Miner"); - action.setKind(CodeActionKind.QuickFix); - Command command = new Command("Open coordination in BPMN Sketch Miner", "cml.coordination.open.sketch.miner"); - command.setArguments(Lists.newLinkedList(Arrays.asList(new String[] { new SketchMinerLinkCreator().createSketchMinerLink(coordination) }))); - action.setCommand(command); - return action; - } - -} diff --git a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/link-integ-test2.cml b/org.contextmapper.dsl.tests/integ-test-files/sketchminer/link-integ-test2.cml deleted file mode 100644 index f96e7c1c..00000000 --- a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/link-integ-test2.cml +++ /dev/null @@ -1,45 +0,0 @@ -ContextMap InsuranceMap { - contains UserContext - contains InsuranceQuotes - - InsuranceQuotes <- UserContext -} - -BoundedContext UserContext { - - Application { - Service UserService { - void submitRequest(@Request request); - } - } -} - -BoundedContext InsuranceQuotes { - - Application { - Coordination QuoteRequestAcceptedCoordination { - UserContext::UserService::submitRequest; - InsuranceQuotes::QuoteRequestService::checkRequest; - InsuranceQuotes::QuoteRequestService::receiveAndCheckQuote; - InsuranceQuotes::QuoteRequestService::accept; - } - - Service QuoteRequestService { - void checkRequest(@Request request); - void receiveAndCheckQuote(@Request request); - void reject(@Request request); - void accept(@Request request); - } - } - - Aggregate QuoteRequest { - Entity Request { - aggregateRoot - } - - enum RequestState { - aggregateLifecycle - SUBMITTED, RECEIVED, REJECTED, ACCEPTED, EXPIRED, POLICY_CREATED - } - } -} \ No newline at end of file diff --git a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/no-coordination-existing-test-1.cml b/org.contextmapper.dsl.tests/integ-test-files/sketchminer/no-coordination-existing-test-1.cml deleted file mode 100644 index 0663efab..00000000 --- a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/no-coordination-existing-test-1.cml +++ /dev/null @@ -1,2 +0,0 @@ - -BoundedContext EmptyContext // ignored diff --git a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-1.cml b/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-1.cml deleted file mode 100644 index d2994f58..00000000 --- a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-1.cml +++ /dev/null @@ -1,28 +0,0 @@ - -ContextMap TestMap { - contains ContextA - contains ContextB - - ContextA <- ContextB -} - -BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::ServiceA::operationA; - ContextB::ServiceB::operationB; - } - Service ServiceA { - operationA; - } - } -} - -BoundedContext ContextB { - Application { - Service ServiceB { - operationB; - } - } -} - diff --git a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-2.cml b/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-2.cml deleted file mode 100644 index 3a820636..00000000 --- a/org.contextmapper.dsl.tests/integ-test-files/sketchminer/simple-coordination-test-2.cml +++ /dev/null @@ -1,41 +0,0 @@ - -ContextMap TestMap { - contains ContextA - contains ContextB - contains ContextC - - ContextA <- ContextB - ContextA <- ContextC -} - -BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::ServiceA::operationA1; - ContextB::ServiceB::operationB; - ContextA::ServiceA::operationA2; - ContextC::ServiceC::operationC; - } - Service ServiceA { - operationA1; - operationA2; - } - } -} - -BoundedContext ContextB { - Application { - Service ServiceB { - operationB; - } - } -} - -BoundedContext ContextC { - Application { - Service ServiceC { - operationC; - } - } -} - diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerDSLParsingTest.xtend b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerDSLParsingTest.xtend index 094833cd..53c2291e 100644 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerDSLParsingTest.xtend +++ b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerDSLParsingTest.xtend @@ -973,144 +973,4 @@ class ApplicationLayerDSLParsingTest { assertFalse(flowStep.stateTransition.target.to.get(1).isEndState); } - @Test - def void canDefineCoordination() { - // given - val String dslSnippet = ''' - BoundedContext TestContext { - Application { - Coordination TestCoordination { - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - assertThatNoValidationErrorsOccurred(result); - assertEquals(1, result.boundedContexts.get(0).application.coordinations.size); - assertEquals("TestCoordination", result.boundedContexts.get(0).application.coordinations.get(0).name); - } - - @Test - def void canDefineCoordinationStep() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::TestService::testOperation; - } - - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - assertThatNoValidationErrorsOccurred(result); - assertEquals(1, result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.size); - assertEquals("TestContext", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(0).boundedContext.name); - assertEquals("TestService", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(0).service.name); - assertEquals("testOperation", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(0).operation.name); - } - - @Test - def void canDefineCoordinationStepReferencingUpstreamContext() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains ContextA - contains ContextB - - ContextA <- ContextB - } - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::ServiceA::operationA; - ContextB::ServiceB::operationB; - } - - Service ServiceA { - operationA; - } - } - } - BoundedContext ContextB { - Application { - Service ServiceB { - operationB; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - assertThatNoValidationErrorsOccurred(result); - assertEquals(2, result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.size); - assertEquals("ContextB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).boundedContext.name); - assertEquals("ServiceB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).service.name); - assertEquals("operationB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).operation.name); - } - - @Test - def void canDefineCoordinationStepReferencingContextInSymetricRelationship() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains ContextA - contains ContextB - - ContextA <-> ContextB - } - BoundedContext ContextA { - Application { - Coordination CoordinationA { - ContextA::ServiceA::operationA; - ContextB::ServiceB::operationB; - } - - Service ServiceA { - operationA; - } - } - } - BoundedContext ContextB { - Application { - Coordination CoordinationB { - ContextB::ServiceB::operationB; - ContextA::ServiceA::operationA; - } - - Service ServiceB { - operationB; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - assertThatNoValidationErrorsOccurred(result); - assertEquals(2, result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.size); - assertEquals("ContextB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).boundedContext.name); - assertEquals("ServiceB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).service.name); - assertEquals("operationB", result.boundedContexts.get(0).application.coordinations.get(0).coordinationSteps.get(1).operation.name); - assertEquals(2, result.boundedContexts.get(1).application.coordinations.get(0).coordinationSteps.size); - assertEquals("ContextA", result.boundedContexts.get(1).application.coordinations.get(0).coordinationSteps.get(1).boundedContext.name); - assertEquals("ServiceA", result.boundedContexts.get(1).application.coordinations.get(0).coordinationSteps.get(1).service.name); - assertEquals("operationA", result.boundedContexts.get(1).application.coordinations.get(0).coordinationSteps.get(1).operation.name); - } } diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerValidationTest.xtend b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerValidationTest.xtend index 540f7353..08c237d2 100644 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerValidationTest.xtend +++ b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/ApplicationLayerValidationTest.xtend @@ -31,11 +31,6 @@ import org.junit.jupiter.api.^extension.ExtendWith import static org.contextmapper.dsl.util.ParsingErrorAssertions.* import static org.contextmapper.dsl.validation.ValidationMessages.* -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_CONTEXT_NOT_ON_MAP -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_OPERATION_NOT_ON_STEP_SERVICE -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_OPERATION_IS_AMBIGUOUS -import org.contextmapper.dsl.validation.ApplicationCoordinationSemanticsValidator @ExtendWith(InjectionExtension) @InjectWith(ContextMappingDSLInjectorProvider) @@ -258,266 +253,4 @@ class ApplicationLayerValidationTest { ApplicationFlowSemanticsValidator.SKETCH_MINER_INFO_ID, Severity.INFO, VISUALIZE_FLOW_WITH_SKETCH_MINER); } - @Test - def void coordinationStepCannotReferenceContextWithoutContextMap() { - // given - val String dslSnippet = ''' - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextB::TestService::testOperation; - } - } - } - BoundedContext ContextB { - Application { - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP , "", - String.format(COORDINATION_STEP_CONTEXT_NOT_REACHABLE, "ContextB")); - } - - @Test - def void coordinationStepCannotReferenceContextWithoutUpstreamRelationships() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains ContextA - contains ContextB - } - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextB::TestService::testOperation; - } - } - } - BoundedContext ContextB { - Application { - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP , "", - String.format(COORDINATION_STEP_CONTEXT_NOT_REACHABLE, "ContextB")); - } - - @Test - def void coordinationStepCannotReferenceContextWithoutRespectiveUpstreamRelationship() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains ContextA - contains ContextB - contains ContextC - - ContextA <- ContextC - } - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextB::TestService::testOperation; - } - } - } - BoundedContext ContextB { - Application { - Service TestService { - testOperation; - } - } - } - BoundedContext ContextC - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP , "", - String.format(COORDINATION_STEP_CONTEXT_NOT_REACHABLE, "ContextB")); - } - - @Test - def void coordinationStepCannotReferenceDomainService() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::TestService::testOperation; - } - } - - Aggregate TestAggregate { - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP, "", - String.format(COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION, "TestService", "TestContext")); - } - - @Test - def void coordinationStepCannotReferenceBoundedContextService() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::TestService::testOperation; - } - } - - Service TestService { - testOperation; - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP, "", - String.format(COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION, "TestService", "TestContext")); - } - - @Test - def void coordinationStepCannotReferenceServiceOutOfStepContext() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains ContextA - contains ContextB - } - BoundedContext ContextA { - Application { - Coordination TestCoordination { - ContextA::TestService::testOperation; - } - } - } - BoundedContext ContextB { - Application { - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP, "", - String.format(COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION, "TestService", "ContextA")); - } - - @Test - def void coordinationStepCannotReferenceOperationOutOfStepService() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::ServiceA::operationB; - } - Service ServiceA { - operationA; - } - Service ServiceB { - operationB; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP, "", - String.format(COORDINATION_STEP_OPERATION_NOT_ON_STEP_SERVICE, "operationB", "ServiceA", "TestContext")); - } - - @Test - def void coordinationStepWarnsIfOperationReferenceIsNotUniqueInStepService() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::TestService::testOperation; - } - Service TestService { - testOperation; - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertWarning(result, ContextMappingDSLPackage.Literals.COORDINATION_STEP, "", - String.format(COORDINATION_STEP_OPERATION_IS_AMBIGUOUS, "testOperation", "TestService")); - } - - @Test - def void canOfferSketchMinerLinkInCoordination() { - // given - val String dslSnippet = ''' - ContextMap TestMap { - contains TestContext - } - BoundedContext TestContext { - Application { - Coordination TestCoordination { - TestContext::TestService::testOperation; - } - Service TestService { - testOperation; - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertIssue(result, ContextMappingDSLPackage.Literals.COORDINATION, - ApplicationCoordinationSemanticsValidator.SKETCH_MINER_INFO_ID, Severity.INFO, VISUALIZE_COORDINATION_WITH_SKETCH_MINER); - } - } diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/UniquenessValidatorTest.xtend b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/UniquenessValidatorTest.xtend index 662c418e..f5bcab3e 100644 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/UniquenessValidatorTest.xtend +++ b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/UniquenessValidatorTest.xtend @@ -292,51 +292,5 @@ class UniquenessValidatorTest { validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.FLOW, "", String.format(FLOW_NAME_NOT_UNIQUE, "TestFlow")); } - - @Test - def void cannotDefineDuplicateCoordinationInSameContext() { - // given - val String dslSnippet = ''' - BoundedContext TestContext { - Application { - Coordination TestCoordination { - } - Coordination TestCoordination { - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION, "", - String.format(COORDINATION_NAME_NOT_UNIQUE, "TestCoordination")); - } - - @Test - def void cannotDefineDuplicateCoordinationInDifferentContexts() { - // given - val String dslSnippet = ''' - BoundedContext ContextA { - Application { - Coordination TestCoordination { - } - } - } - BoundedContext ContextB { - Application { - Coordination TestCoordination { - } - } - } - '''; - // when - val ContextMappingModel result = parseHelper.parse(dslSnippet); - // then - assertThatNoParsingErrorsOccurred(result); - validationTestHelper.assertError(result, ContextMappingDSLPackage.Literals.COORDINATION, "", - String.format(COORDINATION_NAME_NOT_UNIQUE, "TestCoordination")); - } } diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerCoordinationModelCreatorTest.java b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerCoordinationModelCreatorTest.java deleted file mode 100644 index be737f84..00000000 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerCoordinationModelCreatorTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.generators.sketchminer; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.io.IOException; - -import org.contextmapper.dsl.AbstractCMLInputFileTest; -import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; -import org.contextmapper.dsl.contextMappingDSL.Coordination; -import org.contextmapper.dsl.generator.sketchminer.SketchMinerCoordinationModelCreator; -import org.eclipse.xtext.EcoreUtil2; -import org.junit.jupiter.api.Test; - -public class SketchMinerCoordinationModelCreatorTest extends AbstractCMLInputFileTest { - - @Test - public void canGenerateSimpleSequenceWithTwoActors() throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML("simple-coordination-test-1.cml").getContextMappingModel(); - Coordination coordination = EcoreUtil2.eAllOfType(model, Coordination.class).get(0); - - // when - String output = new SketchMinerCoordinationModelCreator().createText(coordination); - - // then - assertEquals("ContextA: service ServiceA.operationA" + System.lineSeparator() + - "ContextB: service ServiceB.operationB" + System.lineSeparator() + - System.lineSeparator(), output); - } - - @Test - public void canGenerateSimpleSequenceWithThreeActors() throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML("simple-coordination-test-2.cml").getContextMappingModel(); - Coordination coordination = EcoreUtil2.eAllOfType(model, Coordination.class).get(0); - - // when - String output = new SketchMinerCoordinationModelCreator().createText(coordination); - - // then - assertEquals("ContextA: service ServiceA.operationA1" + System.lineSeparator() + - "ContextB: service ServiceB.operationB" + System.lineSeparator() + - "ContextA: service ServiceA.operationA2" + System.lineSeparator() + - "ContextC: service ServiceC.operationC" + System.lineSeparator() + - System.lineSeparator(), output); - } - - @Override - protected String getTestFileDirectory() { - return "/integ-test-files/sketchminer/"; - } - -} diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerGeneratorTest.java b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerGeneratorTest.java index 7510a2f9..1067ccdc 100644 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerGeneratorTest.java +++ b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerGeneratorTest.java @@ -67,32 +67,6 @@ public void cannotGenerateFileIfNoFlowExists() throws IOException { this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock()); }); } - - @ParameterizedTest - @ValueSource(strings = { "simple-coordination-test-1" }) - public void canGenerateFilesForBoundedContextCoordinations(String inputFileName) throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML(inputFileName + ".cml").getContextMappingModel(); - - // when - IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock(); - this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock()); - - // then - assertTrue(filesystem.getGeneratedFilesSet().contains("coordinations/testmodel_BC_ContextA_TestCoordination.sketch_miner")); - } - - @Test - public void cannotGenerateFileIfNoCoordinationExists() throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML("no-coordination-existing-test-1.cml").getContextMappingModel(); - - // when, then - assertThrows(ContextMapperApplicationException.class, () -> { - IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock(); - this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock()); - }); - } @Override protected String getTestFileDirectory() { diff --git a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerLinkCreatorTest.java b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerLinkCreatorTest.java index df5d2152..9428e1ad 100644 --- a/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerLinkCreatorTest.java +++ b/org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/sketchminer/SketchMinerLinkCreatorTest.java @@ -22,7 +22,6 @@ import org.contextmapper.dsl.AbstractCMLInputFileTest; import org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory; import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; -import org.contextmapper.dsl.contextMappingDSL.Coordination; import org.contextmapper.dsl.contextMappingDSL.Flow; import org.contextmapper.dsl.generator.sketchminer.SketchMinerLinkCreator; import org.eclipse.emf.ecore.EObject; @@ -96,38 +95,6 @@ public void canCreateSketchMinerLinkWithEObjectWin() throws IOException { "https://www.bpmn-sketch-miner.ai/index.html#EYBwNgdgXAbgjAWAFAFoXIJIQM4FcBOAhhAMYCmAirgPYAuZ2ABAIIjgCWJht710yyAPSDGVOmQBKZAI64GtRgG1GKAHyMAygFUAQgFkMAFUMBRACIBdZNjL4YnMptzAAtu1pTZ85AApPc7FoNZzdaegATAEohETF6f3klbX0jUzMVdQkTAGETDAA1c0YADUYsgCkctKskGzsHRhIACzISAGsEwN84yVaydhgyKJjRGniZAIVFLNyCorUyk0rstJKWbNyABVXSk2LNjCzLa1t7ckZ8PoGyZghw7Jb2nu6x3oArVojopBGezqmMppdAZjOYanUzo5gq53P9fP9oaEvr9Xv8ksDUvNMjk8oV0qUKlUwSd6udmq0OhNvEg-FTAlIPiRkT8kMJRuI0coFskQdUSZCnDCPHTaPCRYj3My2X8ReiUqD0gsZriigSlkTjrVTg1ye04TSZeRrsNWbFUbLpji5orscsdustva9gcjuDtedLkbBrd7o82s8Da9mCRyCApWaORbmBsTNssYxNgB5AAyGGyAE0APrZLLMJ37Q7ErWkxyEENkMMvcQmAAeIHYlxNKMjXkCSkBPMxmohDQlwtboppCJCkqG32l5oHct58eV1rWhJWRZ7ZL9+p8hv6gxNE5bkyUc7xgMX9ujjtVjGdhe77scnq3NzuDwpAY3QfLYbHzfGU8UZ9jqwLEmqYZtmub5i6y63owZahoOPibNQYCcAAntklzcF+LK7j++5cuonYKm6JaCqE67DkK4bsrhiSKIRgHYrMR5qnaUEkbqlIDlW4xelhOG9L+h6zuqS74g6AEXlerr8g097XD6z5PK83FkLW9aNt8yBAA", link); } - - @Test - @DisabledOnOs(OS.WINDOWS) - public void canCreateSketchMinerLinkForCoordinationModelUnix() throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML("link-integ-test2.cml").getContextMappingModel(); - Coordination coordination = EcoreUtil2.eAllOfType(model, Coordination.class).get(0); - - // when - String link = new SketchMinerLinkCreator().createSketchMinerLink(coordination); - - // then - assertEquals( - "https://www.bpmn-sketch-miner.ai/index.html#EYBwNgdgXAbgjAKALRIQVQM4FMBOBhAewgBcsAPYqAAmxxgEsBjLKzXAZVweYDoMBXYAFt6xAEpYAjvywZiCAJIQBOAIYRmARX4FSGarW4tturBOmzinOkyw9GACyyMA1uZlzFy-mo1YTegZctlQBZlIeVsG8OM5Y9DBYAIIQACZ4Tq5hXirqWjqBNNHGBeEWctZGPKqMzCDyCEA", - link); - } - - @Test - @DisabledOnOs(OS.WINDOWS) - public void canCreateSketchMinerLinkWithCoordinationEObjectUnix() throws IOException { - // given - ContextMappingModel model = getOriginalResourceOfTestCML("link-integ-test2.cml").getContextMappingModel(); - EObject coordination = EcoreUtil2.eAllOfType(model, Coordination.class).get(0); - - // when - String link = new SketchMinerLinkCreator().createSketchMinerLink(coordination); - - // then - assertEquals( - "https://www.bpmn-sketch-miner.ai/index.html#EYBwNgdgXAbgjAKALRIQVQM4FMBOBhAewgBcsAPYqAAmxxgEsBjLKzXAZVweYDoMBXYAFt6xAEpYAjvywZiCAJIQBOAIYRmARX4FSGarW4tturBOmzinOkyw9GACyyMA1uZlzFy-mo1YTegZctlQBZlIeVsG8OM5Y9DBYAIIQACZ4Tq5hXirqWjqBNNHGBeEWctZGPKqMzCDyCEA", - link); - } @Test public void canReturnEmptyString4WrongObject() { diff --git a/org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/quickfix/ContextMappingDSLQuickfixProvider.xtend b/org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/quickfix/ContextMappingDSLQuickfixProvider.xtend index 61bd1de7..228be023 100644 --- a/org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/quickfix/ContextMappingDSLQuickfixProvider.xtend +++ b/org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/quickfix/ContextMappingDSLQuickfixProvider.xtend @@ -38,7 +38,6 @@ import org.eclipse.xtext.ui.editor.utils.EditorUtils import org.eclipse.xtext.validation.Issue import static org.contextmapper.dsl.quickfixes.CreateMissingBoundedContextQuickFix.LINK_DIAGNOSTIC_MESSAGE_PATTERN -import org.contextmapper.dsl.validation.ApplicationCoordinationSemanticsValidator /** * Custom quickfix registry. @@ -78,14 +77,6 @@ class ContextMappingDSLQuickfixProvider extends DefaultQuickfixProvider { Program.launch(new SketchMinerLinkCreator().createSketchMinerLink(element)); ]); } - - @Fix(ApplicationCoordinationSemanticsValidator.SKETCH_MINER_INFO_ID) - def openSketchMinerForCoordination(Issue issue, IssueResolutionAcceptor acceptor) { - acceptor.accept(issue, "Open coordination in BPMN Sketch Miner", "Open this coordination in BPMN Sketch Miner", - null, [ EObject element, IModificationContext context | - Program.launch(new SketchMinerLinkCreator().createSketchMinerLink(element)); - ]); - } def applyCMLQuickfix(Issue issue, IssueResolutionAcceptor acceptor, CMLQuickFix quickfix) { acceptor.accept(issue, quickfix.name, quickfix.description, diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/ContextMappingDSL.xtext b/org.contextmapper.dsl/src/org/contextmapper/dsl/ContextMappingDSL.xtext index c1354245..54625fc1 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/ContextMappingDSL.xtext +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/ContextMappingDSL.xtext @@ -202,21 +202,10 @@ Application: ((commands+=CommandEvent)* & (events+=DomainEvent)* & (services+=Service)* & - (flows+=Flow)* & - (coordinations+=Coordination)*) + (flows+=Flow)*) CLOSE)? ; -Coordination: - "Coordination" name=ID (OPEN - (coordinationSteps+=CoordinationStep)* - CLOSE)? -; - -CoordinationStep: - boundedContext=[BoundedContext] '::' service=[tacticdsl::Service] '::' operation=[tacticdsl::ServiceOperation] ';' -; - Flow: "Flow" name=ID (OPEN (steps+=FlowStep)* diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/GenerateContextMappingDSL.mwe2 b/org.contextmapper.dsl/src/org/contextmapper/dsl/GenerateContextMappingDSL.mwe2 index 2181faab..7dba7a5a 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/GenerateContextMappingDSL.mwe2 +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/GenerateContextMappingDSL.mwe2 @@ -132,7 +132,6 @@ Workflow { validator = { composedCheck = "org.contextmapper.dsl.validation.BoundedContextSemanticsValidator" composedCheck = "org.contextmapper.dsl.validation.ApplicationFlowSemanticsValidator" - composedCheck = "org.contextmapper.dsl.validation.ApplicationCoordinationSemanticsValidator" composedCheck = "org.contextmapper.dsl.validation.BoundedContextRelationshipSemanticsValidator" composedCheck = "org.contextmapper.dsl.validation.ContextMapSemanticsValidator" composedCheck = "org.contextmapper.dsl.validation.AggregateSemanticsValidator" @@ -144,7 +143,7 @@ Workflow { composedCheck = "org.contextmapper.dsl.validation.DomainObjectValidator" composedCheck = "org.contextmapper.dsl.validation.DomainValidator" composedCheck = "org.contextmapper.dsl.validation.TacticDDDOperationsValidator" - + // Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage generateDeprecationValidation = true diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/cml/CMLModelObjectsResolvingHelper.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/cml/CMLModelObjectsResolvingHelper.java index a2f290a6..7e8a22c0 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/cml/CMLModelObjectsResolvingHelper.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/cml/CMLModelObjectsResolvingHelper.java @@ -15,14 +15,12 @@ */ package org.contextmapper.dsl.cml; -import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.contextmapper.dsl.contextMappingDSL.Aggregate; -import org.contextmapper.dsl.contextMappingDSL.Application; import org.contextmapper.dsl.contextMappingDSL.BoundedContext; import org.contextmapper.dsl.contextMappingDSL.ContextMap; import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; @@ -35,8 +33,6 @@ import org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship; import org.contextmapper.dsl.contextMappingDSL.UserRequirement; import org.contextmapper.tactic.dsl.tacticdsl.Enum; -import org.contextmapper.tactic.dsl.tacticdsl.Service; -import org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation; import org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.EcoreUtil2; @@ -170,36 +166,6 @@ public Set resolveAggregateStates(Aggregate aggregate) { return aggregateStates; } - - public Set resolveAllUpstreamContexts(BoundedContext boundedContext) { - Set allUpstreamContexts = new HashSet<>(); - allUpstreamContexts.add(boundedContext); - - ContextMap contextMap = getContextMap(boundedContext); - if (contextMap != null) { - for (Relationship relationship : contextMap.getRelationships()) { - BoundedContext upstreamContext = getUpstreamContext(relationship, boundedContext); - if (upstreamContext != null) { - allUpstreamContexts.add(upstreamContext); - } - } - } - - return allUpstreamContexts; - } - - public Service resolveApplicationServiceByName(Application application, String serviceName) { - return application == null ? null : application.getServices().stream() - .filter(service -> service.getName().equals(serviceName)) - .findAny() - .orElse(null); - } - - public List resolveServiceOperationsByName(Service service, String operationName) { - return service == null ? null : service.getOperations().stream() - .filter(operation -> operation.getName().equals(operationName)) - .collect(Collectors.toList()); - } private boolean isBCDownstreamInRelationship(Relationship relationship, BoundedContext bc) { if (relationship instanceof SymmetricRelationship) { @@ -227,22 +193,5 @@ private List getExposedAggregates(Relationship relationship) { } return aggregates; } - - private BoundedContext getUpstreamContext(Relationship relationship, BoundedContext boundedContext) { - if (relationship instanceof SymmetricRelationship) { - SymmetricRelationship symmetricRelationship = (SymmetricRelationship) relationship; - if (symmetricRelationship.getParticipant1().getName().equals(boundedContext.getName())) { - return symmetricRelationship.getParticipant2(); - } else if (symmetricRelationship.getParticipant2().getName().equals(boundedContext.getName())) { - return symmetricRelationship.getParticipant1(); - } - } else if (relationship instanceof UpstreamDownstreamRelationship) { - UpstreamDownstreamRelationship upstreamDownstreamRelationship = (UpstreamDownstreamRelationship) relationship; - if (upstreamDownstreamRelationship.getDownstream().getName().equals(boundedContext.getName())) { - return upstreamDownstreamRelationship.getUpstream(); - } - } - return null; - } } diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/formatting2/ContextMappingDSLFormatter.xtend b/org.contextmapper.dsl/src/org/contextmapper/dsl/formatting2/ContextMappingDSLFormatter.xtend index 18489444..1b4ffbc3 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/formatting2/ContextMappingDSLFormatter.xtend +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/formatting2/ContextMappingDSLFormatter.xtend @@ -26,8 +26,6 @@ import org.contextmapper.dsl.contextMappingDSL.Domain import org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep import org.contextmapper.dsl.contextMappingDSL.EitherCommandOrOperation import org.contextmapper.dsl.contextMappingDSL.Flow -import org.contextmapper.dsl.contextMappingDSL.Coordination -import org.contextmapper.dsl.contextMappingDSL.CoordinationStep import org.contextmapper.dsl.contextMappingDSL.Relationship import org.contextmapper.dsl.contextMappingDSL.SculptorModule import org.contextmapper.dsl.contextMappingDSL.Subdomain @@ -133,9 +131,6 @@ class ContextMappingDSLFormatter extends TacticDDDLanguageFormatter { for (flow : application.flows) { flow.format } - for (coordination : application.coordinations) { - coordination.format - } } def dispatch void format(Flow flow, extension IFormattableDocument document) { @@ -163,29 +158,6 @@ class ContextMappingDSLFormatter extends TacticDDDLanguageFormatter { commandOrOperation.regionFor.keyword("command").prepend[newLine] commandOrOperation.regionFor.keyword("operation").prepend[newLine] } - - def dispatch void format(Coordination coordination, extension IFormattableDocument document) { - interior( - coordination.regionFor.ruleCallTo(OPENRule).append[newLine], - coordination.regionFor.ruleCallTo(CLOSERule).prepend[newLine].append[newLines = 2] - )[indent] - - coordination.regionFor.keyword('Coordination').prepend[newLine] - - for (step : coordination.coordinationSteps) { - step.format - } - } - - def dispatch void format(CoordinationStep step, extension IFormattableDocument document) { - step.prepend[newLine] - - step.regionFor.keywords('::').forEach [ - surround[noSpace] - ] - - step.regionFor.keyword(';').prepend[noSpace] - } def dispatch void format(Domain domain, extension IFormattableDocument document) { interior( diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/SketchMinerGenerator.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/SketchMinerGenerator.java index 0957d447..2a5007fe 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/SketchMinerGenerator.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/SketchMinerGenerator.java @@ -20,10 +20,8 @@ import org.contextmapper.dsl.contextMappingDSL.BoundedContext; import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; -import org.contextmapper.dsl.contextMappingDSL.Coordination; import org.contextmapper.dsl.contextMappingDSL.Flow; import org.contextmapper.dsl.generator.exception.GeneratorInputException; -import org.contextmapper.dsl.generator.sketchminer.SketchMinerCoordinationModelCreator; import org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator; import org.eclipse.emf.common.util.URI; import org.eclipse.xtext.generator.IFileSystemAccess2; @@ -44,23 +42,18 @@ protected void generateFromContextMappingModel(ContextMappingModel model, IFileS for (Flow flow : getFlowsWithSteps(boundedContext)) { fsa.generateFile(fileName + "_BC_" + boundedContext.getName() + "_" + flow.getName() + "." + SKETCH_MINER_FILE_EXT, new SketchMinerModelCreator().createText(flow)); } - for (Coordination coordination : getCoordinationsWithSteps(boundedContext)) { - fsa.generateFile("coordinations/" + fileName + "_BC_" + boundedContext.getName() + "_" + coordination.getName() + "." + SKETCH_MINER_FILE_EXT, new SketchMinerCoordinationModelCreator().createText(coordination)); - } } } private void checkPreconditions() { for (BoundedContext boundedContext : this.contextMappingModel.getBoundedContexts()) { - if (boundedContext.getApplication() != null && (boundedContext.getApplication().getFlows() != null || boundedContext.getApplication().getCoordinations() != null)) { + if (boundedContext.getApplication() != null && boundedContext.getApplication().getFlows() != null) { Set nonEmptyFlows = boundedContext.getApplication().getFlows().stream().filter(f -> !f.getSteps().isEmpty()).collect(Collectors.toSet()); - Set nonEmptyCoordinations = boundedContext.getApplication().getCoordinations().stream().filter(c -> !c.getCoordinationSteps().isEmpty()).collect(Collectors.toSet()); - - if (!nonEmptyFlows.isEmpty() || !nonEmptyCoordinations.isEmpty()) + if (!nonEmptyFlows.isEmpty()) return; } } - throw new GeneratorInputException("Your model does not contain any Bounded Contexts with application layer and flow or coordination definition."); + throw new GeneratorInputException("Your model does not contain any Bounded Contexts with application layer and flow definition."); } private Set getFlowsWithSteps(BoundedContext boundedContext) { @@ -68,11 +61,5 @@ private Set getFlowsWithSteps(BoundedContext boundedContext) { return Sets.newHashSet(); return boundedContext.getApplication().getFlows().stream().filter(f -> !f.getSteps().isEmpty()).collect(Collectors.toSet()); } - - private Set getCoordinationsWithSteps(BoundedContext boundedContext) { - if (boundedContext.getApplication() == null || boundedContext.getApplication().getFlows() == null) - return Sets.newHashSet(); - return boundedContext.getApplication().getCoordinations().stream().filter(c -> !c.getCoordinationSteps().isEmpty()).collect(Collectors.toSet()); - } } diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerCoordinationModelCreator.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerCoordinationModelCreator.java deleted file mode 100644 index 4ee74ea2..00000000 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerCoordinationModelCreator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.generator.sketchminer; - -import java.util.Map; - -import org.contextmapper.dsl.contextMappingDSL.Coordination; -import org.contextmapper.dsl.generator.AbstractFreemarkerTextCreator; -import org.contextmapper.dsl.generator.sketchminer.converter.Coordination2SketchMinerConverter; - -public class SketchMinerCoordinationModelCreator extends AbstractFreemarkerTextCreator { - - private static final String TEMPLATE_NAME = "sketchminer.ftl"; - - @Override - protected void preprocessing(Coordination modelObject) { - // nothing to do here - } - - @Override - protected void registerModelObjects(Map root, Coordination coordination) { - Coordination2SketchMinerConverter converter = new Coordination2SketchMinerConverter(coordination); - root.put("model", converter.convert()); - } - - @Override - protected String getTemplateName() { - return TEMPLATE_NAME; - } - - @Override - protected Class getTemplateClass() { - return SketchMinerCoordinationModelCreator.class; - } - -} diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerLinkCreator.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerLinkCreator.java index bd5e05ff..7750090f 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerLinkCreator.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/SketchMinerLinkCreator.java @@ -15,7 +15,6 @@ */ package org.contextmapper.dsl.generator.sketchminer; -import org.contextmapper.dsl.contextMappingDSL.Coordination; import org.contextmapper.dsl.contextMappingDSL.Flow; import org.eclipse.emf.ecore.EObject; @@ -33,19 +32,11 @@ public String createSketchMinerLink(Flow flow) { return SKETCH_MINER_URL + LZString.compressToEncodedURIComponent( "bpln:v1\n--\n" + sketchMinerInput); } - - public String createSketchMinerLink(Coordination coordination) { - String sketchMinerInput = new SketchMinerCoordinationModelCreator().createText(coordination); - return SKETCH_MINER_URL + LZString.compressToEncodedURIComponent( - "bpln:v1\n--\n" + sketchMinerInput); - } - public String createSketchMinerLink(EObject object) { - if (object instanceof Flow) - return createSketchMinerLink((Flow) object); - else if (object instanceof Coordination) - return createSketchMinerLink((Coordination) object); - return ""; + public String createSketchMinerLink(EObject flow) { + if (!(flow instanceof Flow)) + return ""; + return createSketchMinerLink((Flow) flow); } } diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/Coordination2SketchMinerConverter.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/Coordination2SketchMinerConverter.java deleted file mode 100644 index 45ab2268..00000000 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/Coordination2SketchMinerConverter.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.generator.sketchminer.converter; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper; -import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; -import org.contextmapper.dsl.contextMappingDSL.Coordination; -import org.contextmapper.dsl.contextMappingDSL.CoordinationStep; -import org.contextmapper.dsl.generator.sketchminer.model.SketchMinerModel; -import org.contextmapper.dsl.generator.sketchminer.model.Task; -import org.contextmapper.dsl.generator.sketchminer.model.TaskSequence; -import org.contextmapper.dsl.generator.sketchminer.model.TaskType; -import org.eclipse.xtext.EcoreUtil2; - -import com.google.common.collect.Lists; - -public class Coordination2SketchMinerConverter { - - private Coordination coordination; - private List simplifiedSteps; - private Map taskMap; - private SketchMinerModel model; - - public Coordination2SketchMinerConverter(Coordination coordination) { - this.coordination = coordination; - this.model = new SketchMinerModel(getDefaultActorName(coordination)); - initIntermediateTypes(); - } - - public SketchMinerModel convert() { - TaskSequence seq = new TaskSequence(simplifiedSteps.get(0).getOperation()); - model.addSequence(seq); - finishSequence(seq); - return model; - } - - private void finishSequence(TaskSequence seq) { - for (int i = 1; i < simplifiedSteps.size(); i++) { - seq.addTask(simplifiedSteps.get(i).getOperation()); - } - } - - private void initIntermediateTypes() { - this.simplifiedSteps = Lists.newLinkedList(); - this.taskMap = new HashMap<>(); - - for (CoordinationStep step : coordination.getCoordinationSteps()) { - this.simplifiedSteps.add(convert(step)); - } - } - - private SimplifiedCoordinationStep convert(CoordinationStep step) { - Task operation = getOrCreateTask(step, TaskType.COMMAND); - return new SimplifiedCoordinationStep(operation); - } - - private Task getOrCreateTask(CoordinationStep step, TaskType type) { - String taskName = step.getService().getName() + "." + step.getOperation().getName(); - String taskMapKey = step.getBoundedContext().getName() + "." + taskName; - - if (taskMap.containsKey(taskMapKey)) - return taskMap.get(taskMapKey); - Task task = new Task(taskName, type); - task.setActor(step.getBoundedContext().getName()); - taskMap.put(taskMapKey, task); - return task; - } - - private String getDefaultActorName(Coordination coordination) { - if (EcoreUtil2.getRootContainer(coordination) instanceof ContextMappingModel) - return new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(coordination)).resolveBoundedContext(coordination).getName(); - return "Application"; - } - -} diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/SimplifiedCoordinationStep.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/SimplifiedCoordinationStep.java deleted file mode 100644 index cfb59925..00000000 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/generator/sketchminer/converter/SimplifiedCoordinationStep.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.generator.sketchminer.converter; - -import org.contextmapper.dsl.generator.sketchminer.model.Task; - -public class SimplifiedCoordinationStep { - - private Task operation; - - public SimplifiedCoordinationStep(Task operation) { - this.operation = operation; - } - - public Task getOperation() { - return operation; - } - -} diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/CMLScopingHelper.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/CMLScopingHelper.java index 039d9374..c32be6ed 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/CMLScopingHelper.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/CMLScopingHelper.java @@ -90,5 +90,5 @@ private Set> getParentTypes(EObject object) { } return parentTypes; } - + } diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/ContextMappingDSLScopeProvider.xtend b/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/ContextMappingDSLScopeProvider.xtend index ac383f04..04bb9ed5 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/ContextMappingDSLScopeProvider.xtend +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/scoping/ContextMappingDSLScopeProvider.xtend @@ -41,4 +41,5 @@ class ContextMappingDSLScopeProvider extends AbstractDeclarativeScopeProvider { } super.getScope(context, reference) } + } diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ApplicationCoordinationSemanticsValidator.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ApplicationCoordinationSemanticsValidator.java deleted file mode 100644 index 8c729abe..00000000 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ApplicationCoordinationSemanticsValidator.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2023 The Context Mapper Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.contextmapper.dsl.validation; - -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_CONTEXT_NOT_REACHABLE; -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION; -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_OPERATION_NOT_ON_STEP_SERVICE; -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_STEP_OPERATION_IS_AMBIGUOUS; -import static org.contextmapper.dsl.validation.ValidationMessages.VISUALIZE_COORDINATION_WITH_SKETCH_MINER; - -import java.util.List; - -import org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper; -import org.contextmapper.dsl.contextMappingDSL.BoundedContext; -import org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage; -import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel; -import org.contextmapper.dsl.contextMappingDSL.Coordination; -import org.contextmapper.dsl.contextMappingDSL.CoordinationStep; -import org.contextmapper.tactic.dsl.tacticdsl.Service; -import org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation; -import org.eclipse.xtext.EcoreUtil2; -import org.eclipse.xtext.validation.AbstractDeclarativeValidator; -import org.eclipse.xtext.validation.Check; -import org.eclipse.xtext.validation.EValidatorRegistrar; - -public class ApplicationCoordinationSemanticsValidator extends AbstractDeclarativeValidator { - - public static final String SKETCH_MINER_INFO_ID = "open-coordination-in-sketch-miner"; - - @Override - public void register(EValidatorRegistrar registrar) { - // not needed for classes used as ComposedCheck - } - - @Check - public void stepContextIsReachableByRelationship(final CoordinationStep coordinationStep) { - CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(coordinationStep)); - - BoundedContext containerContext = helper.resolveBoundedContext(coordinationStep); - BoundedContext stepContext = coordinationStep.getBoundedContext(); - if (containerContext == null || stepContext == null || isNullName(stepContext.getName())) { - return; // BC is undefined - } - - if (!helper.resolveAllUpstreamContexts(containerContext).contains(stepContext)) { - error(String.format(COORDINATION_STEP_CONTEXT_NOT_REACHABLE, stepContext.getName()), - coordinationStep, ContextMappingDSLPackage.Literals.COORDINATION_STEP__BOUNDED_CONTEXT); - } - } - - @Check - public void stepServiceIsApplicationService(final CoordinationStep coordinationStep) { - CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(coordinationStep)); - - BoundedContext stepContext = coordinationStep.getBoundedContext(); - if (stepContext == null || isNullName(stepContext.getName())) { - return; // BC is undefined - } - - Service stepService = coordinationStep.getService(); - if (stepService == null || isNullName(stepService.getName())) { - return; // Service is undefined or out of BC scope - } - - if (helper.resolveApplicationServiceByName(stepContext.getApplication(), stepService.getName()) == null) { - error(String.format(COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION, stepService.getName(), stepContext.getName()), - coordinationStep, ContextMappingDSLPackage.Literals.COORDINATION_STEP__SERVICE); - } - } - - @Check - public void stepOperationIsPartOfStepService(final CoordinationStep coordinationStep) { - CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(coordinationStep)); - - BoundedContext stepContext = coordinationStep.getBoundedContext(); - if (stepContext == null || isNullName(stepContext.getName())) { - return; // BC is undefined - } - - Service stepService = coordinationStep.getService(); - if (stepService == null || isNullName(stepService.getName())) { - return; // Service is undefined or out of BC scope - } - - ServiceOperation stepOperation = coordinationStep.getOperation(); - if (stepOperation == null || isNullName(stepOperation.getName())) { - return; // Operation is undefined or out of Service scope - } - - List operations = helper.resolveServiceOperationsByName(stepService, stepOperation.getName()); - if (operations.isEmpty()) { - error(String.format(COORDINATION_STEP_OPERATION_NOT_ON_STEP_SERVICE, stepOperation.getName(), stepService.getName(), stepContext.getName()), - coordinationStep, ContextMappingDSLPackage.Literals.COORDINATION_STEP__OPERATION); - } - } - - @Check - public void stepOperationShouldBeUniqueInStepService(final CoordinationStep coordinationStep) { - CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(coordinationStep)); - - Service stepService = coordinationStep.getService(); - if (stepService == null || isNullName(stepService.getName())) { - return; // Service is undefined or out of BC scope - } - - ServiceOperation stepOperation = coordinationStep.getOperation(); - if (stepOperation == null || isNullName(stepOperation.getName())) { - return; // Operation is undefined or out of Service scope - } - - List operations = helper.resolveServiceOperationsByName(stepService, stepOperation.getName()); - if (operations.size() > 1) { - warning(String.format(COORDINATION_STEP_OPERATION_IS_AMBIGUOUS, stepOperation.getName(), stepService.getName()), - coordinationStep, ContextMappingDSLPackage.Literals.COORDINATION_STEP__OPERATION); - } - } - - @Check - public void sketchMinerLink(final Coordination coordination) { - if (!coordination.getCoordinationSteps().isEmpty()) - info(VISUALIZE_COORDINATION_WITH_SKETCH_MINER, coordination, ContextMappingDSLPackage.Literals.COORDINATION__NAME, SKETCH_MINER_INFO_ID); - } - - private boolean isNullName(String name) { - return name == null || "".equals(name); - } - -} diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/UniquenessValidator.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/UniquenessValidator.java index 68cae5e0..682c94d5 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/UniquenessValidator.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/UniquenessValidator.java @@ -25,7 +25,6 @@ import static org.contextmapper.dsl.validation.ValidationMessages.USE_CASE_NAME_NOT_UNIQUE; import static org.contextmapper.dsl.validation.ValidationMessages.DOMAIN_NOT_UNIQUE; import static org.contextmapper.dsl.validation.ValidationMessages.FLOW_NAME_NOT_UNIQUE; -import static org.contextmapper.dsl.validation.ValidationMessages.COORDINATION_NAME_NOT_UNIQUE; import java.util.HashSet; import java.util.Iterator; @@ -39,7 +38,6 @@ import org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLPackage; import org.contextmapper.dsl.contextMappingDSL.Domain; import org.contextmapper.dsl.contextMappingDSL.Flow; -import org.contextmapper.dsl.contextMappingDSL.Coordination; import org.contextmapper.dsl.contextMappingDSL.SculptorModule; import org.contextmapper.dsl.contextMappingDSL.Subdomain; import org.contextmapper.dsl.contextMappingDSL.UserRequirement; @@ -195,18 +193,6 @@ public void validateThatFlowNameIsUnique(final Flow flow) { } } - @Check - public void validateThatCoordinationNameIsUnique(final Coordination coordination) { - if (coordination != null) { - Iterator allCoordinations = EcoreUtil2.eAllOfType(getRootCMLModel(coordination), Coordination.class).iterator(); - Iterator duplicateCoordinations = IteratorExtensions.filter(allCoordinations, ((Function1) (Coordination c) -> { - return c.getName().equals(coordination.getName()); - })); - if (IteratorExtensions.size(duplicateCoordinations) > 1) - error(String.format(COORDINATION_NAME_NOT_UNIQUE, coordination.getName()), coordination, ContextMappingDSLPackage.Literals.COORDINATION__NAME); - } - } - private void checkDomainObjectUnique(List domainObjects) { Set usedNames = new HashSet<>(); for (SimpleDomainObject o : domainObjects) { diff --git a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ValidationMessages.java b/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ValidationMessages.java index 797c7a59..ab1d012d 100644 --- a/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ValidationMessages.java +++ b/org.contextmapper.dsl/src/org/contextmapper/dsl/validation/ValidationMessages.java @@ -33,10 +33,6 @@ public class ValidationMessages { public static final String ORGANIZATIONAL_MAP_DOES_NOT_CONTAIN_TEAM = "Your Context Map is of the type ORGANIZATIONAL but does not contain Bounded Contexts of the type TEAM. This type of Context Map is intended to model team relationships."; public static final String COMMAND_OR_OPERATION_IS_NOT_PART_OF_BOUNDED_CONTEXT = "The command or operation '%s' is not part of the '%s' Bounded Context. Please ensure that your workflow only uses commands, operations and events that are part of the same Bounded Context."; public static final String STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE = "'%s' is not a state of the Aggregate '%s'."; - public static final String COORDINATION_STEP_CONTEXT_NOT_REACHABLE = "The Bounded Context '%s' is not reachable through Context Map relationships. Maybe you want to create a relationship with this context?"; - public static final String COORDINATION_STEP_SERVICE_NOT_ON_STEP_CONTEXT_APPLICATION = "The Service '%s' is not part of the Bounded Context '%s' Application."; - public static final String COORDINATION_STEP_OPERATION_NOT_ON_STEP_SERVICE = "The operation '%s' is not part of the Service '%s' of the Bounded Context '%s' Application."; - public static final String COORDINATION_STEP_OPERATION_IS_AMBIGUOUS = "The reference to operation '%s' is ambiguous, since there exist multiple operations with that name in Service '%s'. We suggest keeping the operation names distinct when referencing them through Coordinations."; /* Uniqueness problems */ public static final String BOUNDED_CONTEXT_NAME_NOT_UNIQUE = "Multiple bounded contexts with the name '%s' have been declared."; @@ -50,14 +46,13 @@ public class ValidationMessages { public static final String SERVICE_NAME_NOT_UNIQUE_IN_BC = "Multiple services with the name '%s' have been declared in this Bounded Context."; public static final String SERVICE_NAME_NOT_UNIQUE_IN_SUBDOMAIN = "Multiple services with the name '%s' have been declared in this Subdomain."; public static final String FLOW_NAME_NOT_UNIQUE = "Multiple flows with the name '%s' have been declared. Please provide unique names!"; - public static final String COORDINATION_NAME_NOT_UNIQUE = "Multiple coordinations with the name '%s' have been declared. Please provide unique names!"; /* Generator problems */ public static final String EMPTY_UML_COMPONENT_DIAGRAM_MESSAGE = "Sorry, we cannot generate a component diagram. Your Context Map seems to be empty."; public static final String EMPTY_UML_CLASS_DIAGRAM_MESSAGE = "Sorry, we cannot generate a class diagram for this Bounded Context. There are no Aggregates or none of the Aggregates contain any domain objects (entities, value objects or domain events)."; public static final String EMPTY_UML_CLASS_DIAGRAM_MESSAGE_AGGREGATE = "Sorry, we cannot generate a class diagram for this Aggregate. There are no domain objects (entities, value objects or domain events)."; public static final String EMPTY_UML_CLASS_DIAGRAM_MESSAGE_MODULE = "Sorry, we cannot generate a class diagram for this module. There are no domain objects (entities, value objects or domain events)."; - + /* General input problems */ public static final String ENTITY_NAME_CONTAINS_INVALID_CHARACTERS = "The entity name should consist of the following characters: a-z, A-Z, 0-9, _. Please rename the entity accordingly before applying transformations."; public static final String VERB_CONTAINS_INVALID_CHARACTERS = "The verb should consist of the following characters: a-z, A-Z, 0-9, _. Please rename it accordingly before applying transformations."; @@ -73,6 +68,4 @@ public class ValidationMessages { /* Quickfix suggestions */ public static final String SPLIT_STORY_BY_VERB_SUGGESTION = "You could split your story by its operation/verb."; public static final String VISUALIZE_FLOW_WITH_SKETCH_MINER = "Do you want to vizualize this flow? You can open it in BPMN Sketch Miner ..."; - public static final String VISUALIZE_COORDINATION_WITH_SKETCH_MINER = "Do you want to vizualize this coordination? You can open it in BPMN Sketch Miner ..."; - }