Skip to content

Commit 918162d

Browse files
committed
ST6RI-636 Fixed PlantUML multiplicity visualization.
- Added FeatureUtil.getMultiplicityOf to provide a result consistent with the old derivation computation for Feature::getMultiplicity.
1 parent 2e8c21f commit 918162d

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/Visitor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation, PlantUML Visualization
33
* Copyright (c) 2020-2022 Mgnite Inc.
4+
* Copyright (c) 2023 Model Driven Solutions, Inc.
45
*
56
* This program is free software: you can redistribute it and/or modify
67
* it under the terms of the GNU Lesser General Public License as published by
@@ -19,6 +20,7 @@
1920
*
2021
* Contributors:
2122
* Hisashi Miyashita, Mgnite Inc.
23+
* Ed Seidewitz, MDS
2224
*
2325
*****************************************************************************/
2426

@@ -347,7 +349,7 @@ protected PRelation addPRelation(Element src, Element dest, Element rel) {
347349
private MultiplicityRange getEffectiveMultiplicityRange(Element e) {
348350
if (!(e instanceof Type)) return null;
349351
Type typ = (Type) e;
350-
Multiplicity m = typ.getMultiplicity();
352+
Multiplicity m = FeatureUtil.getMultiplicityOf(typ);
351353
return FeatureUtil.getMultiplicityRangeOf(m);
352354
}
353355

org.omg.sysml/src/org/omg/sysml/util/FeatureUtil.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public static List<Feature> getAllSubsettingFeaturesIn(Type type, Feature subset
229229
collect(Collectors.toList());
230230
}
231231

232-
// Feature values
232+
// Feature values
233233

234234
public static FeatureValue getValuationFor(Feature feature) {
235235
return (FeatureValue)feature.getOwnedMembership().stream().
@@ -395,4 +395,23 @@ public static void addMultiplicityTo(Type type) {
395395
}
396396
}
397397

398+
public static Multiplicity getMultiplicityOf(Type type) {
399+
return getMultiplicityOf(type, new HashSet<>());
400+
}
401+
402+
public static Multiplicity getMultiplicityOf(Type type, Set<Type> visited) {
403+
Multiplicity multiplicity = type.getMultiplicity();
404+
if (multiplicity == null) {
405+
visited.add(type);
406+
for (Type general: TypeUtil.getGeneralTypesOf(type)){
407+
if (general != null && !visited.contains(general)) {
408+
multiplicity = getMultiplicityOf(general, visited);
409+
if (multiplicity != null) {
410+
break;
411+
}
412+
}
413+
}
414+
}
415+
return multiplicity;
416+
}
398417
}

sysml/src/examples/Simple Tests/PartTest.sysml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ package PartTest {
1111
}
1212

1313
abstract part def <xx> B {
14-
public abstract part a: A;
14+
public abstract part a: A[1..2];
15+
public abstract part b subsets a;
16+
public abstract part c[0..1] subsets a;
1517
port x: ~C;
1618
package P { }
1719

0 commit comments

Comments
 (0)