Skip to content

Commit f61a1df

Browse files
authored
Merge pull request #748 from Systems-Modeling/ST6RI-919
ST6RI-919 Update derived properties to handle implied relationships
2 parents 4de3265 + 140d243 commit f61a1df

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021-2022, 2025 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021-2022, 2025, 2026 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
@@ -24,6 +24,7 @@
2424
import static org.junit.Assert.assertArrayEquals;
2525
import static org.junit.Assert.assertEquals;
2626
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertNotNull;
2728
import static org.junit.Assert.assertNull;
2829
import static org.junit.Assert.assertTrue;
2930

@@ -36,6 +37,7 @@
3637
import org.omg.sysml.lang.sysml.ActionUsage;
3738
import org.omg.sysml.lang.sysml.AttributeUsage;
3839
import org.omg.sysml.lang.sysml.Comment;
40+
import org.omg.sysml.lang.sysml.ConnectionDefinition;
3941
import org.omg.sysml.lang.sysml.Definition;
4042
import org.omg.sysml.lang.sysml.Documentation;
4143
import org.omg.sysml.lang.sysml.Element;
@@ -351,4 +353,35 @@ public void testLocale() throws Exception {
351353
assertEquals("comment.locale", "en_US", comment.getLocale());
352354
assertEquals("doc.locale", "en_US", doc.getLocale());
353355
}
356+
357+
public final String crossFeatureTest =
358+
"package Test {"
359+
+ " part def A {"
360+
+ " ref b : B;"
361+
+ " }"
362+
+ " part def B;"
363+
+ " connection def C {"
364+
+ " end [0..1] ref end1 : A;"
365+
+ " end ref end2 : B crosses end1.b;"
366+
+ " }"
367+
+ "}";
368+
369+
@Test
370+
public void testCrossFeature() throws Exception {
371+
SysMLInteractive instance = getSysMLInteractiveInstance();
372+
SysMLInteractiveResult result = instance.process(crossFeatureTest);
373+
Element root = result.getRootElement();
374+
Namespace test = (Namespace)((Namespace)root).getOwnedMember().get(0);
375+
Definition a = (Definition)test.getOwnedMember().get(0);
376+
Usage a_b = a.getOwnedUsage().get(0);
377+
ConnectionDefinition c = (ConnectionDefinition)test.getOwnedMember().get(2);
378+
List<Feature> ends = c.getAssociationEnd();
379+
Usage end1 = (Usage)ends.get(0);
380+
Usage end2 = (Usage)ends.get(1);
381+
Feature ownedCrossFeature = end1.ownedCrossFeature();
382+
383+
assertNotNull("end1 owned cross feature", ownedCrossFeature);
384+
assertEquals("end1 cross feature", end1.ownedCrossFeature(), end1.getCrossFeature());
385+
assertEquals("end2 cross feature", a_b, end2.getCrossFeature().getFeatureTarget());
386+
}
354387
}
Lines changed: 3 additions & 15 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, 2026 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
@@ -21,13 +21,11 @@
2121

2222
package org.omg.sysml.delegate.setting;
2323

24-
import java.util.List;
25-
2624
import org.eclipse.emf.ecore.EObject;
2725
import org.eclipse.emf.ecore.EStructuralFeature;
2826
import org.eclipse.emf.ecore.InternalEObject;
29-
import org.omg.sysml.lang.sysml.CrossSubsetting;
3027
import org.omg.sysml.lang.sysml.Feature;
28+
import org.omg.sysml.util.FeatureUtil;
3129

3230
public class Feature_crossFeature_SettingDelegate extends BasicDerivedObjectSettingDelegate {
3331

@@ -37,17 +35,7 @@ public Feature_crossFeature_SettingDelegate(EStructuralFeature eStructuralFeatur
3735

3836
@Override
3937
protected EObject basicGet(InternalEObject owner) {
40-
CrossSubsetting subsetting = ((Feature)owner).getOwnedCrossSubsetting();
41-
if (subsetting != null) {
42-
Feature crossedFeature = subsetting.getCrossedFeature();
43-
if (crossedFeature != null) {
44-
List<Feature> chainingFeatures = crossedFeature.getChainingFeature();
45-
if (chainingFeatures.size() >=2) {
46-
return chainingFeatures.get(1);
47-
}
48-
}
49-
}
50-
return null;
38+
return FeatureUtil.getCrossFeatureOf((Feature)owner);
5139
}
5240

5341
}

0 commit comments

Comments
 (0)