Skip to content

Commit 137735b

Browse files
committed
KERML_-140 Allowed MultiplicityRange owned members other than bounds.
- Updated abstract syntax metamodel. - Added setting delegate for MultiplicityRange::bound. - Implemented validateMultiplicityRangeBounds constraint check.
1 parent e09e56f commit 137735b

17 files changed

Lines changed: 37920 additions & 37872 deletions

org.omg.kerml.xtext/src/org/omg/kerml/xtext/validation/KerMLValidator.xtend

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ class KerMLValidator extends AbstractKerMLValidator {
274274

275275
public static val INVALID_MULTIPLICITY_RANGE_BOUND_RESULT_TYPES = "validateMultiplicityRangeResultTypes"
276276
public static val INVALID_MULTIPLICITY_RANGE_BOUND_RESULT_TYPES_MSG = "Must have a Natural value"
277+
public static val INVALID_MULTIPLICITY_RANGE_BOUNDS = "validateMultiplicityRangeBounds"
278+
public static val INVALID_MULTIPLICITY_RANGE_BOUNDS_MSG = "Bound expressions must be first two owned members"
277279

278280
public static val INVALID_METADATA_FEATURE_ANNOTATED_ELEMENT = "validateMetadataFeatureAnnotatedElement"
279281
public static val INVALID_METADATA_FEATURE_ANNOTATED_ELEMENT_MSG = "Cannot annotate {metaclass}"
@@ -1034,6 +1036,15 @@ class KerMLValidator extends AbstractKerMLValidator {
10341036
error(INVALID_MULTIPLICITY_RANGE_BOUND_RESULT_TYPES_MSG, b, null, INVALID_MULTIPLICITY_RANGE_BOUND_RESULT_TYPES)
10351037
}
10361038
}
1039+
1040+
// validateMultiplicityRangeBounds
1041+
val ownedMembers = mult.ownedMember
1042+
val lowerBound = mult.lowerBound
1043+
val upperBound = mult.upperBound
1044+
if ((lowerBound === null && (ownedMembers.empty || ownedMembers.get(0) !== upperBound)) ||
1045+
(lowerBound !== null && (ownedMembers.size < 2 || ownedMembers.get(0) !== lowerBound || ownedMembers.get(1) !== upperBound))) {
1046+
error(INVALID_MULTIPLICITY_RANGE_BOUNDS_MSG, mult, null, INVALID_MULTIPLICITY_RANGE_BOUNDS)
1047+
}
10371048
}
10381049

10391050
@Check

org.omg.sysml/model/SysML.ecore

Lines changed: 1229 additions & 1230 deletions
Large diffs are not rendered by default.

org.omg.sysml/model/SysML.genmodel

Lines changed: 283 additions & 283 deletions
Large diffs are not rendered by default.

org.omg.sysml/model/SysML.uml

Lines changed: 12041 additions & 12017 deletions
Large diffs are not rendered by default.

org.omg.sysml/model/types.ecore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<details key="settingDelegates" value="http://www.omg.org/spec/SysML"/>
1010
<details key="invocationDelegates" value="http://www.omg.org/spec/SysML"/>
1111
</eAnnotations>
12+
<eClassifiers xsi:type="ecore:EDataType" name="Boolean" instanceClassName="boolean">
13+
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
14+
<details key="documentation" value="Boolean is used for logical expressions, consisting of the predefined values true and false."/>
15+
</eAnnotations>
16+
</eClassifiers>
1217
<eClassifiers xsi:type="ecore:EDataType" name="Integer" instanceClassName="int">
1318
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
1419
<details key="documentation" value="Integer is a primitive type representing integer values."/>
@@ -19,19 +24,14 @@
1924
<details key="documentation" value="Real is a primitive type representing the mathematical concept of real."/>
2025
</eAnnotations>
2126
</eClassifiers>
22-
<eClassifiers xsi:type="ecore:EDataType" name="String" instanceClassName="java.lang.String">
23-
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
24-
<details key="documentation" value="String is a sequence of characters in some suitable character set used to display information about the model. Character sets may include non-Roman alphabets and characters."/>
25-
</eAnnotations>
26-
</eClassifiers>
2727
<eClassifiers xsi:type="ecore:EDataType" name="UnlimitedNatural" instanceClassName="int">
2828
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
2929
<details key="documentation" value="UnlimitedNatural is a primitive type representing unlimited natural values."/>
3030
</eAnnotations>
3131
</eClassifiers>
32-
<eClassifiers xsi:type="ecore:EDataType" name="Boolean" instanceClassName="boolean">
32+
<eClassifiers xsi:type="ecore:EDataType" name="String" instanceClassName="java.lang.String">
3333
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
34-
<details key="documentation" value="Boolean is used for logical expressions, consisting of the predefined values true and false."/>
34+
<details key="documentation" value="String is a sequence of characters in some suitable character set used to display information about the model. Character sets may include non-Roman alphabets and characters."/>
3535
</eAnnotations>
3636
</eClassifiers>
3737
</ecore:EPackage>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2024 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.delegate.setting;
23+
24+
import org.eclipse.emf.common.util.EList;
25+
import org.eclipse.emf.ecore.EStructuralFeature;
26+
import org.eclipse.emf.ecore.InternalEObject;
27+
import org.omg.sysml.lang.sysml.Expression;
28+
import org.omg.sysml.lang.sysml.MultiplicityRange;
29+
import org.omg.sysml.util.NonNotifyingEObjectEList;
30+
31+
public class MultiplicityRange_bound_SettingDelegate extends BasicDerivedListSettingDelegate {
32+
33+
public MultiplicityRange_bound_SettingDelegate(EStructuralFeature eStructuralFeature) {
34+
super(eStructuralFeature);
35+
}
36+
37+
@Override
38+
public EList<Expression> basicGet(InternalEObject owner) {
39+
EList<Expression> bounds = new NonNotifyingEObjectEList<>(Expression.class, owner, eStructuralFeature.getFeatureID());
40+
Expression lowerBound = ((MultiplicityRange)owner).getLowerBound();
41+
Expression upperBound = ((MultiplicityRange)owner).getUpperBound();
42+
if (upperBound != null) {
43+
if (lowerBound != null) {
44+
bounds.add(lowerBound);
45+
}
46+
bounds.add(upperBound);
47+
}
48+
return bounds;
49+
}
50+
51+
}

