Search in sources :

Example 16 with ContainmentPathElement

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

the class EMV2Properties method isErrorModelElementProperty.

/**
 * return the containment path if the stack combined with the target and optionally the type set match the containment path of a property association.
 * It is sufficient for one of the paths in the PA to match.
 * ciStack represents the path from the context of the PA to the component instance whose property we want to retrieve
 * The desired type set ts must be contained in the type set named in the containment path
 * @param propertyAssociation PropertyAssociation that is the candidate
 * @param ciStack (can be null or empty) ComponentInstance in instance model hierarchy with the error model element, whose property we are retrieving (or null)
 * @param target Element the target object in the error model whose property we retrieve
 * @param ts type set that must contain the last element if it is a type
 * @return ContainedNamedElement the containment path that matches
 */
public static EMV2PropertyAssociation isErrorModelElementProperty(EMV2PropertyAssociation propertyAssociation, NamedElement target, Stack<NamedElement> ciStack, ErrorTypes ts) {
    boolean matchStack = false;
    EList<EMV2Path> applies = propertyAssociation.getEmv2Path();
    for (EMV2Path emv2Path : applies) {
        ContainmentPathElement cp = emv2Path.getContainmentPath();
        if (cp != null) {
            matchStack = matchCIStack(ciStack, cp);
        } else {
            matchStack = matchCIStack(ciStack, emv2Path.getEmv2Target());
        }
        if (matchStack) {
            // we are past the component portion of the path
            String targetName = EMV2Util.getPrintName(target);
            NamedElement pathTargetEME = EMV2Util.getErrorModelElement(emv2Path);
            String pathName = EMV2Util.getPrintName(pathTargetEME);
            if (targetName.equalsIgnoreCase(pathName)) {
                ErrorTypes typeelement = EMV2Util.getErrorType(emv2Path);
                if (typeelement != null && ts != null) {
                    // check to see if the desired ts is contained in the PA containment path
                    if (EMV2TypeSetUtil.contains(ts, typeelement) || EMV2TypeSetUtil.contains(typeelement, ts)) {
                        return propertyAssociation;
                    }
                } else {
                    return propertyAssociation;
                }
            }
        }
    }
    return null;
}
Also used : EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Example 17 with ContainmentPathElement

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

the class EMV2Util method getPrintName.

