Search in sources :

Example 26 with Subcomponent

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

the class AadlPropertyResolver method processContainedPropertyAssociationsInChildren.

private void processContainedPropertyAssociationsInChildren(final BusinessObjectContext q) {
    // Process contained property associations contained in children
    for (final BusinessObjectContext childQueryable : q.getChildren()) {
        final Object childBo = childQueryable.getBusinessObject();
        if (childBo instanceof InstanceObject) {
            processPropertyAssociationsForInstanceObjectsNotInTree(childQueryable, (InstanceObject) childBo);
        } else {
            if (childBo instanceof Subcomponent || childBo instanceof FeatureGroup) {
                final NamedElement childNamedElement = (NamedElement) childBo;
                // Handle refinements
                RefinableElement tmpRefinable = (RefinableElement) childNamedElement;
                do {
                    processDeclarativeContainedPropertyAssociations(childQueryable, tmpRefinable.getOwnedPropertyAssociations());
                    tmpRefinable = tmpRefinable.getRefinedElement();
                } while (tmpRefinable != null);
                // Process contained property associations contained in the element's classifier
                if (childBo instanceof FeatureGroup) {
                    final FeatureGroupType featureGroupType = AadlPrototypeUtil.getFeatureGroupType(AadlPrototypeUtil.getPrototypeBindingContext(childQueryable), (FeatureGroup) childBo);
                    if (featureGroupType != null) {
                        processDeclarativeContainedPropertyAssociations(childQueryable, featureGroupType);
                    }
                } else if (childBo instanceof Subcomponent) {
                    final Classifier subcomponentClassifier = AadlPrototypeUtil.getComponentClassifier(AadlPrototypeUtil.getPrototypeBindingContext(childQueryable), (Subcomponent) childBo);
                    if (subcomponentClassifier != null) {
                        processDeclarativeContainedPropertyAssociations(childQueryable, subcomponentClassifier);
                    }
                }
            } else if (childBo instanceof Classifier) {
                processDeclarativeContainedPropertyAssociations(childQueryable, ((Classifier) childBo));
            } else if (childBo instanceof AadlPackage) {
                processContainedPropertyAssociationsInChildren(childQueryable);
            }
        }
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) FeatureGroup(org.osate.aadl2.FeatureGroup) AadlPackage(org.osate.aadl2.AadlPackage) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) InstanceObject(org.osate.aadl2.instance.InstanceObject) RefinableElement(org.osate.aadl2.RefinableElement) Classifier(org.osate.aadl2.Classifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 27 with Subcomponent

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

the class AadlClassifierUtil method getComponentImplementation.

/**
 * Returns a component implementation for a specified business object. Only component implementations and subcomponents are supported.
 * @param bo
 * @return
 */
public static Optional<ComponentImplementation> getComponentImplementation(final Object bo) {
    final ComponentImplementation ci;
    if (bo instanceof BusinessObjectContext) {
        return getComponentImplementation(((BusinessObjectContext) bo).getBusinessObject());
    } else if (bo instanceof ComponentImplementation) {
        ci = (ComponentImplementation) bo;
    } else if (bo instanceof Subcomponent) {
        final Classifier scClassifier = ((Subcomponent) bo).getAllClassifier();
        ci = scClassifier instanceof ComponentImplementation ? (ComponentImplementation) scClassifier : null;
    } else {
        ci = null;
    }
    return Optional.ofNullable(ci);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Subcomponent(org.osate.aadl2.Subcomponent) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 28 with Subcomponent

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

the class AadlClassifierUtil method getComponentClassifier.

/**
 * Returns a component classifier for a specified business object. Only component implementations and subcomponents are supported.
 * @param bo
 * @return
 */
public static Optional<ComponentClassifier> getComponentClassifier(final Object bo) {
    final ComponentClassifier ci;
    if (bo instanceof BusinessObjectContext) {
        return getComponentClassifier(((BusinessObjectContext) bo).getBusinessObject());
    } else if (bo instanceof ComponentImplementation) {
        ci = (ComponentImplementation) bo;
    } else if (bo instanceof Subcomponent) {
        final ComponentClassifier scClassifier = ((Subcomponent) bo).getAllClassifier();
        ci = scClassifier instanceof ComponentClassifier ? scClassifier : null;
    } else {
        ci = null;
    }
    return Optional.ofNullable(ci);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Subcomponent(org.osate.aadl2.Subcomponent) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 29 with Subcomponent

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

the class SystemInstanceImpl method leadsOutof.

/**
 * Does the connection instance lead out of the flow specific feature
 * instance The connection may start in a subcomponent
 *
 * @param conni ConnectionInstance
 * @param cfi FeatureInstance the source feature instance
 * @param ffi The feature instance involved in the flow
 * @return true if connection goes through the ffi
 */
private boolean leadsOutof(ConnectionInstance conni, FeatureInstance cfi, FeatureInstance ffi) {
    if (cfi == ffi) {
        return true;
    }
    ComponentInstance flowci = ffi.getContainingComponentInstance();
    ComponentInstance connci = cfi.getContainingComponentInstance();
    while (connci != null) {
        if (flowci == connci) {
            return true;
        }
        connci = connci.getContainingComponentInstance();
    }
    return false;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 30 with Subcomponent

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

the class EMV2Util method getLastComponentInstance.

/**
 * get the last component instance in the epath relative to the component instance root
 * Returns root if the path does not include subcomponents.
 * Returns null if the component instance is not found, i.e., the path subcomponent references cannot be found in the
 * component instance hierarchy.
 * @param epath EMV2Path that includes EMV2PathElements pointing to subcomponents.
 * @param root ComponentInstance that is the root of the subcomponent section of the path
 * @return ComponentInstance
 */
public static ComponentInstance getLastComponentInstance(EMV2Path epath, ComponentInstance root) {
    ComponentInstance result = root;
    if (epath.getContainmentPath() != null) {
        // handle paths that come from the EMV2PropertyAssociation with the new syntax for the core path
        ContainmentPathElement ce = epath.getContainmentPath();
        while (ce != null && result != null) {
            if (ce.getNamedElement() instanceof Subcomponent) {
                Subcomponent sub = (Subcomponent) ce.getNamedElement();
                result = result.findSubcomponentInstance(sub);
            }
            ce = ce.getPath();
        }
        return result;
    }
    EMV2PathElement epe = epath.getEmv2Target();
    while (epe != null && result != null) {
        if (epe.getNamedElement() instanceof Subcomponent) {
            Subcomponent sub = (Subcomponent) epe.getNamedElement();
            result = result.findSubcomponentInstance(sub);
        }
        epe = epe.getPath();
    }
    return result;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Aggregations

Subcomponent (org.osate.aadl2.Subcomponent)118 ComponentClassifier (org.osate.aadl2.ComponentClassifier)53 Classifier (org.osate.aadl2.Classifier)46 ComponentImplementation (org.osate.aadl2.ComponentImplementation)40 NamedElement (org.osate.aadl2.NamedElement)40 Feature (org.osate.aadl2.Feature)37 DataSubcomponent (org.osate.aadl2.DataSubcomponent)33 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)33 ArrayList (java.util.ArrayList)31 EObject (org.eclipse.emf.ecore.EObject)25 Connection (org.osate.aadl2.Connection)24 FeatureGroup (org.osate.aadl2.FeatureGroup)21 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)21 Property (org.osate.aadl2.Property)20 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)19 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)17 FeatureGroupType (org.osate.aadl2.FeatureGroupType)17 Element (org.osate.aadl2.Element)16 List (java.util.List)15 AadlPackage (org.osate.aadl2.AadlPackage)15