Search in sources :

Example 6 with FeatureGroupType

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

the class AadlBusinessObjectProvider method getChildBusinessObjects.

@Override
public Stream<?> getChildBusinessObjects(final BusinessObjectProviderContext ctx) {
    final Object bo = ctx.getBusinessObjectContext().getBusinessObject();
    // An IProject is specified as the business object for contextless diagrams.
    if (bo instanceof IProject) {
        // Special handling for project
        final IProject project = (IProject) bo;
        // Perform an incremental project build to ensure new packages are included.
        try {
            project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
        Stream<Object> packages = getPackages(project);
        // If no packages were found, assume that the project needs to be built. This can happen if the Eclipse process is forcefully terminated.
        if (packages == null) {
            try {
                project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
            packages = getPackages(project);
        }
        return packages;
    } else if (bo instanceof AadlPackage) {
        return getChildren((AadlPackage) bo, ctx.getExtensionRegistry());
    } else if (bo instanceof Classifier) {
        return getChildren((Classifier) bo, true, ctx.getExtensionRegistry());
    } else if (bo instanceof FeatureGroup) {
        final FeatureGroupType fgt = AadlFeatureUtil.getFeatureGroupType(ctx.getBusinessObjectContext(), (FeatureGroup) bo);
        return fgt == null ? Stream.empty() : AadlFeatureUtil.getAllFeatures(fgt).stream();
    } else if (bo instanceof Subcomponent) {
        return getChildren((Subcomponent) bo, ctx.getBusinessObjectContext(), ctx.getExtensionRegistry());
    } else if (bo instanceof SubprogramCall) {
        return getChildren((SubprogramCall) bo);
    } else if (bo instanceof SubprogramCallSequence) {
        return getChildren((SubprogramCallSequence) bo);
    } else if (bo instanceof ModeTransition) {
        final ModeTransition mt = ((ModeTransition) bo);
        final String modeTransitionTriggersDesc = mt.getOwnedTriggers().stream().map(mtt -> mttHandler.getName(mtt)).collect(Collectors.joining(","));
        return Stream.concat(mt.getOwnedTriggers().stream(), Stream.of(new Tag(Tag.KEY_MODE_TRANSITION_TRIGGERS, modeTransitionTriggersDesc)));
    } else if (bo instanceof ComponentInstance) {
        return getChildren((ComponentInstance) bo);
    } else if (bo instanceof FeatureInstance) {
        return ((FeatureInstance) bo).getFeatureInstances().stream();
    } else if (bo instanceof Connection) {
        if (!((Connection) bo).isAllBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    } else if (bo instanceof ConnectionInstance) {
        if (!((ConnectionInstance) bo).isBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    }
    return Stream.empty();
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) FeatureGroup(org.osate.aadl2.FeatureGroup) AadlPackage(org.osate.aadl2.AadlPackage) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) SubprogramCallSequence(org.osate.aadl2.SubprogramCallSequence) FeatureGroupType(org.osate.aadl2.FeatureGroupType) Connection(org.osate.aadl2.Connection) ModeTransition(org.osate.aadl2.ModeTransition) Classifier(org.osate.aadl2.Classifier) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EObject(org.eclipse.emf.ecore.EObject) Tag(org.osate.ge.aadl2.internal.model.Tag) SubprogramCall(org.osate.aadl2.SubprogramCall)

Example 7 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType 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 8 with FeatureGroupType

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

the class AadlFeatureUtil method getAllFeatures.

public static EList<Feature> getAllFeatures(final FeatureGroupType fgt) {
    final EList<Feature> owned = getAllOwnedFeatures(fgt);
    final FeatureGroupType inverseFgt = fgt.getInverse();
    if (owned.isEmpty() && !Aadl2Util.isNull(inverseFgt)) {
        return getAllOwnedFeatures(inverseFgt);
    }
    return owned;
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) Feature(org.osate.aadl2.Feature)

Example 9 with FeatureGroupType

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

the class ClassifierInfoView method createDescendantTree.

private DescendantTree createDescendantTree(final Classifier rootClassifier, final Set<IProject> projects, final IProgressMonitor progressMonitor) throws InterruptedException {
    final SubMonitor subMonitor = SubMonitor.convert(progressMonitor);
    final Deque<DescendantTreeNode> deque = new LinkedList<>();
    final DescendantTreeNode root = new DescendantTreeNode(rootClassifier, NO_PREFIX);
    deque.addLast(root);
    /* We maintain a queue of classifiers to search for, starting with our root classifier. For each
		 * one, we look for all references to it, and then process all references that appear in a context
		 * where it is being implemented/extended/inverted.
		 */
    final AadlFinder.Scope scope = new AadlFinder.ResourceSetScope(projects);
    while (!deque.isEmpty()) {
        if (subMonitor.isCanceled()) {
            throw new InterruptedException();
        }
        final DescendantTreeNode current = deque.removeFirst();
        /* Find all the references to the current classifier */
        // Use the "logarithmic progress pattern described in SubMonitor JavaDoc
        subMonitor.subTask(current.getText());
        subMonitor.setWorkRemaining(10);
        final AtomicBoolean cancelled = new AtomicBoolean(false);
        AadlFinder.getInstance().getAllReferencesToTypeInScope(scope, (resourceSet, refDesc) -> {
            if (subMonitor.isCanceled()) {
                cancelled.set(true);
            }
            if (refDesc.getTargetEObjectUri().equals(current.getURI())) {
                subMonitor.setWorkRemaining(10);
                subMonitor.split(1);
                final URI sourceEObjectUri = refDesc.getSourceEObjectUri();
                final EObject eObj = resourceSet.getEObject(sourceEObjectUri, true);
                EObject childObject = null;
                String childPrefix = null;
                if (eObj instanceof TypeExtension) {
                    childObject = ((TypeExtension) eObj).eContainer();
                    childPrefix = EXTENDED_BY;
                } else if (eObj instanceof Realization) {
                    childObject = ((Realization) eObj).eContainer();
                    childPrefix = IMPLEMENTED_BY;
                } else if (eObj instanceof ImplementationExtension) {
                    childObject = ((ImplementationExtension) eObj).eContainer();
                    childPrefix = EXTENDED_BY;
                } else if (eObj instanceof GroupExtension) {
                    childObject = ((GroupExtension) eObj).eContainer();
                    childPrefix = EXTENDED_BY;
                } else if (eObj instanceof FeatureGroupType) {
                    childObject = eObj;
                    childPrefix = INVERTED_BY;
                }
                /* Add the referencing node to the tree */
                if (childObject != null) {
                    final DescendantTreeNode child = new DescendantTreeNode(childObject, childPrefix);
                    current.addChild(child);
                    deque.addLast(child);
                }
            }
        }, subMonitor.split(1));
        if (cancelled.get()) {
            throw new InterruptedException();
        }
    }
    return new DescendantTree(root);
}
Also used : SubMonitor(org.eclipse.core.runtime.SubMonitor) FeatureGroupType(org.osate.aadl2.FeatureGroupType) TypeExtension(org.osate.aadl2.TypeExtension) ImplementationExtension(org.osate.aadl2.ImplementationExtension) URI(org.eclipse.emf.common.util.URI) LinkedList(java.util.LinkedList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Realization(org.osate.aadl2.Realization) AadlFinder(org.osate.search.AadlFinder) EObject(org.eclipse.emf.ecore.EObject) GroupExtension(org.osate.aadl2.GroupExtension)

Example 10 with FeatureGroupType

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

the class ClassifierInfoView method createAncestorTreeNode.

private AncestorTreeNode createAncestorTreeNode(final Classifier classifier, final String prefix, final IProgressMonitor progressMonitor) throws InterruptedException {
    if (progressMonitor.isCanceled()) {
        throw new InterruptedException();
    }
    AncestorTreeNode[] children = new AncestorTreeNode[0];
    if (classifier instanceof ComponentType) {
        final ComponentType extended = ((ComponentType) classifier.getExtended());
        if (extended != null) {
            children = new AncestorTreeNode[] { createAncestorTreeNode(extended, EXTENDS, progressMonitor) };
        }
    } else if (classifier instanceof ComponentImplementation) {
        final ComponentImplementation asCompImpl = (ComponentImplementation) classifier;
        final ComponentType implemented = asCompImpl.getType();
        final ComponentImplementation extended = asCompImpl.getExtended();
        if (extended == null) {
            children = new AncestorTreeNode[] { createAncestorTreeNode(implemented, IMPLEMENTS, progressMonitor) };
        } else {
            children = new AncestorTreeNode[] { createAncestorTreeNode(implemented, IMPLEMENTS, progressMonitor), createAncestorTreeNode(extended, EXTENDS, progressMonitor) };
        }
    } else if (classifier instanceof FeatureGroupType) {
        final FeatureGroupType asFeatureGroup = (FeatureGroupType) classifier;
        final FeatureGroupType inverseOf = asFeatureGroup.getInverse();
        final FeatureGroupType extended = asFeatureGroup.getExtended();
        final List<AncestorTreeNode> childrenList = new ArrayList<>(2);
        if (inverseOf != null) {
            childrenList.add(createAncestorTreeNode(inverseOf, INVERSE_OF, progressMonitor));
        }
        if (extended != null) {
            childrenList.add(createAncestorTreeNode(extended, EXTENDS, progressMonitor));
        }
        children = childrenList.toArray(children);
    }
    return new AncestorTreeNode(classifier, prefix, children);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ArrayList(java.util.ArrayList)

Aggregations

FeatureGroupType (org.osate.aadl2.FeatureGroupType)49 Classifier (org.osate.aadl2.Classifier)23 FeatureGroup (org.osate.aadl2.FeatureGroup)22 ComponentClassifier (org.osate.aadl2.ComponentClassifier)20 Feature (org.osate.aadl2.Feature)16 Subcomponent (org.osate.aadl2.Subcomponent)13 ComponentPrototype (org.osate.aadl2.ComponentPrototype)10 ComponentType (org.osate.aadl2.ComponentType)10 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)10 NamedElement (org.osate.aadl2.NamedElement)10 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)9 AadlPackage (org.osate.aadl2.AadlPackage)8 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)8 EObject (org.eclipse.emf.ecore.EObject)7 ComponentImplementation (org.osate.aadl2.ComponentImplementation)7 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)7 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)7 ArrayList (java.util.ArrayList)6 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)6 EClass (org.eclipse.emf.ecore.EClass)5