org.omg.sysml/src/org/omg/sysml/delegate/setting/MultiplicityRange_lowerBound_SettingDelegate.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022 Model Driven Solutions, Inc.
3+
* Copyright (c) 2022, 2024 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -26,7 +26,6 @@
2626

2727
import org.eclipse.emf.ecore.EStructuralFeature;
2828
import org.eclipse.emf.ecore.InternalEObject;
29-
import org.omg.sysml.lang.sysml.Element;
3029
import org.omg.sysml.lang.sysml.Expression;
3130
import org.omg.sysml.lang.sysml.MultiplicityRange;
3231
import org.omg.sysml.util.NamespaceUtil;
@@ -39,13 +38,10 @@ public MultiplicityRange_lowerBound_SettingDelegate(EStructuralFeature eStructur
3938

4039
@Override
4140
public Expression basicGet(InternalEObject owner) {
42-
List<Element> bounds = NamespaceUtil.getOwnedMembersOf((MultiplicityRange)owner).collect(Collectors.toList());
43-
if (bounds.size() < 2) {
44-
return null;
45-
} else {
46-
Element bound = bounds.get(0);
47-
return bound instanceof Expression? (Expression)bound: null;
48-
}
41+
List<Expression> bounds = NamespaceUtil.getOwnedMembersOf((MultiplicityRange)owner).
42+
filter(Expression.class::isInstance).map(Expression.class::cast).
43+
collect(Collectors.toList());
44+
return bounds.size() < 2? null: bounds.get(0);
4945
}
5046

5147
}

org.omg.sysml/src/org/omg/sysml/delegate/setting/MultiplicityRange_upperBound_SettingDelegate.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022 Model Driven Solutions, Inc.
3+
* Copyright (c) 2022, 2024 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -26,7 +26,6 @@
2626

