Search in sources :

Example 96 with PropertyAssociation

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());
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) Mode(org.osate.aadl2.Mode) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property)

Example 97 with PropertyAssociation

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");
                        }
                    }
                }
            }
        }
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) Mode(org.osate.aadl2.Mode)

Example 98 with PropertyAssociation

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());
        }
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) Mode(org.osate.aadl2.Mode) ArrayList(java.util.ArrayList) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement)

Example 99 with PropertyAssociation

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));
                    }
                }
            }
        }
    }
}
Also used : ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 100 with PropertyAssociation

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));
                }
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Aggregations

PropertyAssociation (org.osate.aadl2.PropertyAssociation)90 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)51 Property (org.osate.aadl2.Property)49 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)45 PropertyExpression (org.osate.aadl2.PropertyExpression)41 BasicProperty (org.osate.aadl2.BasicProperty)28 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)27 NamedElement (org.osate.aadl2.NamedElement)24 ListValue (org.osate.aadl2.ListValue)21 ArrayList (java.util.ArrayList)19 NamedValue (org.osate.aadl2.NamedValue)18 Element (org.osate.aadl2.Element)15 ArraySizeProperty (org.osate.aadl2.ArraySizeProperty)13 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)13 ReferenceValue (org.osate.aadl2.ReferenceValue)13 EObject (org.eclipse.emf.ecore.EObject)12 Mode (org.osate.aadl2.Mode)12 Classifier (org.osate.aadl2.Classifier)11 IntegerLiteral (org.osate.aadl2.IntegerLiteral)11