use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.
the class PropertiesValidator method getMasterModes.
public List<Mode> getMasterModes(ContainedNamedElement cne) {
List<Mode> masterModes = new ArrayList<Mode>();
ComponentClassifier componentClassifier = null;
Subcomponent lastSubcomponent = getLastSubcomponent(cne);
if (null == lastSubcomponent) {
Classifier classifier = cne.getContainingClassifier();
if (classifier instanceof ComponentClassifier) {
componentClassifier = (ComponentClassifier) classifier;
}
} else {
componentClassifier = lastSubcomponent.getAllClassifier();
if (null != componentClassifier) {
masterModes = componentClassifier.getAllModes();
}
}
if (null != componentClassifier) {
masterModes = componentClassifier.getAllModes();
}
return masterModes;
}
use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.
the class PropertiesValidator method checkConstantProperty.
protected void checkConstantProperty(PropertyAssociation assoc) {
Property property = assoc.getProperty();
if (!property.eIsProxy()) {
EList<ContainedNamedElement> appliesTos = assoc.getAppliesTos();
if (appliesTos == null || appliesTos.isEmpty()) {
NamedElement holder = (NamedElement) assoc.getOwner();
if (holder.acceptsProperty(property)) {
checkOverridingConstant(holder, assoc);
}
} else {
for (ContainedNamedElement cne : assoc.getAppliesTos()) {
if (cne.getContainmentPathElements().size() == 1) {
ContainmentPathElement cpe = cne.getContainmentPathElements().get(0);
NamedElement ne = cpe.getNamedElement();
if (!ne.eIsProxy() && ne.acceptsProperty(property)) {
checkOverridingConstant(ne, assoc);
}
}
}
}
}
}
use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.
the class PropertiesValidator method checkModalAppliesTo.
public void checkModalAppliesTo(PropertyAssociation pa) {
boolean error = false;
List<ContainedNamedElement> appliesTo = pa.getAppliesTos();
if (null != appliesTo && appliesTo.size() > 1) {
List<ModalPropertyValue> mpvs = pa.getOwnedValues();
if (null != mpvs && mpvs.size() > 0) {
for (ModalPropertyValue mpv : mpvs) {
List<Mode> inModes = mpv.getInModes();
if (null != inModes && inModes.size() > 0) {
error = true;
break;
}
}
}
}
if (error) {
error(pa, "If property value is assigned to a mode there can only be one element in the applies to statement.");
}
}
use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.
the class PropertiesValidator method getLastSubcomponent.
public Subcomponent getLastSubcomponent(ContainedNamedElement cne) {
Subcomponent subComponent = null;
List<ContainmentPathElement> cpes = cne.getContainmentPathElements();
for (int i = cpes.size() - 1; i > -1; i--) {
ContainmentPathElement cpe = cpes.get(i);
if (cpe.getNamedElement() instanceof Subcomponent) {
subComponent = (Subcomponent) cpe.getNamedElement();
return subComponent;
}
}
return subComponent;
}
use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.
the class PropertiesValidator method unparseAppliesTo.
private static String unparseAppliesTo(final ContainedNamedElement cna) {
final StringBuffer sb = new StringBuffer();
EList<ContainmentPathElement> path = cna.getContainmentPathElements();
for (final Iterator<ContainmentPathElement> it = path.iterator(); it.hasNext(); ) {
final ContainmentPathElement pc = it.next();
sb.append(pc.getNamedElement().getName());
if (it.hasNext()) {
sb.append(".");
}
}
return sb.toString();
}
Aggregations