Search in sources :

Example 26 with ErrorModelSubclause

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

the class EMV2Properties method getPropertyInClassifier.

/**
 * 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 of the classifier.
 * @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> getPropertyInClassifier(String propertyName, Classifier cl, NamedElement target, Stack<NamedElement> ciStack, ErrorTypes ts) {
    if (cl != null) {
        // deals with inherited properties by walking subclause inheritance
        EList<ErrorModelSubclause> emslist = EMV2Util.getAllContainingClassifierEMV2Subclauses(cl);
        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 27 with ErrorModelSubclause

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause 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 28 with ErrorModelSubclause

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

the class EMV2Util method getAllPropagationPoints.

/**
 * return list of propagation points including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<PropagationPoint> list of propagation points as HashMap for quick lookup of names
 */
public static Collection<PropagationPoint> getAllPropagationPoints(Classifier cl) {
    HashMap<String, PropagationPoint> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<PropagationPoint> eflist = errorModelSubclause.getPoints();
        for (PropagationPoint propPoint : eflist) {
            if (!result.containsKey(propPoint.getName())) {
                result.put(propPoint.getName(), propPoint);
            }
        }
    }
    return result.values();
}
Also used : PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) QualifiedPropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedPropagationPoint) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) LinkedHashMap(java.util.LinkedHashMap)

Example 29 with ErrorModelSubclause

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

the class EMV2Util method getAllErrorSinks.

/**
 * return list of error sinks including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<ErrorSource> list of error sinks declared in the flow section
 */
public static Collection<ErrorSink> getAllErrorSinks(Classifier cl) {
    HashMap<String, ErrorSink> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
        for (ErrorFlow errorFlow : eflist) {
            if (errorFlow instanceof ErrorSink) {
                if (!result.containsKey(errorFlow.getName())) {
                    result.put(errorFlow.getName(), (ErrorSink) errorFlow);
                }
            }
        }
    }
    return result.values();
}
Also used : ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with ErrorModelSubclause

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

the class EMV2Util method getErrorBehaviorStateMachine.

/**
 * get Error Behavior State Machine (ebsm) in context  of the element
 * This means the ebsm is either an enclosing container or the ebsm is referenced by an enclosing use behavior declaration.
 * @param element
 * @return
 */
public static ErrorBehaviorStateMachine getErrorBehaviorStateMachine(Element element) {
    EObject container = element;
    // find enclosing ebsm
    while (container != null) {
        if (container instanceof ErrorBehaviorStateMachine) {
            return (ErrorBehaviorStateMachine) container;
        }
        container = container.eContainer();
    }
    // now find it in use behavior clause
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(element);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        ErrorBehaviorStateMachine ebsm = errorModelSubclause.getUseBehavior();
        if (ebsm != null) {
            return ebsm;
        }
    }
    return null;
}
Also used : ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) EObject(org.eclipse.emf.ecore.EObject) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine)

Aggregations

ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)32 LinkedHashMap (java.util.LinkedHashMap)15 Classifier (org.osate.aadl2.Classifier)9 ErrorBehaviorStateMachine (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine)7 NamedElement (org.osate.aadl2.NamedElement)6 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)5 URI (org.eclipse.emf.common.util.URI)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 ComponentImplementation (org.osate.aadl2.ComponentImplementation)4 EObject (org.eclipse.emf.ecore.EObject)3 AadlPackage (org.osate.aadl2.AadlPackage)3 ComponentType (org.osate.aadl2.ComponentType)3 Subcomponent (org.osate.aadl2.Subcomponent)3 AadlGraphicalEditorException (org.osate.ge.aadl2.AadlGraphicalEditorException)3 EMV2PropertyAssociation (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)3 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)3 List (java.util.List)2 Optional (java.util.Optional)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ErrorModelLibrary (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary)2