Skip to content

Commit 57c4019

Browse files
committed
KERML_-119 Updated setting delegates for Annotation & AnnotatingElement.
1 parent fa125f5 commit 57c4019

6 files changed

Lines changed: 180 additions & 6 deletions
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.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.AnnotatingElement;
28+
import org.omg.sysml.lang.sysml.Annotation;
29+
import org.omg.sysml.lang.sysml.Element;
30+
import org.omg.sysml.util.NonNotifyingEObjectEList;
31+
32+
public class AnnotatingElement_annotation_SettingDelegate extends BasicDerivedListSettingDelegate {
33+
34+
public AnnotatingElement_annotation_SettingDelegate(EStructuralFeature eStructuralFeature) {
35+
super(eStructuralFeature);
36+
}
37+
38+
@Override
39+
protected EList<Annotation> basicGet(InternalEObject owner) {
40+
EList<Annotation> annotations = new NonNotifyingEObjectEList<>(Element.class, owner, eStructuralFeature.getFeatureID());
41+
Annotation owningAnnotatingRelationship = ((AnnotatingElement)owner).getOwningAnnotatingRelationship();
42+
if (owningAnnotatingRelationship != null) {
43+
annotations.add(owningAnnotatingRelationship);
44+
}
45+
annotations.addAll(((AnnotatingElement)owner).getOwnedAnnotatingRelationship());
46+
return annotations;
47+
}
48+
49+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2024, 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
@@ -40,7 +40,7 @@ protected EList<Annotation> basicGet(InternalEObject owner) {
4040
((Element)owner).getOwnedRelationship().stream().
4141
filter(Annotation.class::isInstance).
4242
map(Annotation.class::cast).
43-
filter(ann->ann.getAnnotatingElement() == owner).
43+
filter(ann->ann.getAnnotatedElement() != owner).
4444
forEachOrdered(annotations::add);
4545
return annotations;
4646
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.setting;
23+
24+
import org.eclipse.emf.ecore.EStructuralFeature;
25+
import org.eclipse.emf.ecore.InternalEObject;
26+
import org.omg.sysml.lang.sysml.Annotation;
27+
import org.omg.sysml.lang.sysml.Element;
28+
29+
public class AnnotatingElement_owningAnnotatingRelationship_SettingDelegate extends Relationship_owningRelatedElement_SettingDelegate {
30+
31+
public AnnotatingElement_owningAnnotatingRelationship_SettingDelegate(EStructuralFeature eStructuralFeature) {
32+
super(eStructuralFeature);
33+
}
34+
35+
@Override
36+
public Element basicGet(InternalEObject annotatingElement) {
37+
Element owningRelatedElement = basicGet(annotatingElement, Element.class);
38+
return owningRelatedElement instanceof Annotation? owningRelatedElement: null;
39+
}
40+
41+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.setting;
23+
24+
import org.eclipse.emf.ecore.EStructuralFeature;
25+
import org.eclipse.emf.ecore.InternalEObject;
26+
import org.omg.sysml.lang.sysml.Annotation;
27+
import org.omg.sysml.lang.sysml.Element;
28+
29+
public class Annotation_annotatingElement_SettingDelegate extends BasicDerivedObjectSettingDelegate {
30+
31+
public Annotation_annotatingElement_SettingDelegate(EStructuralFeature eStructuralFeature) {
32+
super(eStructuralFeature);
33+
}
34+
35+
@Override
36+
public Element basicGet(InternalEObject annotation) {
37+
Element ownedAnnotatingElement = ((Annotation)annotation).getOwnedAnnotatingElement();
38+
return ownedAnnotatingElement != null? ownedAnnotatingElement:
39+
((Annotation)annotation).getOwningAnnotatingElement();
40+
}
41+
42+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.setting;
23+
24+
import org.eclipse.emf.ecore.EStructuralFeature;
25+
import org.eclipse.emf.ecore.InternalEObject;
26+
import org.omg.sysml.lang.sysml.AnnotatingElement;
27+
import org.omg.sysml.lang.sysml.Annotation;
28+
import org.omg.sysml.lang.sysml.Element;
29+
30+
public class Annotation_ownedAnnotatingElement_SettingDelegate extends BasicDerivedObjectSettingDelegate {
31+
32+
public Annotation_ownedAnnotatingElement_SettingDelegate(EStructuralFeature eStructuralFeature) {
33+
super(eStructuralFeature);
34+
}
35+
36+
@Override
37+
public Element basicGet(InternalEObject annotation) {
38+
return ((Annotation)annotation).getOwnedRelatedElement().stream().
39+
filter(AnnotatingElement.class::isInstance).
40+
findFirst().orElse(null);
41+
}
42+
43+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2024, 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
@@ -23,7 +23,7 @@
2323

2424
import org.eclipse.emf.ecore.EStructuralFeature;
2525
import org.eclipse.emf.ecore.InternalEObject;
26-
import org.omg.sysml.lang.sysml.Annotation;
26+
import org.omg.sysml.lang.sysml.AnnotatingElement;
2727
import org.omg.sysml.lang.sysml.Element;
2828

2929
public class Annotation_owningAnnotatingElement_SettingDelegate extends Relationship_owningRelatedElement_SettingDelegate {
@@ -35,8 +35,7 @@ public Annotation_owningAnnotatingElement_SettingDelegate(EStructuralFeature eSt
3535
@Override
3636
public Element basicGet(InternalEObject annotation) {
3737
Element owningRelatedElement = basicGet(annotation, Element.class);
38-
return owningRelatedElement == ((Annotation)annotation).getAnnotatingElement()?
39-
owningRelatedElement: null;
38+
return owningRelatedElement instanceof AnnotatingElement? owningRelatedElement: null;
4039
}
4140

4241
}

0 commit comments

Comments
 (0)