use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class PropertiesValidator method checkInheritedMissingModes.
public void checkInheritedMissingModes(Classifier classifier) {
List<Mode> allModes = new ArrayList<Mode>();
List<PropertyAssociation> propertyAssociations = new ArrayList<PropertyAssociation>();
List<PropertyAssociation> ownedPropertyAssociations = new ArrayList<PropertyAssociation>();
List<Property> ownedProperties = new ArrayList<Property>();
Element warningTarget = null;
if (classifier instanceof ComponentImplementation) {
ComponentImplementation componentImpl = (ComponentImplementation) classifier;
if (null == componentImpl.getExtended()) {
return;
}
allModes = componentImpl.getAllModes();
propertyAssociations = componentImpl.getAllPropertyAssociations();
ownedPropertyAssociations = componentImpl.getOwnedPropertyAssociations();
ownedProperties = new ArrayList<Property>();
warningTarget = componentImpl.getOwnedExtension();
} else if (classifier instanceof ComponentType) {
ComponentType componentType = (ComponentType) classifier;
if (null == componentType.getExtended()) {
return;
}
allModes = componentType.getAllModes();
propertyAssociations = componentType.getAllPropertyAssociations();
ownedPropertyAssociations = componentType.getOwnedPropertyAssociations();
ownedProperties = new ArrayList<Property>();
warningTarget = componentType.getOwnedExtension();
}
for (PropertyAssociation ownedPropertyAssociation : ownedPropertyAssociations) {
ownedProperties.add(ownedPropertyAssociation.getProperty());
}
Map<Property, List<Mode>> propModesMap = buildPropertySetForModeMap(allModes, propertyAssociations);
for (Property keyProperty : propModesMap.keySet()) {
if (ownedProperties.contains(keyProperty)) {
continue;
}
List<Mode> mappedModes = propModesMap.get(keyProperty);
for (Mode nextMode : allModes) {
if (!mappedModes.contains(nextMode)) {
warning(warningTarget, "Value not set for mode " + nextMode.getName() + " for property " + keyProperty.getQualifiedName());
}
}
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class PropertiesValidator method checkPropertyAssociationModalBindings.
protected void checkPropertyAssociationModalBindings(PropertyAssociation pa) {
List<ModalPropertyValue> modalPropertyValues = pa.getOwnedValues();
Iterator<ModalPropertyValue> mpvIt = modalPropertyValues.iterator();
while (mpvIt.hasNext()) {
ModalPropertyValue mpv = mpvIt.next();
if (mpvIt.hasNext()) {
List<Mode> modes = mpv.getInModes();
if (null == modes || modes.isEmpty()) {
error(mpv, "Missing 'in modes'");
}
}
}
for (ModalPropertyValue mpv1 : modalPropertyValues) {
if (null == mpv1) {
continue;
}
List<Mode> inModes1 = mpv1.getInModes();
for (ModalPropertyValue mpv2 : modalPropertyValues) {
if (null == mpv2) {
continue;
}
List<Mode> inModes2 = mpv2.getInModes();
if (mpv1 != mpv2) {
for (Mode inMode1 : inModes1) {
if (null == inMode1) {
continue;
}
for (Mode inMode2 : inModes2) {
if (inMode1.equals(inMode2)) {
error(mpv2, "Assignment to duplicate modes");
}
}
}
}
}
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class PropertiesValidator method checkContainedProperties.
public void checkContainedProperties(PropertyAssociation pa) {
List<ModalPropertyValue> mpvs = pa.getOwnedValues();
if (null == mpvs || mpvs.isEmpty()) {
return;
}
List<ContainedNamedElement> appliesTo = pa.getAppliesTos();
if (null == appliesTo || appliesTo.size() != 1) {
return;
}
List<Mode> masterModes = getMasterModes(appliesTo.get(0));
if (null == masterModes || masterModes.isEmpty()) {
return;
}
List<Mode> modesWithProperty = new ArrayList<Mode>();
ModalPropertyValue lastModalPropertyValue = mpvs.get(mpvs.size() - 1);
List<Mode> lastInModes = lastModalPropertyValue.getInModes();
if (null == lastInModes || lastInModes.isEmpty()) {
modesWithProperty.addAll(masterModes);
} else {
for (ModalPropertyValue mpv : mpvs) {
List<Mode> inModes = mpv.getInModes();
if (null != inModes && !inModes.isEmpty()) {
modesWithProperty.removeAll(inModes);
modesWithProperty.addAll(inModes);
}
}
}
for (Mode masterMode : masterModes) {
if (!modesWithProperty.contains(masterMode)) {
warning(pa, "Value not set for mode " + masterMode.getName() + " for property " + pa.getProperty().getQualifiedName());
}
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class PropertiesValidator method checkAssociationAppliesTo.
/**
* Check constraints that property applies to the element it is associated
* with per Section 10.3:
*
* <blockquote>The property named by a property association must list the
* category of the component type, component implementation, subcomponent,
* feature, connection, flow, or mode the property association is declared
* for in its Property_Owner_Category list. </blockquote>
*/
private void checkAssociationAppliesTo(final PropertyAssociation pa) {
final Property pn = pa.getProperty();
final EList<ContainedNamedElement> appliesTo = pa.getAppliesTos();
if (appliesTo == null || appliesTo.size() == 0) {
Element element = pa.getOwner();
if (element instanceof NamedElement) {
final boolean applies = ((NamedElement) element).acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
// error(pa,
// "Property " + pa.getQualifiedName() +
// " does not apply to " + element.eClass().getName());
}
}
} else {
for (ContainedNamedElement cna : appliesTo) {
EList<ContainmentPathElement> path = cna.getContainmentPathElements();
if (!path.isEmpty()) {
// only the last value is interesting to us
final ContainmentPathElement ph = path.get(path.size() - 1);
if (!Aadl2Util.isNull(ph.getNamedElement())) {
final boolean applies = ph.getNamedElement().acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + unparseAppliesTo(cna));
}
}
}
}
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class ErrorModelValidator method casePropertyAssociation.
@Override
@Check(CheckType.FAST)
public void casePropertyAssociation(PropertyAssociation propertyAssociation) {
// check that error type is contained in type set of target element
EList<ContainedNamedElement> apto = propertyAssociation.getAppliesTos();
for (ContainedNamedElement containedNamedElement : apto) {
EList<ContainmentPathElement> cpe = containedNamedElement.getContainmentPathElements();
if (cpe.size() > 1) {
ContainmentPathElement obj = cpe.get(cpe.size() - 1);
if (obj.getNamedElement() instanceof ErrorType) {
ErrorType et = (ErrorType) obj.getNamedElement();
ContainmentPathElement target = cpe.get(cpe.size() - 2);
NamedElement ne = target.getNamedElement();
TypeSet tts = null;
if (ne instanceof ErrorBehaviorState) {
tts = ((ErrorBehaviorState) ne).getTypeSet();
} else if (ne instanceof ErrorPropagation) {
tts = ((ErrorPropagation) ne).getTypeSet();
} else if (ne instanceof ErrorEvent) {
tts = ((ErrorEvent) ne).getTypeSet();
}
if (!EMV2TypeSetUtil.contains(tts, et)) {
error(propertyAssociation, "Property " + propertyAssociation.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
}
}
}
}
}
Aggregations