Skip to content

Commit 57402a0

Browse files
authored
Merge pull request #636 from Systems-Modeling/ST6RI-829
ST6RI-829 Standard model library element IDs (KERML_-36, SYSML2_-107)
2 parents 2a6d146 + a9a818b commit 57402a0

10 files changed

Lines changed: 323 additions & 15 deletions

File tree

org.omg.sysml.interactive.tests/.launch/Derived Property Test.launch renamed to org.omg.sysml.interactive.tests/.launch/Derived Property and Operation Test.launch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<stringAttribute key="bad_container_name" value="/org.omg.sysml.interactive.tests/.lau"/>
4+
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
45
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
5-
<listEntry value="/org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyTest.java"/>
6+
<listEntry value="/org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyAndOperationTest.java"/>
67
</listAttribute>
78
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
89
<listEntry value="1"/>
@@ -12,10 +13,11 @@
1213
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
1314
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
1415
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
16+
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
1517
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
1618
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
1719
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
18-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.omg.sysml.interactive.tests.DerivedPropertyTest"/>
20+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.omg.sysml.interactive.tests.DerivedPropertyAndOperationTest"/>
1921
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.omg.sysml.interactive.tests"/>
2022
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
2123
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -DlibraryPath=${workspace_loc:/SysML-v2-Pilot-Implementation/sysml.library}"/>

org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyTest.java renamed to org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyAndOperationTest.java

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323

2424
import static org.junit.Assert.assertEquals;
2525
import static org.junit.Assert.assertFalse;
26+
import static org.junit.Assert.assertNull;
2627
import static org.junit.Assert.assertTrue;
2728

2829
import java.util.List;
2930

3031
import org.junit.Test;
3132
import org.omg.sysml.interactive.SysMLInteractive;
33+
import org.omg.sysml.interactive.SysMLInteractiveResult;
3234
import org.omg.sysml.lang.sysml.AcceptActionUsage;
3335
import org.omg.sysml.lang.sysml.ActionUsage;
3436
import org.omg.sysml.lang.sysml.AttributeUsage;
@@ -37,11 +39,12 @@
3739
import org.omg.sysml.lang.sysml.Expression;
3840
import org.omg.sysml.lang.sysml.ItemUsage;
3941
import org.omg.sysml.lang.sysml.Namespace;
42+
import org.omg.sysml.lang.sysml.Relationship;
4043
import org.omg.sysml.lang.sysml.TriggerInvocationExpression;
4144
import org.omg.sysml.lang.sysml.Usage;
4245
import org.omg.sysml.lang.sysml.ViewUsage;
4346

