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();
}
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();
}
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();
}
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();
}
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;
}
Aggregations