Search in sources :

Example 31 with NamedElement

use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.

the class AgreeScopeProvider method getNamedElementsFromClassifier.

private Map<String, NamedElement> getNamedElementsFromClassifier(Classifier ctx, boolean fromCompImpl) {
    Map<String, NamedElement> components = new HashMap<>();
    components.putAll(getNamedElements(getAadlContainer(ctx)));
    for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(ctx, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
        AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
        components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
    }
    Classifier extended = ctx.getExtended();
    if (extended != null) {
        components.putAll(getNamedElementsFromClassifier(extended, false));
    }
    if (ctx instanceof ComponentImplementation) {
        components.putAll(getNamedElementsFromClassifier(((ComponentImplementation) ctx).getType(), true));
        ArrayList<NamedElement> nes = new ArrayList<>();
        nes.addAll(((ComponentImplementation) ctx).getAllSubcomponents());
        nes.addAll(((ComponentImplementation) ctx).getAllConnections());
        components.putAll(toNamedElementMap(nes));
    } else if (ctx instanceof ComponentType) {
        if (fromCompImpl) {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getAllFeatures());
            components.putAll(toNamedElementMap(nes));
        } else {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getOwnedFeatures());
            components.putAll(toNamedElementMap(nes));
        }
    }
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 32 with NamedElement

use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.

the class AgreeAADLPropertyUtils method getPropertyEnumString.

public static String getPropertyEnumString(NamedElement namedEl, String property) {
    Property prop = Aadl2GlobalScopeUtil.get(namedEl, Aadl2Package.eINSTANCE.getProperty(), property);
    EnumerationLiteral lit = PropertyUtils.getEnumLiteral(namedEl, prop);
    return lit.getName();
}
Also used : Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 33 with NamedElement

use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.

the class AgreeAADLPropertyUtils method getPropertyList.

public static List<PropertyExpression> getPropertyList(NamedElement namedEl, String property) {
    List<PropertyExpression> els = new ArrayList<>();
    Property prop = Aadl2GlobalScopeUtil.get(namedEl, Aadl2Package.eINSTANCE.getProperty(), property);
    ListValue listExpr = (ListValue) PropertyUtils.getSimplePropertyListValue(namedEl, prop);
    for (PropertyExpression propExpr : listExpr.getOwnedListElements()) {
        els.add(propExpr);
    }
    return els;
}
Also used : ListValue(org.osate.aadl2.ListValue) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 34 with NamedElement

use of org.osate.aadl2.NamedElement in project osate2 by osate.

the class Arinc653 method getDal.

public static Optional<SupportedDalType> getDal(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getDal_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(SupportedDalType.valueOf(resolved));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 35 with NamedElement

use of org.osate.aadl2.NamedElement in project osate2 by osate.

the class CodeGenerationProperties method getParameterUsage.

public static Optional<ParameterUsage> getParameterUsage(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getParameterUsage_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(ParameterUsage.valueOf(resolved));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

Property (org.osate.aadl2.Property)351 PropertyExpression (org.osate.aadl2.PropertyExpression)291 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)236 NamedElement (org.osate.aadl2.NamedElement)229 BasicProperty (org.osate.aadl2.BasicProperty)90 ListValue (org.osate.aadl2.ListValue)63 EObject (org.eclipse.emf.ecore.EObject)50 UnitLiteral (org.osate.aadl2.UnitLiteral)48 Classifier (org.osate.aadl2.Classifier)46 ArrayList (java.util.ArrayList)45 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)41 PropertyAssociation (org.osate.aadl2.PropertyAssociation)38 ComponentClassifier (org.osate.aadl2.ComponentClassifier)37 Subcomponent (org.osate.aadl2.Subcomponent)35 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)32 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)32 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)31 ComponentImplementation (org.osate.aadl2.ComponentImplementation)30 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 Element (org.osate.aadl2.Element)28