Skip to content

Commit a9a818b

Browse files
committed
ST6RI-829 Updated qualifiedName derivation per resolution to KERML_-36.
1 parent d37a245 commit a9a818b

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyAndOperationTest.java

Lines changed: 22 additions & 0 deletions
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;
@@ -88,6 +90,26 @@ public void testViewExpose() throws Exception {
8890
assertEquals(1, exposed.size());
8991
}
9092

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+
91113
public final String pathTest =
92114
"// Path of package: TopLevel\n"
93115
+ "// Path of owning membership: TopLevel/owningMembership\n"

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
}

0 commit comments

Comments
 (0)