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 Nov 8, 2024
1 parent d86af4c commit 612b0b0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

=== Improvements

- 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/829[#829] [metamodel] `OccurrenceUsage#portionKind` is now unsettable and its default value is `null`.
- 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 @@ -11,6 +11,7 @@
== Improvements

- `OccurrenceUsage#portionKind` is now `unsettable` and its default value is `null` in the SysMLv2 metamodel to conform to the specification.
- Add support of `AllocationDefinition` and 'AllocationUsage` in export from model to textual SysMLv2.

== New features

Expand Down

0 comments on commit 612b0b0

Please sign in to comment.