44-
public class DerivedPropertyTest extends SysMLInteractiveTest {
47+
public class DerivedPropertyAndOperationTest extends SysMLInteractiveTest {
4548

4649
@Test
4750
public void testOwnedUsage() throws Exception {
@@ -86,5 +89,87 @@ public void testViewExpose() throws Exception {
8689
List<Element> exposed = view.getExposedElement();
8790
assertEquals(1, exposed.size());
8891
}
92+
93+
public final String qualifiedNameTest =
94+
"package Test {\n"
95+
+ " package P {\n"
96+
+ " item x;\n"
97+
+ " item x;\n"
98+
+ " }"
99+
+ "}";
100+
101+
@Test
102+
public void testQualifiedName() throws Exception {
103+
SysMLInteractive instance = getSysMLInteractiveInstance();
104+
SysMLInteractiveResult result = instance.process(qualifiedNameTest);
105+
Element root = result.getRootElement();
106+
List<Element> elements = ((Namespace)root).getOwnedMember();
107+
Namespace P = (Namespace)((Namespace)elements.get(0)).getOwnedMember().get(0);
108+
List<Element> P_ownedMembers = P.getOwnedMember();
109+
assertEquals("Test::P::x", P_ownedMembers.get(0).getQualifiedName());
110+
assertNull(P_ownedMembers.get(1).getQualifiedName());
111+
}
112+
113+
public final String pathTest =
114+
"// Path of package: TopLevel\n"
115+
+ "// Path of owning membership: TopLevel/owningMembership\n"
116+
+ "package TopLevel {\n"
117+
+ "\n"
118+
+ " // Path of classifier: TopLevel::A\n"
119+
+ " // Path of owning membership: TopLevel::A/owningMembership\n"
120+
+ " part def A;\n"
121+
+ "\n"
122+
+ " // Path of classifier: TopLevel::B\n"
123+
+ " // Path of owning membership: TopLevel::B/owningMembership\n"
124+
+ " // Path of owned subclassification: TopLevel::B/1\n"
125+
+ " part def B specializes A {\n"
126+
+ " // Path of owning membership: TopLevel::B/2\n"
127+
+ " // Path of feature: TopLevel::B/2/1\n"
128+
+ " ref;\n"
129+
+ " }\n"
130+
+ "\n"
131+
+ " // Path of owning membership: TopLevel/3\n"
132+
+ " // Path of classifier: TopLevel/3/1\n"
133+
+ " part def {\n"
134+
+ " // Path of owning membership: TopLevel/3/1/1\n"
135+
+ " // Path of feature: TopLevel/3/1/1/1\n"
136+
+ " ref f;\n"
137+
+ " }\n"
138+
+ "}";
139+
140+
@Test
141+
public void testPathOperation() throws Exception {
142+
SysMLInteractive instance = getSysMLInteractiveInstance();
143+
List<Element> elements = process(instance, pathTest);
144+
145+
Namespace TopLevel = (Namespace)elements.get(0);
146+
assertEquals("TopLevel", TopLevel.path());
147+
assertEquals("TopLevel/owningMembership", TopLevel.getOwningMembership().path());
148+
149+
Namespace A = (Namespace)TopLevel.getOwnedMember().get(0);
150+
assertEquals("TopLevel::A", A.path());
151+
assertEquals("TopLevel::A/owningMembership", A.getOwningMembership().path());
152+
153+
Namespace B = (Namespace)TopLevel.getOwnedMember().get(1);
154+
assertEquals("TopLevel::B", B.path());
155+
assertEquals("TopLevel::B/owningMembership", B.getOwningMembership().path());
156+
157+
Relationship B_1 = B.getOwnedRelationship().get(0);
158+
assertEquals("TopLevel::B/1", B_1.path());
159+
160+
Relationship B_2 = B.getOwnedRelationship().get(1);
161+
assertEquals("TopLevel::B/2", B_2.path());
162+
assertEquals("TopLevel::B/2/1", B_2.getOwnedRelatedElement().get(0).path());
163+
164+
Relationship TopLevel_3 = TopLevel.getOwnedRelationship().get(2);
165+
assertEquals("TopLevel/3", TopLevel_3.path());
166+
167+
Element TopLevel_3_1 = TopLevel_3.getOwnedRelatedElement().get(0);
168+
assertEquals("TopLevel/3/1", TopLevel_3_1.path());
169+
170+
Relationship TopLevel_3_1_1 = TopLevel_3_1.getOwnedRelationship().get(0);
171+
assertEquals("TopLevel/3/1/1", TopLevel_3_1_1.path());
172+
assertEquals("TopLevel/3/1/1/1", TopLevel_3_1_1.getOwnedRelatedElement().get(0).path());
173+
}
89174

90175
}
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) 2025 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.invocation;
23+
24+
import java.lang.reflect.InvocationTargetException;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.eclipse.emf.ecore.EOperation;
28+
import org.eclipse.emf.ecore.InternalEObject;
29+
import org.eclipse.emf.ecore.util.BasicInvocationDelegate;
30+
import org.omg.sysml.lang.sysml.Element;
31+
import org.omg.sysml.lang.sysml.Relationship;
32+
33+
public class Element_path_InvocationDelegate extends BasicInvocationDelegate {
34+
35+
public Element_path_InvocationDelegate(EOperation operation) {
36+
super(operation);
37+
}
38+
39+
@Override
40+
public String dynamicInvoke(InternalEObject target, EList<?> arguments) throws InvocationTargetException {
41+
Element self = (Element) target;
42+
String qualifiedName = self.getQualifiedName();
43+
Relationship owningRelationship = self.getOwningRelationship();
44+
return qualifiedName != null? qualifiedName:
45+
owningRelationship != null?
46+
owningRelationship.path() + "/" +
47+
(owningRelationship.getOwnedRelatedElement().indexOf(self) + 1):
48+
"";
49+
}
50+
51+
}
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) 2025 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.invocation;
23+
24+
import java.lang.reflect.InvocationTargetException;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.eclipse.emf.ecore.EOperation;
28+
import org.eclipse.emf.ecore.InternalEObject;
29+
import org.omg.sysml.lang.sysml.Element;
30+
import org.omg.sysml.lang.sysml.OwningMembership;
31+
32+
public class OwningMembership_path_InvocationDelegate extends Relationship_path_InvocationDelegate {
33+
34+
public OwningMembership_path_InvocationDelegate(EOperation operation) {
35+
super(operation);
36+
}
37+
38+
@Override
39+
public String dynamicInvoke(InternalEObject target, EList<?> arguments) throws InvocationTargetException {
40+
OwningMembership self = (OwningMembership) target;
41+
Element ownedElement = self.getOwnedMemberElement();
42+
if (ownedElement != null) {
43+
String qualifiedName = ownedElement.getQualifiedName();
44+
if (qualifiedName != null) {
45+
return qualifiedName + "/owningMembership";
46+
}
47+
}
48+
return super.dynamicInvoke(target, arguments);
49+
}
50+
51+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2025 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.invocation;
23+
24+
import java.lang.reflect.InvocationTargetException;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.eclipse.emf.ecore.EOperation;
28+
import org.eclipse.emf.ecore.InternalEObject;
29+
import org.omg.sysml.lang.sysml.Element;
30+
import org.omg.sysml.lang.sysml.Relationship;
31+
32+
public class Relationship_path_InvocationDelegate extends Element_path_InvocationDelegate {
33+
34+
public Relationship_path_InvocationDelegate(EOperation operation) {
35+
super(operation);
36+
}
37+
38+
@Override
39+
public String dynamicInvoke(InternalEObject target, EList<?> arguments) throws InvocationTargetException {
40+
Relationship self = (Relationship) target;
41+
Relationship owningRelationship = self.getOwningRelationship();
42+
Element owningRelatedElement = self.getOwningRelatedElement();
43+
return owningRelationship == null && owningRelatedElement != null?
44+
owningRelatedElement.path() + "/" +
45+
(owningRelatedElement.getOwnedRelationship().indexOf(self) + 1):
46+
super.dynamicInvoke(target, arguments);
47+
}
48+
49+
}

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022-2023 Model Driven Solutions, Inc.
3+
* Copyright (c) 2022-2023, 2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2022 Siemens AG
55
*
66
* This program is free software: you can redistribute it and/or modify
@@ -35,16 +35,21 @@ public Element_qualifiedName_SettingDelegate(EStructuralFeature eStructuralFeatu
3535

3636
@Override
3737
protected Object basicGet(InternalEObject owner) {
38-
Namespace owningNamespace = ((Element) owner).getOwningNamespace();
38+
Element self = (Element)owner;
39+
Namespace owningNamespace = self.getOwningNamespace();
3940
if (owningNamespace == null) {
4041
return null;
4142
} else {
42-
String name = ((Element) owner).escapedName();
43-
if (name == null || owningNamespace.getOwner() == null) {
44-
return name;
43+
String name = self.getName();
44+
if (name == null || owningNamespace.getOwnedMember().stream().
45+
filter(m->name.equals(m.getName())).
46+
findFirst().orElse(null) != self) {
47+
return null;
48+
} else if (owningNamespace.getOwner() == null) {
49+
return self.escapedName();
4550
} else {
4651
String qualification = owningNamespace.getQualifiedName();
47-
return qualification == null? null: qualification + "::" + name;
52+
return qualification == null? null: qualification + "::" + self.escapedName();
4853
}
4954
}
5055
}

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/impl/ElementImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2020-2023 Model Driven Solutions, Inc.
3+
* Copyright (c) 2020-2023, 2025 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
@@ -310,7 +310,9 @@ protected EClass eStaticClass() {
310310

311311
/**
312312
* <!-- begin-user-doc -->
313-
* If there is not elementId, set it to a random UUID.
313+
* If there is no elementId, and the Element is not a standard library Element,
314+
* set the elementId to a random UUID. If the Element is a standard library Element,
315+
* create a name-based UUID using the Element's path.
314316
* <!-- end-user-doc -->
315317
* @generated NOT
316318
*/
@@ -319,12 +321,12 @@ public String getElementId() {
319321
if (elementId == null) {
320322
UUID uuid = UUID.randomUUID();
321323
if (ElementUtil.isStandardLibraryElement(this)) {
322-
String qualifiedName = getQualifiedName();
323-
if (qualifiedName != null) {
324+
String path = path();
325+
if (path != null) {
324326
Namespace libraryNamespace = libraryNamespace();
325327
if (this != libraryNamespace) {
326328
UUID namespaceUUID = UUID.fromString(libraryNamespace.getElementId());
327-
uuid = ElementUtil.constructNameUUID(namespaceUUID, qualifiedName);
329+
uuid = ElementUtil.constructNameUUID(namespaceUUID, path);
328330
}
329331
}
330332
}

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/impl/LibraryPackageImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ public boolean isStandard() {
102102
// UUID for "NameSpace_URL", per ITU-T Rec. X.667 (10/2012), Annex D.9
103103
public final UUID UUID_NAMESPACE_URL = UUID.fromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
104104

105+
/**
106+
* <!-- begin-user-doc -->
107+
* If this is a standard library Package, then set the elementId to a named-based UUID
108+
* using a URL constructed from the KerML or SysML base URI and the Package's name.
109+
* <!-- end-user-doc -->
110+
* @generated NOT
111+
*/
105112
@Override
106113
public String getElementId() {
107114
if (elementId == null && isStandard()) {

0 commit comments

Comments
 (0)