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