2727
import org.eclipse.emf.ecore.EStructuralFeature;
2828
import org.eclipse.emf.ecore.InternalEObject;
29-
import org.omg.sysml.lang.sysml.Element;
3029
import org.omg.sysml.lang.sysml.Expression;
3130
import org.omg.sysml.lang.sysml.MultiplicityRange;
3231
import org.omg.sysml.util.NamespaceUtil;
@@ -39,14 +38,12 @@ public MultiplicityRange_upperBound_SettingDelegate(EStructuralFeature eStructur
3938

4039
@Override
4140
public Expression basicGet(InternalEObject owner) {
42-
List<Element> bounds = NamespaceUtil.getOwnedMembersOf((MultiplicityRange)owner).collect(Collectors.toList());
43-
int size = bounds.size();
44-
if (bounds.isEmpty()) {
45-
return null;
46-
} else {
47-
Element bound = bounds.get(size - 1);
48-
return bound instanceof Expression? (Expression)bound: null;
49-
}
41+
List<Expression> bounds = NamespaceUtil.getOwnedMembersOf((MultiplicityRange)owner).
42+
filter(Expression.class::isInstance).map(Expression.class::cast).
43+
collect(Collectors.toList());
44+
return bounds.isEmpty()? null:
45+
bounds.size() == 1? bounds.get(0):
46+
bounds.get(1);
5047
}
5148

5249
}

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/MultiplicityRange.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,34 @@
3333
* <p>A <code>MultiplicityRange</code> is a <code>Multiplicity</code> whose value is defined to be the (inclusive) range of natural numbers given by the result of a <code>lowerBound</code> <code>Expression</code> and the result of an <code>upperBound</code> <code>Expression</code>. The result of these <code>Expressions</code> shall be of type <code><em>Natural</em></code>. If the result of the <code>upperBound</code> <code>Expression</code> is the unbounded value <code>*</code>, then the specified range includes all natural numbers greater than or equal to the <code>lowerBound</code> value. If no <code>lowerBound</code> <code>Expression</code>, then the default is that the lower bound has the same value as the upper bound, except if the <code>upperBound</code> evaluates to <code>*</code>, in which case the default for the lower bound is 0.</p>
3434
*
3535
* bound->forAll(b | b.featuringType = self.featuringType)
36-
* lowerBound =
37-
* let ownedMembers : Sequence(Element) =
38-
* ownedMembership->selectByKind(OwningMembership).ownedMember in
39-
* if ownedMembers->size() < 2 or
40-
* not ownedMembers->first().oclIsKindOf(Expression) then null
41-
* else ownedMembers->first().oclAsType(Expression)
42-
* endif
4336
* bound->forAll(b |
4437
* b.result.specializesFromLibrary('ScalarValues::Integer') and
4538
* let value : UnlimitedNatural = valueOf(b) in
4639
* value <> null implies value >= 0
4740
* )
41+
* lowerBound =
42+
* let ownedExpressions : Sequence(Expression) =
43+
* ownedMember->selectByKind(Expression) in
44+
* if ownedExpressions->size() < 2 then null
45+
* else ownedExpressions->first()
46+
* endif
4847
* upperBound =
49-
* let ownedMembers : Sequence(Element) =
50-
* ownedMembership->selectByKind(OwningMembership).ownedMember in
51-
* if ownedMembers->isEmpty() or
52-
* not ownedMembers->last().oclIsKindOf(Expression)
53-
* then null
54-
* else ownedMembers->last().oclAsType(Expression)
55-
* endif
48+
* let ownedExpressions : Sequence(Expression) =
49+
* ownedMember->selectByKind(Expression) in
50+
* if ownedExpressions->isEmpty() then null
51+
* else if ownedExpressions->size() = 1 then ownedExpressions->at(1)
52+
* else ownedExpressions->at(2)
53+
* endif endif
54+
* ownedMember->notEmpty() and
55+
* ownedMember->at(1) = upperBound or
56+
* ownedMember->size() > 1 and
57+
* ownedMember->at(1) = lowerBound and
58+
* ownedMember->at(2) = upperBound
59+
* bound =
60+
* if upperBound = null then Sequence{}
61+
* else if lowerBound = null then Sequence{upperBound}
62+
* else Sequence{lowerBound, upperBound}
63+
* endif endif
5664
* <!-- end-model-doc -->
5765
*
5866
* <p>
@@ -150,12 +158,11 @@ public interface MultiplicityRange extends Multiplicity {
150158
* Returns the value of the '<em><b>Bound</b></em>' reference list.
151159
* The list contents are of type {@link org.omg.sysml.lang.sysml.Expression}.
152160
* <p>
153-
* This feature redefines the following features:
161+
* This feature subsets the following features:
154162
* </p>
155163
* <ul>
156164
* <li>'{@link org.omg.sysml.lang.sysml.Namespace#getOwnedMember() <em>Owned Member</em>}'</li>
157165
* </ul>
158-
* This feature is a derived union.
159166
* <!-- begin-user-doc -->
160167
* <p>
161168
* If the meaning of the '<em>Bound</em>' reference list isn't clear,
@@ -167,10 +174,10 @@ public interface MultiplicityRange extends Multiplicity {
167174
* <!-- end-model-doc -->
168175
* @return the value of the '<em>Bound</em>' reference list.
169176
* @see org.omg.sysml.lang.sysml.SysMLPackage#getMultiplicityRange_Bound()
170-
* @model required="true" upper="2" transient="true" changeable="false" volatile="true" derived="true"
177+
* @model required="true" upper="2" transient="true" volatile="true" derived="true"
171178
* annotation="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName body='multiplicity'"
172-
* annotation="union"
173-
* annotation="redefines"
179+
* annotation="subsets"
180+
* annotation="http://www.omg.org/spec/SysML"
174181
* @generated
175182
*/
176183
EList<Expression> getBound();

0 commit comments

Comments
 (0)