diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2214c656a..541d86990 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -22,6 +22,7 @@ - https://github.com/eclipse-syson/syson/issues/829[#829] [metamodel] `OccurrenceUsag#portionKind` is now unsettable and its default value is `null`. - https://github.com/eclipse-syson/syson/issues/796[#796] [import] Improve the code in import module, by making it more generic +- https://github.com/eclipse-syson/syson/issues/843[#843] [export] Add support of `AllocationDefinition` and 'AllocationUsage` in export from model to textual SysMLv2. === New features diff --git a/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java b/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java index 3f9a3114f..6707439d4 100644 --- a/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java +++ b/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java @@ -18,6 +18,8 @@ import org.eclipse.syson.sysml.ActionDefinition; import org.eclipse.syson.sysml.ActionUsage; import org.eclipse.syson.sysml.ActorMembership; +import org.eclipse.syson.sysml.AllocationDefinition; +import org.eclipse.syson.sysml.AllocationUsage; import org.eclipse.syson.sysml.AssertConstraintUsage; import org.eclipse.syson.sysml.AttributeDefinition; import org.eclipse.syson.sysml.AttributeUsage; @@ -55,6 +57,8 @@ public class SysMLKeywordSwitch extends SysmlSwitch { private static final String PART_KEYWORD = "part"; + private static final String ALLOCATION_KEYWORD = "allocation"; + private static final String PORT_KEYWORD = "port"; private static final String INTERFACE_KEYWORD = "interface"; @@ -168,6 +172,16 @@ public String casePartUsage(PartUsage object) { return PART_KEYWORD; } + @Override + public String caseAllocationDefinition(AllocationDefinition object) { + return ALLOCATION_KEYWORD; + } + + @Override + public String caseAllocationUsage(AllocationUsage object) { + return ALLOCATION_KEYWORD; + } + @Override public String caseReferenceUsage(ReferenceUsage object) { if (object.getOwningMembership() instanceof SubjectMembership) { diff --git a/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java b/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java index 3badbfa2f..7c6e3179d 100644 --- a/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java +++ b/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java @@ -21,6 +21,8 @@ import org.eclipse.syson.sysml.ActionDefinition; import org.eclipse.syson.sysml.ActionUsage; import org.eclipse.syson.sysml.ActorMembership; +import org.eclipse.syson.sysml.AllocationDefinition; +import org.eclipse.syson.sysml.AllocationUsage; import org.eclipse.syson.sysml.Annotation; import org.eclipse.syson.sysml.AttributeDefinition; import org.eclipse.syson.sysml.AttributeUsage; @@ -1256,6 +1258,38 @@ public void useCaseDefinition() { } + @DisplayName("AllocationDefinition") + @Test + public void allocationDefinition() { + AllocationDefinition allocationDefinition = this.builder.createWithName(AllocationDefinition.class, "ad_1"); + + this.assertTextualFormEquals("allocation def ad_1;", allocationDefinition); + } + + @DisplayName("AllocationDefinition containing a part") + @Test + public void allocationDefinitionWithContainedEnd() { + AllocationDefinition allocationDefinition = this.builder.createWithName(AllocationDefinition.class, "ad_1"); + this.builder.createInWithName(PartUsage.class, allocationDefinition, "part_1"); + + this.assertTextualFormEquals(""" + allocation def ad_1 { + ref part part_1; + }""", allocationDefinition); + } + + @DisplayName("AllocationUsage") + @Test + public void allocationUsage() { + AllocationUsage allocationDefinition = this.builder.createWithName(AllocationUsage.class, "au_1"); + this.builder.createInWithName(PartUsage.class, allocationDefinition, "part_1"); + + this.assertTextualFormEquals(""" + ref allocation au_1 { + ref part part_1; + }""", allocationDefinition); + } + @DisplayName("ActionUsage with simple succession with owned sub-actions") @Test public void actionUsageWithSuccessionSimple() { diff --git a/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc index b0ba10e3f..43be911c0 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc @@ -12,9 +12,10 @@ - `OccurrenceUsage#portionKind` is now `unsettable` and its default value is `null` in the SysMLv2 metamodel to conform to the specification. - Improve the code in import module, by making it more generic. It now reports (on the server side) more messages to understand the scope of what is imported and the errors encountered. +- Add support of `AllocationDefinition` and 'AllocationUsage` in export from model to textual SysMLv2. == New features - Handle imported package elements in diagrams. -image::namesapce-import.png[Namespace import node] \ No newline at end of file +image::namesapce-import.png[Namespace import node]