Search in sources :

Example 51 with ComponentType

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));
    }
}
Also used : ComponentType(org.osate.aadl2.ComponentType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 52 with ComponentType

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;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 53 with ComponentType

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;
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroup(org.osate.aadl2.FeatureGroup) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) ComponentType(org.osate.aadl2.ComponentType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Feature(org.osate.aadl2.Feature) CallContext(org.osate.aadl2.CallContext) SubprogramGroupAccess(org.osate.aadl2.SubprogramGroupAccess) ComponentPrototype(org.osate.aadl2.ComponentPrototype) SubprogramAccess(org.osate.aadl2.SubprogramAccess) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) SubprogramCall(org.osate.aadl2.SubprogramCall)

Example 54 with ComponentType

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;
}
Also used : ComponentType(org.osate.aadl2.ComponentType) AadlPackage(org.osate.aadl2.AadlPackage) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) URI(org.eclipse.emf.common.util.URI)

Example 55 with ComponentType

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());
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) AadlPackage(org.osate.aadl2.AadlPackage) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

ComponentType (org.osate.aadl2.ComponentType)73 ComponentImplementation (org.osate.aadl2.ComponentImplementation)42 Classifier (org.osate.aadl2.Classifier)33 ComponentClassifier (org.osate.aadl2.ComponentClassifier)21 ArrayList (java.util.ArrayList)18 EObject (org.eclipse.emf.ecore.EObject)16 NamedElement (org.osate.aadl2.NamedElement)15 AnnexSubclause (org.osate.aadl2.AnnexSubclause)13 Feature (org.osate.aadl2.Feature)13 BasicEList (org.eclipse.emf.common.util.BasicEList)11 AadlPackage (org.osate.aadl2.AadlPackage)11 HashSet (java.util.HashSet)10 FeatureGroupType (org.osate.aadl2.FeatureGroupType)10 List (java.util.List)9 Subcomponent (org.osate.aadl2.Subcomponent)8 FeatureGroup (org.osate.aadl2.FeatureGroup)7 EList (org.eclipse.emf.common.util.EList)6 Property (org.osate.aadl2.Property)6 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)6 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)5