Search in sources :

Example 71 with PropertyAssociation

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

the class AadlBaUtils method getPropertyType.

/**
 * Returns the PropertyType object associated to the given PropertyElementHolder
 * given object.
 * @param holder the PropertyElementHolder given object
 * @return the associated PropertyType object
 */
public static PropertyType getPropertyType(PropertyElementHolder holder) {
    PropertyType result = null;
    Element el = holder.getElement();
    if (el instanceof PropertyType) {
        result = (PropertyType) el;
    } else if (el instanceof BasicProperty) {
        result = ((BasicProperty) el).getPropertyType();
    } else if (el instanceof PropertyAssociation) {
        result = ((PropertyAssociation) el).getProperty().getPropertyType();
    } else if (el instanceof PropertyExpression) {
        result = PropertyUtils.getContainingProperty((PropertyExpression) el).getPropertyType();
    } else if (el instanceof EnumerationLiteral) {
        result = (EnumerationType) el.eContainer();
    }
    return result;
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) PropertyAssociation(org.osate.aadl2.PropertyAssociation) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 72 with PropertyAssociation

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

the class AadlBaNameResolver method classifierPropertyReferenceResolver.

// return result code:
// 0 : resolution has passed.
// 1 : classifier is not found.
// 2 : classifier has been found but one or more property names are not found.
private short classifierPropertyReferenceResolver(DeclarativePropertyReference ref, boolean hasToReport) {
    if (qualifiedNamedElementResolver(ref.getQualifiedName(), hasToReport)) {
        NamedElement klass = (NamedElement) ref.getQualifiedName().getOsateRef();
        Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
        PropertyAssociation pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), klass);
        if (pa != null) {
            ref.getPropertyNames().get(0).setOsateRef(pa);
            propertyNameId.setOsateRef(pa);
            return (short) ((propertyNameResolver(ref.getPropertyNames())) ? 0 : 2);
        } else {
            reportNameError(propertyNameId, propertyNameId.getId());
            return 2;
        }
    } else {
        return 1;
    }
}
Also used : Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DeclarativeBasicPropertyAssociation(org.osate.ba.declarative.DeclarativeBasicPropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 73 with PropertyAssociation

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

the class AadlBaNameResolver method classifierFeaturePropertyReferenceResolver.

private boolean classifierFeaturePropertyReferenceResolver(DeclarativePropertyReference ref) {
    Reference component = ref.getReference();
    if (refResolver(component)) {
        PropertyAssociation pa = null;
        Classifier type = null;
        Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
        Element el = (component.getOsateRef() != null) ? component.getOsateRef() : component.getBaRef();
        if (el instanceof PrototypeBinding) {
            PrototypeBinding pb = (PrototypeBinding) el;
            type = AadlBaUtils.getClassifier(pb, pb.getContainingClassifier());
        } else if (el instanceof ClassifierFeature) {
            ClassifierFeature cf = (ClassifierFeature) el;
            // Fetch the own property association of the classifier feature.
            pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), cf);
            if (pa == null) {
                type = AadlBaUtils.getClassifier(cf, cf.getContainingClassifier());
            }
        } else if (el instanceof BehaviorVariable) {
            BehaviorVariable bv = (BehaviorVariable) el;
            DeclarativeBehaviorElement de = (DeclarativeBehaviorElement) bv.getDataClassifier();
            if (de.getOsateRef() instanceof Classifier) {
                type = (Classifier) de.getOsateRef();
            }
        } else // Cannot resolve or unimplemented cases.
        {
            String msg = "the type of \'" + ((NamedElement) el).getName() + "\' cannot be resolved";
            _errManager.error(el, msg);
        }
        // search within its type.
        if (pa == null && type != null) {
            pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), type);
        }
        if (pa != null) {
            ref.getPropertyNames().get(0).setOsateRef(pa);
            propertyNameId.setOsateRef(pa);
            return propertyNameResolver(ref.getPropertyNames());
        } else {
            reportNameError(propertyNameId, propertyNameId.getId());
            return false;
        }
    } else {
        // refResolver has already reported the error.
        return false;
    }
}
Also used : DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) Reference(org.osate.ba.declarative.Reference) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DeclarativeBasicPropertyAssociation(org.osate.ba.declarative.DeclarativeBasicPropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) PrototypeBinding(org.osate.aadl2.PrototypeBinding) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ClassifierFeature(org.osate.aadl2.ClassifierFeature)

Example 74 with PropertyAssociation

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

the class AadlBaTypeChecker method propertyElementHolderResolver.

private PropertyElementHolder propertyElementHolderResolver(Element el, LocationReference loc) {
    PropertyElementHolder result = null;
    if (el instanceof BasicProperty) {
        BasicProperty bp = (BasicProperty) el;
        BasicPropertyHolder tmp = _fact.createBasicPropertyHolder();
        tmp.setBasicProperty(bp);
        result = tmp;
    } else if (el instanceof PropertyAssociation) {
        PropertyAssociation pa = (PropertyAssociation) el;
        PropertyAssociationHolder tmp = _fact.createPropertyAssociationHolder();
        tmp.setPropertyAssociation(pa);
        result = tmp;
    } else if (el instanceof PropertyExpression) {
        PropertyExpression pe = (PropertyExpression) el;
        PropertyExpressionHolder tmp = _fact.createPropertyExpressionHolder();
        tmp.setPropertyExpression(pe);
        result = tmp;
    } else if (el instanceof PropertyType) {
        PropertyType pt = (PropertyType) el;
        PropertyTypeHolder tmp = _fact.createPropertyTypeHolder();
        tmp.setPropertyType(pt);
        result = tmp;
    } else if (el instanceof EnumerationLiteral) {
        EnumerationLiteral enumLit = (EnumerationLiteral) el;
        EnumLiteralHolder tmp = _fact.createEnumLiteralHolder();
        tmp.setEnumLiteral(enumLit);
        result = tmp;
    } else {
        String errorMsg = "type: " + el.getClass().getSimpleName() + " is not supported yet.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
    result.setLocationReference(loc);
    return result;
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) PropertyType(org.osate.aadl2.PropertyType) BasicProperty(org.osate.aadl2.BasicProperty) PropertyExpression(org.osate.aadl2.PropertyExpression) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 75 with PropertyAssociation

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

the class DeclarativeUtils method unparseElement.

public static String unparseElement(Element el) {
    String result;
    if (el instanceof PropertyAssociation) {
        PropertyAssociation pa = (PropertyAssociation) el;
        result = "";
        for (ModalPropertyValue mpv : pa.getOwnedValues()) {
            result += mpv.getOwnedValue().toString() + " ; ";
        }
    } else {
        result = el.toString();
    }
    return result;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation)

Aggregations

PropertyAssociation (org.osate.aadl2.PropertyAssociation)93 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)51 Property (org.osate.aadl2.Property)51 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)45 PropertyExpression (org.osate.aadl2.PropertyExpression)43 BasicProperty (org.osate.aadl2.BasicProperty)28 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)27 NamedElement (org.osate.aadl2.NamedElement)27 ListValue (org.osate.aadl2.ListValue)22 ArrayList (java.util.ArrayList)21 NamedValue (org.osate.aadl2.NamedValue)19 Element (org.osate.aadl2.Element)18 EObject (org.eclipse.emf.ecore.EObject)14 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)14 ReferenceValue (org.osate.aadl2.ReferenceValue)14 ArraySizeProperty (org.osate.aadl2.ArraySizeProperty)13 Classifier (org.osate.aadl2.Classifier)13 Mode (org.osate.aadl2.Mode)12 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)11