use of org.geotoolkit.sml.xml.v100.ComponentType in project osate2 by osate.
the class RealizationImpl method setImplemented.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setImplemented(ComponentType newImplemented) {
ComponentType oldImplemented = implemented;
implemented = newImplemented;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.REALIZATION__IMPLEMENTED, oldImplemented, implemented));
}
}
use of org.geotoolkit.sml.xml.v100.ComponentType in project osate2 by osate.
the class AnnexUtil method getAllAnnexSubclauses.
/**
* return set of annex subclauses for a given Classifier according to the classifier extends hierarchy and implementation -> type inheritance
* Meta model class of interest e.g., EMV2AnnexSubclauseClass = ErrorModelPackage.eINSTANCE.getErrorModelSubclause();
* @param cl Classifier. Can be null. will return an empty set.
* @param eclass Meta model class of annex subclause of interest
* @return list of specific error model subclauses from specified classifier to those inherited
*/
public static EList<AnnexSubclause> getAllAnnexSubclauses(Classifier cl, EClass eclass) {
final EList<AnnexSubclause> result = new BasicEList<AnnexSubclause>();
if (cl == null) {
return result;
}
final EList<Classifier> classifiers = cl.getSelfPlusAllExtended();
if (cl instanceof ComponentImplementation) {
ComponentType ct = ((ComponentImplementation) cl).getType();
final EList<Classifier> tclassifiers = ct.getSelfPlusAllExtended();
classifiers.addAll(tclassifiers);
}
for (Classifier classifier : classifiers) {
EList<AnnexSubclause> oas = classifier.getOwnedAnnexSubclauses();
for (AnnexSubclause annexSubclause : oas) {
AnnexSubclause actualAnnexSubclause = (AnnexSubclause) getParsedAnnex(annexSubclause);
if (actualAnnexSubclause != null && actualAnnexSubclause.eClass().equals(eclass)) {
result.add(actualAnnexSubclause);
}
}
}
return result;
}
use of org.geotoolkit.sml.xml.v100.ComponentType in project osate2 by osate.
the class PropertiesLinkingService method findElementInContext.
protected static <T> T findElementInContext(Element referencingObject, Context context, String name, Class<T> validSearchResultType) {
NamedElement searchResult = null;
if (context == null) {
searchResult = AadlUtil.getContainingClassifier(referencingObject).findNamedElement(name);
} else if (context instanceof FeatureGroup) {
FeatureGroup featureGroup = (FeatureGroup) context;
while (featureGroup.getFeatureGroupType() == null && featureGroup.getFeatureGroupPrototype() == null && featureGroup.getRefined() instanceof FeatureGroup) {
featureGroup = (FeatureGroup) featureGroup.getRefined();
}
FeatureGroupType featureGroupType = null;
if (featureGroup.getFeatureGroupType() != null) {
featureGroupType = featureGroup.getFeatureGroupType();
} else if (featureGroup.getFeatureGroupPrototype() != null) {
featureGroupType = findFeatureGroupTypeForFeatureGroupPrototype(AadlUtil.getContainingClassifier(referencingObject), featureGroup.getFeatureGroupPrototype());
}
if (featureGroupType != null) {
searchResult = featureGroupType.findNamedElement(name);
}
} else if (context instanceof Feature) {
Feature feature = (Feature) context;
while (feature.getClassifier() == null && feature.getPrototype() == null && feature.getRefined() != null) {
feature = feature.getRefined();
}
Classifier featureClassifier = null;
if (feature.getClassifier() != null) {
featureClassifier = feature.getClassifier();
} else if (feature.getPrototype() != null) {
featureClassifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), feature.getPrototype());
}
if (featureClassifier != null) {
searchResult = featureClassifier.findNamedElement(name);
}
} else if (context instanceof Subcomponent) {
Subcomponent subcomponent = (Subcomponent) context;
while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
subcomponent = subcomponent.getRefined();
}
ComponentClassifier subcomponentClassifier = null;
if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
subcomponentClassifier = (ComponentClassifier) subcomponent.getSubcomponentType();
} else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
subcomponentClassifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), (ComponentPrototype) subcomponent.getSubcomponentType());
}
if (subcomponentClassifier != null) {
searchResult = subcomponentClassifier.findNamedElement(name);
}
} else if (context instanceof SubprogramCall) {
SubprogramCall subprogramCall = (SubprogramCall) context;
if (subprogramCall.getCalledSubprogram() instanceof ComponentClassifier) {
searchResult = ((ComponentClassifier) subprogramCall.getCalledSubprogram()).findNamedElement(name);
} else if (subprogramCall.getCalledSubprogram() instanceof SubprogramSubcomponent) {
Subcomponent subcomponent = (SubprogramSubcomponent) subprogramCall.getCalledSubprogram();
while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
subcomponent = subcomponent.getRefined();
}
ComponentClassifier subcomponentClassifier = null;
if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
subcomponentClassifier = (ComponentClassifier) subcomponent.getSubcomponentType();
} else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
subcomponentClassifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), (ComponentPrototype) subcomponent.getSubcomponentType());
}
if (subcomponentClassifier != null) {
searchResult = subcomponentClassifier.findNamedElement(name);
}
} else if (subprogramCall.getCalledSubprogram() instanceof SubprogramAccess) {
Feature access = (SubprogramAccess) subprogramCall.getCalledSubprogram();
while (access.getClassifier() == null && access.getPrototype() == null && access.getRefined() != null) {
access = access.getRefined();
}
Classifier accessClassifier = null;
if (access.getClassifier() != null) {
accessClassifier = access.getClassifier();
} else if (access.getPrototype() != null) {
CallContext callContext = subprogramCall.getContext();
if (callContext instanceof ComponentType) {
accessClassifier = findClassifierForComponentPrototype((ComponentType) callContext, access.getPrototype());
} else if (callContext instanceof FeatureGroup) {
FeatureGroup callContextFeatureGroup = (FeatureGroup) callContext;
FeatureGroupType prototypeContext = null;
while (callContextFeatureGroup.getFeatureGroupType() == null && callContextFeatureGroup.getFeatureGroupPrototype() == null && callContextFeatureGroup.getRefined() instanceof FeatureGroup) {
callContextFeatureGroup = (FeatureGroup) callContextFeatureGroup.getRefined();
}
if (callContextFeatureGroup.getFeatureGroupType() != null) {
prototypeContext = callContextFeatureGroup.getFeatureGroupType();
} else if (callContextFeatureGroup.getFeatureGroupPrototype() != null) {
prototypeContext = findFeatureGroupTypeForFeatureGroupPrototype(AadlUtil.getContainingClassifier(referencingObject), callContextFeatureGroup.getFeatureGroupPrototype());
}
if (prototypeContext != null) {
accessClassifier = findClassifierForComponentPrototype(prototypeContext, access.getPrototype());
}
} else if (callContext instanceof SubprogramGroupAccess) {
Feature callContextAccess = (SubprogramGroupAccess) callContext;
Classifier prototypeContext = null;
while (callContextAccess.getClassifier() == null && callContextAccess.getPrototype() == null && callContextAccess.getRefined() != null) {
callContextAccess = callContextAccess.getRefined();
}
if (callContextAccess.getClassifier() != null) {
prototypeContext = callContextAccess.getClassifier();
} else if (callContextAccess.getPrototype() != null) {
prototypeContext = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), callContextAccess.getPrototype());
}
if (prototypeContext != null) {
accessClassifier = findClassifierForComponentPrototype(prototypeContext, access.getPrototype());
}
} else if (callContext instanceof SubprogramGroupSubcomponent) {
Subcomponent callContextSubcomponent = (SubprogramGroupSubcomponent) callContext;
while (callContextSubcomponent.getSubcomponentType() == null && callContextSubcomponent.getRefined() != null) {
callContextSubcomponent = callContextSubcomponent.getRefined();
}
if (callContextSubcomponent.getSubcomponentType() instanceof ComponentClassifier) {
if (callContextSubcomponent.getOwnedPrototypeBindings().isEmpty()) {
accessClassifier = findClassifierForComponentPrototype(callContextSubcomponent.getClassifier(), access.getPrototype());
} else {
accessClassifier = findClassifierForComponentPrototype(callContextSubcomponent.getClassifier(), callContextSubcomponent, access.getPrototype());
}
} else if (callContextSubcomponent.getSubcomponentType() instanceof ComponentPrototype) {
ComponentClassifier prototypeContext = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), callContextSubcomponent.getPrototype());
if (prototypeContext != null) {
accessClassifier = findClassifierForComponentPrototype(prototypeContext, access.getPrototype());
}
}
} else // callContext is null.
{
accessClassifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), access.getPrototype());
}
}
if (accessClassifier != null) {
searchResult = accessClassifier.findNamedElement(name);
}
} else if (subprogramCall.getCalledSubprogram() instanceof ComponentPrototype) {
ComponentClassifier classifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(referencingObject), (ComponentPrototype) subprogramCall.getCalledSubprogram());
if (classifier != null) {
searchResult = classifier.findNamedElement(name);
}
}
}
if (validSearchResultType.isInstance(searchResult)) {
return validSearchResultType.cast(searchResult);
} else {
return null;
}
}
use of org.geotoolkit.sml.xml.v100.ComponentType in project osate2 by osate.
the class Aadl2DependentElementsCalculator method getDependentElementURIs.
@Override
public List<URI> getDependentElementURIs(EObject baseElement, IProgressMonitor monitor) {
List<URI> dependentElementURIs = super.getDependentElementURIs(baseElement, monitor);
if (baseElement instanceof ComponentType) {
AadlPackage pkg = EcoreUtil2.getContainerOfType(baseElement, AadlPackage.class);
EcoreUtil2.getAllContentsOfType(pkg, ComponentImplementation.class).stream().filter(impl -> impl.getType() == baseElement).map(EcoreUtil::getURI).forEach(dependentElementURIs::add);
}
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
return dependentElementURIs;
}
use of org.geotoolkit.sml.xml.v100.ComponentType in project osate2 by osate.
the class Aadl2RenameStrategy method revertDeclarationChange.
@Override
public void revertDeclarationChange(ResourceSet resourceSet) {
super.revertDeclarationChange(resourceSet);
// rename component implementations
EObject targetElement = resourceSet.getEObject(getTargetElementOriginalURI(), false);
if (targetElement instanceof ComponentType) {
String oldName = getTargetElementOriginalURI().fragment();
oldName = oldName.substring(oldName.lastIndexOf('.') + 1);
AadlPackage pkg = EcoreUtil2.getContainerOfType(targetElement, AadlPackage.class);
for (ComponentImplementation impl : EcoreUtil2.getAllContentsOfType(pkg, ComponentImplementation.class)) {
if (impl.getType() == targetElement) {
impl.setName(oldName + "." + impl.getImplementationName());
}
}
}
}
Aggregations