Skip to content

Commit

Permalink
Merge pull request #590 from Systems-Modeling/ST6RI-793
Browse files Browse the repository at this point in the history
ST6RI-793 Transition source cannot be a feature chain
  • Loading branch information
seidewitz authored Sep 6, 2024
2 parents 3187a2e + 82af8b9 commit 017e0ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@

package org.omg.sysml.delegate.setting;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.ActionUsage;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Membership;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.TransitionUsage;
import org.omg.sysml.util.NamespaceUtil;
import org.omg.sysml.util.FeatureUtil;
import org.omg.sysml.util.UsageUtil;

public class TransitionUsage_source_SettingDelegate extends BasicDerivedObjectSettingDelegate {

Expand All @@ -40,14 +38,8 @@ public TransitionUsage_source_SettingDelegate(EStructuralFeature eStructuralFeat

@Override
protected EObject basicGet(InternalEObject owner) {
NamespaceUtil.addAdditionalMembersTo((TransitionUsage)owner);
EList<Membership> ownedMemberships = ((TransitionUsage)owner).getOwnedMembership();
if (ownedMemberships.isEmpty()) {
return null;
} else {
Element member = ownedMemberships.get(0).getMemberElement();
return member instanceof ActionUsage? (ActionUsage)member: null;
}
Feature source = UsageUtil.getSourceFeatureOf((TransitionUsage)owner);
return source == null? null: FeatureUtil.getBasicFeatureOf(source);
}

}
13 changes: 12 additions & 1 deletion org.omg.sysml/src/org/omg/sysml/util/UsageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static Feature getSourceFeature(Feature feature) {
if (owningNamespace instanceof TransitionUsage) {
TransitionUsage transition = (TransitionUsage)owningNamespace;
if (transition.getSuccession() == feature) {
return transition.getSource();
return getSourceFeatureOf(transition);
}
}
return getPreviousFeature(feature);
Expand Down Expand Up @@ -377,6 +377,17 @@ private static boolean hasIncomingTransitionsIn(Type container, StateUsage state

// Transitions

public static Feature getSourceFeatureOf(TransitionUsage transition) {
NamespaceUtil.addAdditionalMembersTo(transition);
return transition.getOwnedMembership().stream().
filter(mem->!(mem instanceof FeatureMembership)).
map(Membership::getMemberElement).
filter(Feature.class::isInstance).
map(Feature.class::cast).
filter(f->FeatureUtil.getBasicFeatureOf(f) instanceof ActionUsage).
findFirst().orElse(null);
}

public static Feature getTransitionSourceOf(Feature transition) {
Feature source= transition instanceof TransitionUsage? ((TransitionUsage)transition).getSource():
transition instanceof Succession? ((Succession)transition).getSourceFeature():
Expand Down

0 comments on commit 017e0ba

Please sign in to comment.