Search in sources :

Example 31 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.

the class AadlBaNameResolver method propertyFieldIndexResolver.

private boolean propertyFieldIndexResolver(Element el, IntegerValue field, BasicProperty bProperty, int fieldIndex, DeclarativePropertyName declProName) {
    if (integerValueResolver(field)) {
        // Link to the default value, if it exists.
        if (Aadl2Package.LIST_VALUE == el.eClass().getClassifierID() && propertyFieldListValueResolver(field, (ListValue) el, fieldIndex, declProName)) {
            return true;
        } else if (Aadl2Package.PROPERTY_ASSOCIATION == el.eClass().getClassifierID()) {
            PropertyAssociation pa = (PropertyAssociation) el;
            ModalPropertyValue mpv = pa.getOwnedValues().get(pa.getOwnedValues().size() - 1);
            PropertyExpression pe = mpv.getOwnedValue();
            if (Aadl2Package.LIST_VALUE == pe.eClass().getClassifierID()) {
                return propertyFieldListValueResolver(field, (ListValue) pe, fieldIndex, declProName);
            }
        }
        // the else statements: link with the property type.
        ListType lt = (ListType) bProperty.getPropertyType();
        declProName.setOsateRef(lt.getElementType());
        return true;
    } else {
        return false;
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DeclarativeBasicPropertyAssociation(org.osate.ba.declarative.DeclarativeBasicPropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ListValue(org.osate.aadl2.ListValue) DeclarativeListValue(org.osate.ba.declarative.DeclarativeListValue) ListType(org.osate.aadl2.ListType) PropertyExpression(org.osate.aadl2.PropertyExpression)

Example 32 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.

the class AadlBaNameResolver method behaviorVariableResolver.

/**
 * Resolves the behavior annex's variables.
 *
 * @return {@code true} if all names are resolved. {@code false} otherwise.
 */
private boolean behaviorVariableResolver() {
    boolean result = true;
    QualifiedNamedElement uccr;
    // classifier reference exists.
    for (BehaviorVariable v : _ba.getVariables()) {
        uccr = (QualifiedNamedElement) v.getDataClassifier();
        result &= qualifiedNamedElementResolver(uccr, true);
        for (ArrayDimension tmp : v.getArrayDimensions()) {
            IntegerValueConstant ivc = ((DeclarativeArrayDimension) tmp).getDimension();
            result &= integerValueConstantResolver(ivc);
        }
        List<PropertyAssociation> paList = v.getOwnedPropertyAssociations();
        List<PropertyAssociation> paPropertyNotFound = new ArrayList<PropertyAssociation>();
        Set<PropertyAssociation> paPropertyValueError = new HashSet<PropertyAssociation>();
        for (PropertyAssociation pa : paList) {
            QualifiedNamedElement p = (QualifiedNamedElement) pa.getProperty();
            boolean valid = qualifiedNamedElementResolver(p, false);
            if (valid) {
                for (ModalPropertyValue mpv : pa.getOwnedValues()) {
                    result &= propertyExpressionResolver(v, p, mpv.getOwnedValue());
                    paPropertyValueError.add(pa);
                }
            }
            if (!valid) {
                paPropertyNotFound.add(pa);
            }
            result &= valid;
        }
        StringBuilder msg = new StringBuilder();
        if (paPropertyNotFound.size() > 1) {
            msg.append("Properties ");
        } else {
            msg.append("Property ");
        }
        boolean first = true;
        for (PropertyAssociation paToRemove : paPropertyNotFound) {
            QualifiedNamedElement p = (QualifiedNamedElement) paToRemove.getProperty();
            StringBuilder qualifiedName = new StringBuilder();
            if (p.getBaNamespace() != null) {
                qualifiedName.append(p.getBaNamespace().getId());
                qualifiedName.append("::");
            }
            qualifiedName.append(p.getBaName().getId());
            if (first) {
                msg.append("\'" + qualifiedName + "\' ");
            } else {
                msg.append(" and \'" + qualifiedName + "\' ");
            }
            first = false;
        }
        paList.removeAll(paPropertyNotFound);
        paList.removeAll(paPropertyValueError);
        if (paPropertyNotFound.size() > 0) {
            msg.append("not found");
            _errManager.error(v, msg.toString());
        }
    }
    return result;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DeclarativeBasicPropertyAssociation(org.osate.ba.declarative.DeclarativeBasicPropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ArrayList(java.util.ArrayList) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeArrayDimension(org.osate.ba.declarative.DeclarativeArrayDimension) IntegerValueConstant(org.osate.ba.aadlba.IntegerValueConstant) ArrayDimension(org.osate.aadl2.ArrayDimension) DeclarativeArrayDimension(org.osate.ba.declarative.DeclarativeArrayDimension) HashSet(java.util.HashSet)

Example 33 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.

the class PropertyUtils method createIntegerAssignment.

public static PropertyAssociation createIntegerAssignment(String propertyName, long value) {
    Property property = Aadl2Factory.eINSTANCE.createProperty();
    PropertyAssociation assignment = Aadl2Factory.eINSTANCE.createPropertyAssociation();
    ModalPropertyValue modalPropertyValue = Aadl2Factory.eINSTANCE.createModalPropertyValue();
    IntegerLiteral propertyValue = Aadl2Factory.eINSTANCE.createIntegerLiteral();
    property.setName(propertyName);
    propertyValue.setValue(value);
    modalPropertyValue.setOwnedValue(propertyValue);
    assignment.setProperty(property);
    assignment.getOwnedValues().add(modalPropertyValue);
    return assignment;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 34 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.

the class PropertyUtils method getListValue.

public static ListValue getListValue(NamedElement ne, String propertyName) {
    PropertyAssociation pa = findPropertyAssociation(propertyName, ne);
    if (pa != null) {
        Property p = pa.getProperty();
        if (p.getName().equalsIgnoreCase(propertyName)) {
            List<ModalPropertyValue> values = pa.getOwnedValues();
            if (values.size() == 1) {
                ModalPropertyValue v = values.get(0);
                PropertyExpression expr = v.getOwnedValue();
                if (expr instanceof ListValue) {
                    return (ListValue) expr;
                }
            }
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Example 35 with PropertyAssociation

use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.

the class PropertyUtils method getStringValue.

/**
 * Extract String value from a specified property. May return null.
 *
 * @param i
 *            component instance.
 * @param propertyName
 *            property name.
 * @return property value.
 */
public static String getStringValue(NamedElement i, String propertyName) {
    PropertyAssociation pa = findPropertyAssociation(propertyName, i);
    if (pa != null) {
        Property p = pa.getProperty();
        if (p.getName().equalsIgnoreCase(propertyName)) {
            List<ModalPropertyValue> values = pa.getOwnedValues();
            if (values.size() == 1) {
                ModalPropertyValue v = values.get(0);
                PropertyExpression expr = v.getOwnedValue();
                if (expr instanceof StringLiteral) {
                    return ((StringLiteral) expr).getValue();
                }
            }
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) StringLiteral(org.osate.aadl2.StringLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

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