Search in sources :

Example 46 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class PropertyUtils method getInstanceObjectReference.

/**
 * Get an InstanceObject from an instance reference value. Throws an
 * exception if no property value exists or an error occurs.
 *
 * @param io The instance object from which to retrieve the property value.
 *            (We don't use a property holder because we can only get an
 *            instance reference value as a property value from an instance
 *            object.)
 * @param pd The property to retrieve.
 * @return The instance object of the property.
 */
public static InstanceObject getInstanceObjectReference(final InstanceObject io, final Property pd) {
    if (io == null) {
        return null;
    }
    try {
        final PropertyExpression pv = io.getSimplePropertyValue(pd);
        final InstanceObject ref = ((InstanceReferenceValue) pv).getReferencedInstanceObject();
        return ref;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 47 with InstanceReferenceValue

use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.

the class DefaultBusinessObjectTreeUpdater method createPropertyValues.

private void createPropertyValues(final BusinessObjectNode node, final Property property, final PropertyResult pr, final Object value, final Deque<Integer> indicesStack, final String appliesToDescendantRef, final Multimap<BusinessObjectNode, AgePropertyValue> dstToPropertyValues) {
    if (value instanceof List) {
        @SuppressWarnings("unchecked") final List<Object> valueList = ((List<Object>) value);
        int idx = 0;
        for (final Object innerValue : valueList) {
            indicesStack.addLast(idx);
            createPropertyValues(node, property, pr, innerValue, indicesStack, appliesToDescendantRef, dstToPropertyValues);
            indicesStack.removeLast();
            idx++;
        }
    } else {
        final BusinessObjectNode dst;
        boolean fullyResolved = true;
        if (value instanceof ReferenceValueWithContext) {
            final AadlPropertyResolutionResults rr = ((ReferenceValueWithContext) value).resolve(node, queryService);
            dst = (BusinessObjectNode) rr.dst;
            fullyResolved = !rr.isPartial;
        } else if (value instanceof ClassifierValue) {
            dst = (BusinessObjectNode) PropertyValueUtil.getReferencedClassifier(node, (ClassifierValue) value, queryService);
        } else if (value instanceof InstanceReferenceValue) {
            final InstanceReferenceValue irv = (InstanceReferenceValue) value;
            final InstanceObject referencedInstanceObject = irv.getReferencedInstanceObject();
            final AadlPropertyResolutionResults rr = PropertyValueUtil.getReferencedInstanceObject(node, referencedInstanceObject, queryService);
            dst = (BusinessObjectNode) rr.dst;
            fullyResolved = !rr.isPartial;
        } else {
            dst = null;
        }
        dstToPropertyValues.put(dst, new AgePropertyValue(pr, indicesStack, appliesToDescendantRef, fullyResolved));
    }
}
Also used : AadlPropertyResolutionResults(org.osate.ge.aadl2.internal.aadlproperties.AadlPropertyResolutionResults) ClassifierValue(org.osate.aadl2.ClassifierValue) ReferenceValueWithContext(org.osate.ge.aadl2.internal.aadlproperties.ReferenceValueWithContext) InstanceObject(org.osate.aadl2.instance.InstanceObject) List(java.util.List) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) EObject(org.eclipse.emf.ecore.EObject) InstanceObject(org.osate.aadl2.instance.InstanceObject) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) AgePropertyValue(org.osate.ge.aadl2.internal.model.AgePropertyValue)

Aggregations

PropertyExpression (org.osate.aadl2.PropertyExpression)39 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)37 Property (org.osate.aadl2.Property)34 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 ListValue (org.osate.aadl2.ListValue)19 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 BasicProperty (org.osate.aadl2.BasicProperty)11 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)11 ArrayList (java.util.ArrayList)8 RecordValue (org.osate.aadl2.RecordValue)6 InstanceObject (org.osate.aadl2.instance.InstanceObject)6 Classifier (org.osate.aadl2.Classifier)5 ClassifierValue (org.osate.aadl2.ClassifierValue)5 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)4 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)4 BooleanLiteral (org.osate.aadl2.BooleanLiteral)4 IntegerLiteral (org.osate.aadl2.IntegerLiteral)4 NamedValue (org.osate.aadl2.NamedValue)4 StringLiteral (org.osate.aadl2.StringLiteral)4 Iterator (java.util.Iterator)3