public static String getPrintName(EMV2Path ep) {
    if (ep == null) {
        return "";
    }
    EMV2PathElement epe = ep.getEmv2Target();
    if (epe == null) {
        return "";
    }
    ContainmentPathElement cpe = ep.getContainmentPath();
    String prefix;
    if (cpe == null) {
        prefix = "";
    } else {
        prefix = "^" + cpe.getNamedElement().getName();
        cpe = cpe.getPath();
    }
    while (cpe != null) {
        prefix = prefix + "." + cpe.getNamedElement().getName();
        cpe = cpe.getPath();
    }
    if (!prefix.isEmpty()) {
        prefix = prefix + '@';
    }
    if (epe.getEmv2PropagationKind() != null) {
        return prefix + epe.getEmv2PropagationKind() + (epe.getErrorType() != null ? "." + epe.getErrorType().getName() : "");
    } else {
        return getPathName(epe);
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Example 18 with ContainmentPathElement

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

the class EMV2Util method getPrintNameWithoutType.

/**
 * @deprecated Unused. Will be removed in 2.8.1
 */
@Deprecated
public static String getPrintNameWithoutType(EMV2Path ep) {
    if (ep == null) {
        return "";
    }
    EMV2PathElement epe = ep.getEmv2Target();
    if (epe == null) {
        return "";
    }
    ContainmentPathElement cpe = ep.getContainmentPath();
    if (cpe == null) {
        return getPathNameWithoutType(epe);
    }
    String prefix = "^" + cpe.getNamedElement().getName();
    while (cpe.getPath() != null) {
        cpe = cpe.getPath();
        prefix = prefix + "." + cpe.getNamedElement().getName();
    }
    if (!prefix.isEmpty()) {
        prefix = prefix + '@';
    }
    if (epe.getEmv2PropagationKind() != null) {
        return prefix + epe.getEmv2PropagationKind();
    } else {
        return getPathNameWithoutType(epe);
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Example 19 with ContainmentPathElement

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

the class AbstractPropertiesSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 20 with ContainmentPathElement

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

the class PropertyUtils method getContainedSimplePropertyValue.

/**
 * get a property association from the properties section of the containing classifier if the context.
 * This method has been designed to work with end points of connections, i.e., consisting of a target and a context.
 * The context must be a NamedElement in its containing classifier, i.e., a feature, feature group, subcomponent.
 * The property holder is assumed to be contained in the context object, e.g., a feature in afeature group or a data subcomponent in a port, or feature in a subcomponent.
 * The association must match the property definition.
 * if the context is null then the containing classifier of the target is used and the path must be one or no path.
 * The applies to clause of the property association must be of size 2 if the context is set and point to the context and then the property holder.
 * The property value of the property association is assumed not to be modal.
 * @param context NamedElement whose containing classifier's properties section is searched for the desired property
 * @param target NamedElement the model element to which the property is applied to via the applies to clause
 * @param pd Property the property definition
 * @return
 */
public static PropertyExpression getContainedSimplePropertyValue(final NamedElement context, final NamedElement target, final Property pd) {
    if (context == null) {
        return target.getNonModalPropertyValue(pd);
    }
    Classifier cl = AadlUtil.getContainingClassifier(context);
    EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : props) {
        if (propertyAssociation.getProperty().equals(pd)) {
            // we found a property with the corect type
            // now we need to check whether the applies to points to the holder
            EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
            for (ContainedNamedElement containedNamedElement : appliestos) {
                EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
                if (cpes.size() == 2) {
                    NamedElement pathcxt = cpes.get(0).getNamedElement();
                    NamedElement pathelement = cpes.get(1).getNamedElement();
                    if (context.equals(pathcxt) && target.equals(pathelement)) {
                        EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
                        if (!vallist.isEmpty()) {
                            ModalPropertyValue elem = vallist.get(0);
                            PropertyExpression res = elem.getOwnedValue();
                            if (res instanceof NamedValue) {
                                AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
                                if (nv instanceof Property) {
                                    res = target.getNonModalPropertyValue((Property) nv);
                                } else if (nv instanceof PropertyConstant) {
                                    res = ((PropertyConstant) nv).getConstantValue();
                                }
                            }
                            return res;
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Classifier(org.osate.aadl2.Classifier) PropertyConstant(org.osate.aadl2.PropertyConstant) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Property(org.osate.aadl2.Property)

Aggregations

ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)52 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)27 NamedElement (org.osate.aadl2.NamedElement)24 PropertyAssociation (org.osate.aadl2.PropertyAssociation)19 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)15 ReferenceValue (org.osate.aadl2.ReferenceValue)14 Property (org.osate.aadl2.Property)12 Subcomponent (org.osate.aadl2.Subcomponent)12 IntegerLiteral (org.osate.aadl2.IntegerLiteral)11 ListValue (org.osate.aadl2.ListValue)11 NamedValue (org.osate.aadl2.NamedValue)11 ArrayRange (org.osate.aadl2.ArrayRange)10 RangeValue (org.osate.aadl2.RangeValue)10 RealLiteral (org.osate.aadl2.RealLiteral)10 RecordValue (org.osate.aadl2.RecordValue)10 BooleanLiteral (org.osate.aadl2.BooleanLiteral)9 ClassifierValue (org.osate.aadl2.ClassifierValue)9 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)9 StringLiteral (org.osate.aadl2.StringLiteral)9 EObject (org.eclipse.emf.ecore.EObject)7