Search in sources :

Example 1 with IntegerValueConstant

use of org.osate.ba.aadlba.IntegerValueConstant 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 2 with IntegerValueConstant

use of org.osate.ba.aadlba.IntegerValueConstant in project osate2 by osate.

the class DeclarativeArrayDimensionImpl method basicSetDimension.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetDimension(IntegerValueConstant newDimension, NotificationChain msgs) {
    IntegerValueConstant oldDimension = dimension;
    dimension = newDimension;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DeclarativePackage.DECLARATIVE_ARRAY_DIMENSION__DIMENSION, oldDimension, newDimension);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : IntegerValueConstant(org.osate.ba.aadlba.IntegerValueConstant) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

IntegerValueConstant (org.osate.ba.aadlba.IntegerValueConstant)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ArrayDimension (org.osate.aadl2.ArrayDimension)1 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)1 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)1 PropertyAssociation (org.osate.aadl2.PropertyAssociation)1 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)1 DeclarativeArrayDimension (org.osate.ba.declarative.DeclarativeArrayDimension)1 DeclarativeBasicPropertyAssociation (org.osate.ba.declarative.DeclarativeBasicPropertyAssociation)1 QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)1