Search in sources :

Example 16 with EMV2PropertyAssociation

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.

the class EMV2Properties method getPropertyInInstanceHierarchy.

/**
 * recurse up the component hierarchy to look for the PA from the outside in.
 * For each component instance, handle inherited properties based on subclause inheritance ordering
 * @param propertyName
 * @param ci the component instance whose subclause property section we are looking for the property
 * @param target
 * @param ciStack stack of CIS that are down the hierarchy towards the target emv2 subclause
 * @param ts
 * @return
 */
private static List<EMV2PropertyAssociation> getPropertyInInstanceHierarchy(String propertyName, ComponentInstance ci, NamedElement target, Stack<NamedElement> ciStack, ErrorTypes ts) {
    if (ci != null) {
        if (ci.getContainingComponentInstance() != null) {
            ciStack.push(ci);
            List<EMV2PropertyAssociation> result = getPropertyInInstanceHierarchy(propertyName, ci.getContainingComponentInstance(), target, ciStack, ts);
            ciStack.pop();
            if (!result.isEmpty()) {
                return result;
            }
        }
        // deals with inherited properties by walking subclause inheritance
        List<ErrorModelSubclause> emslist = EMV2Util.getAllContainingClassifierEMV2Subclauses(ci);
        for (ErrorModelSubclause ems : emslist) {
            List<EMV2PropertyAssociation> props = ems.getProperties();
            List<EMV2PropertyAssociation> result = getMatchingPropertiesInList(props, propertyName, target, ciStack, ts);
            if (!result.isEmpty()) {
                return result;
            }
        }
    }
    return Collections.emptyList();
}
Also used : ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)

Example 17 with EMV2PropertyAssociation

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.

the class EMV2Properties method getPropertyInInstanceHierarchy.

/**
 * retrieve an error model property (such as Hazard) attached to an error model element based on contained property associations
 * in the annex subclause properties section.
 * Here we come down the component instance hierarchy to find the outmost property association
 * in the properties section of the annex subclauses. Those are the ones that can override down the component hierarchy.
 * @param propertyName name of property we are looking for
 * @param ci component instance whose EM element has the property
 * @param target the error model element (which is optionally followed by a type that is contained in the typeset ts
 * @param ts the type set
 * @return Containmentpath of the PA that matches the parameters.
 * we return the path because the PA applies to more than element
 */
public static List<EMV2PropertyAssociation> getPropertyInInstanceHierarchy(String propertyName, NamedElement ci, NamedElement target, ErrorTypes ts) {
    if (ci == null) {
        return Collections.emptyList();
    }
    Stack<NamedElement> ciStack = new Stack<NamedElement>();
    ComponentClassifier cl = null;
    if (ci instanceof ComponentInstance) {
        // ciStack will contain the nested set of component instances
        return getPropertyInInstanceHierarchy(propertyName, (ComponentInstance) ci, target, ciStack, ts);
    }
    if (ci instanceof Subcomponent) {
        // look in enclosing component impl first. Then in classifier of subcomponent
        cl = (ComponentClassifier) ((Subcomponent) ci).getContainingClassifier();
        ciStack.push(ci);
        // ciStack has subcomponent whose error model is of interest
        List<EMV2PropertyAssociation> result = getPropertyInClassifier(propertyName, cl, target, ciStack, ts);
        if (!result.isEmpty()) {
            return result;
        }
        ciStack.pop();
        cl = ((Subcomponent) ci).getAllClassifier();
        return getPropertyInClassifier(propertyName, cl, target, ciStack, ts);
    }
    if (ci instanceof ComponentClassifier) {
        cl = (ComponentClassifier) ci;
        // empty ciStack
        return getPropertyInClassifier(propertyName, cl, target, ciStack, ts);
    }
    return Collections.emptyList();
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) NamedElement(org.osate.aadl2.NamedElement) Stack(java.util.Stack)

Example 18 with EMV2PropertyAssociation

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.

the class EMV2Util method getLastSubcomponent.

/**
 * return the last subcomponent in the EMV2Path
 * @param epath EMV2Path
 * @return Subcomponent
 */
public static Subcomponent getLastSubcomponent(EMV2Path epath) {
    if (epath.getContainmentPath() != null) {
        // handle paths that come from the EMV2PropertyAssociation with the new syntax for the core path
        ContainmentPathElement last = getLast(epath.getContainmentPath());
        if (last.getNamedElement() instanceof Subcomponent) {
            return (Subcomponent) last.getNamedElement();
        }
        return null;
    }
    EMV2PathElement epe = epath.getEmv2Target();
    Subcomponent result = null;
    while (epe != null) {
        if (epe.getNamedElement() instanceof Subcomponent) {
            result = (Subcomponent) epe.getNamedElement();
        }
        epe = epe.getPath();
    }
    return result;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) Subcomponent(org.osate.aadl2.Subcomponent) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Aggregations

EMV2PropertyAssociation (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)14 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)7 NamedElement (org.osate.aadl2.NamedElement)6 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)5 EMV2Path (org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path)5 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)5 EList (org.eclipse.emf.common.util.EList)4 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)4 ListValue (org.osate.aadl2.ListValue)4 Property (org.osate.aadl2.Property)4 PropertyExpression (org.osate.aadl2.PropertyExpression)4 RecordValue (org.osate.aadl2.RecordValue)4 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)4 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)4 ErrorTypes (org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)4 ArrayList (java.util.ArrayList)3 Classifier (org.osate.aadl2.Classifier)3 Element (org.osate.aadl2.Element)3 StringLiteral (org.osate.aadl2.StringLiteral)3 Subcomponent (org.osate.aadl2.Subcomponent)3