Skip to content

Commit

Permalink
[843] Implement export of AllocationDefinition and basic export of Al…
Browse files Browse the repository at this point in the history
…locationUsage

Bug: eclipse-syson#843
Signed-off-by: Étienne Bausson <[email protected]>
  • Loading branch information
ebausson-obeo committed Dec 3, 2024
1 parent a4244a3 commit 600c934
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,6 +57,8 @@ public class SysMLKeywordSwitch extends SysmlSwitch<String> {

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";
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
image::namesapce-import.png[Namespace import node]

0 comments on commit 600c934

Please sign in to comment.