Skip to content

Commit d37a245

Browse files
committed
ST6RI-829 Implemented stable IDs for all standard library elements.
1 parent f27f22e commit d37a245

4 files changed

Lines changed: 71 additions & 6 deletions

File tree

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()) {

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import java.lang.reflect.InvocationTargetException;
2626
import java.util.Collection;
27+
import java.util.UUID;
28+
2729
import org.eclipse.emf.common.notify.NotificationChain;
2830
import org.eclipse.emf.common.util.BasicEList;
2931
import org.eclipse.emf.common.util.EList;
@@ -42,6 +44,7 @@
4244
import org.omg.sysml.lang.sysml.Relationship;
4345
import org.omg.sysml.lang.sysml.SysMLPackage;
4446
import org.omg.sysml.lang.sysml.VisibilityKind;
47+
import org.omg.sysml.util.ElementUtil;
4548

4649
/**
4750
* <!-- begin-user-doc -->
@@ -521,6 +524,31 @@ public String unqualifiedNameOf(String qualifiedName) {
521524
throw new WrappedException(ite);
522525
}
523526
}
527+
528+
/**
529+
* <!-- begin-user-doc -->
530+
* If the Namespace is the root Namespace of a standard library package, then give it a stable elementId.
531+
* <!-- end-user-doc -->
532+
* @generated NOT
533+
*/
534+
@Override
535+
public String getElementId() {
536+
if (elementId == null && getOwningRelationship() == null) {
537+
EList<Element> ownedMembers = getOwnedMember();
538+
if (!ownedMembers.isEmpty()) {
539+
Element firstOwnedMember = ownedMembers.get(0);
540+
if (ElementUtil.isStandardLibraryElement(firstOwnedMember) &&
541+
firstOwnedMember.libraryNamespace() == firstOwnedMember) {
542+
String qualifiedName = firstOwnedMember.getQualifiedName();
543+
if (qualifiedName != null) {
544+
UUID namespaceUUID = UUID.fromString(firstOwnedMember.getElementId());
545+
elementId = ElementUtil.constructNameUUID(namespaceUUID, qualifiedName + "/owner").toString();
546+
}
547+
}
548+
}
549+
}
550+
return super.getElementId();
551+
}
524552

525553
/**
526554
* <!-- begin-user-doc -->

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

Lines changed: 29 additions & 1 deletion
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, 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
@@ -20,6 +20,8 @@
2020
*******************************************************************************/
2121
package org.omg.sysml.lang.sysml.impl;
2222

23+
import java.util.UUID;
24+
2325
import org.eclipse.emf.common.notify.NotificationChain;
2426
import org.eclipse.emf.common.util.EList;
2527

@@ -33,6 +35,7 @@
3335
import org.omg.sysml.lang.sysml.Element;
3436
import org.omg.sysml.lang.sysml.OwningMembership;
3537
import org.omg.sysml.lang.sysml.SysMLPackage;
38+
import org.omg.sysml.util.ElementUtil;
3639

3740
/**
3841
* <!-- begin-user-doc -->
@@ -367,6 +370,31 @@ public boolean isSetMemberName() {
367370
return false;
368371
}
369372

373+
/**
374+
* <!-- begin-user-doc -->
375+
* If the OwningMembership is not itself a standard library Element, but its ownedMemberElement
376+
* is a standard library Package, then give the OwningMembership a stable elementId anyway.
377+
* (This will give a stable elementID to the owningMembership of a top-level standard library Package.)
378+
* <!-- end-user-doc -->
379+
* @generated NOT
380+
*/
381+
@Override
382+
public String getElementId() {
383+
if (elementId == null) {
384+
Element ownedMemberElement = getOwnedMemberElement();
385+
if (!ElementUtil.isStandardLibraryElement(this) &&
386+
ElementUtil.isStandardLibraryElement(ownedMemberElement) &&
387+
ownedMemberElement.libraryNamespace() == ownedMemberElement) {
388+
String path = path();
389+
if (path != null) {
390+
UUID namespaceUUID = UUID.fromString(ownedMemberElement.getElementId());
391+
elementId = ElementUtil.constructNameUUID(namespaceUUID, path).toString();
392+
}
393+
}
394+
}
395+
return super.getElementId();
396+
}
397+
370398
/**
371399
* <!-- begin-user-doc -->
372400
* <!-- end-user-doc -->

0 commit comments

Comments
 (0)