Search in sources :

Example 6 with TypeExtension

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

the class ComponentTypeImpl method basicSetOwnedExtension.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetOwnedExtension(TypeExtension newOwnedExtension, NotificationChain msgs) {
    TypeExtension oldOwnedExtension = ownedExtension;
    ownedExtension = newOwnedExtension;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Aadl2Package.COMPONENT_TYPE__OWNED_EXTENSION, oldOwnedExtension, newOwnedExtension);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TypeExtension(org.osate.aadl2.TypeExtension)

Example 7 with TypeExtension

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

the class ComponentTypeImpl method createOwnedExtension.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public TypeExtension createOwnedExtension() {
    TypeExtension newOwnedExtension = (TypeExtension) create(Aadl2Package.eINSTANCE.getTypeExtension());
    setOwnedExtension(newOwnedExtension);
    return newOwnedExtension;
}
Also used : TypeExtension(org.osate.aadl2.TypeExtension)

Example 8 with TypeExtension

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

the class ClassifierOperationExecutor method addStep.

/**
 * @param operation
 * @param part
 * @param basePart
 * @param pkgBoc if non-null then the operation result will indicate that the object should be added to the diagram.
 * @return
 */
private OperationBuilder<Classifier> addStep(final OperationBuilder<?> operation, final ClassifierOperationPart part, final ClassifierOperationPart basePart, final BusinessObjectContext pkgBoc) {
    Objects.requireNonNull(part, "part must not be null");
    Objects.requireNonNull(part.getType(), "operation part type must not be null");
    switch(part.getType()) {
        case EXISTING:
            return operation.supply(() -> StepResultBuilder.create(classifierCreationHelper.getResolvedClassifier(part.getSelectedClassifier())).build());
        case NEW_COMPONENT_IMPLEMENTATION:
        case NEW_COMPONENT_TYPE:
        case NEW_FEATURE_GROUP_TYPE:
            final EClass creationEClass = getCreationEClass(part);
            final PackageSection unmodifiableSection = classifierCreationHelper.getResolvedPublicSection(part.getSelectedPackage());
            return operation.modifyModel(unmodifiableSection, (tag, prevResult) -> tag, (tag, section, prevResult) -> {
                // Create the new classifier
                final Classifier newClassifier = section.createOwnedClassifier(creationEClass);
                // Set name
                newClassifier.setName(classifierCreationHelper.getName(part, basePart));
                final Classifier baseOperationResult = resolveWithLiveResourceSetOrThrowIfProxy((Classifier) prevResult);
                // Handle component implementations
                if (newClassifier instanceof ComponentImplementation) {
                    final ComponentImplementation newImpl = (ComponentImplementation) newClassifier;
                    final ComponentType baseComponentType;
                    if (baseOperationResult instanceof ComponentType) {
                        final Realization realization = newImpl.createOwnedRealization();
                        baseComponentType = (ComponentType) baseOperationResult;
                        realization.setImplemented(baseComponentType);
                    } else if (baseOperationResult instanceof ComponentImplementation) {
                        final ComponentImplementation baseImpl = (ComponentImplementation) baseOperationResult;
                        final ImplementationExtension extension = newImpl.createOwnedExtension();
                        extension.setExtended(baseImpl);
                        final Realization realization = newImpl.createOwnedRealization();
                        realization.setImplemented(baseImpl.getType());
                        baseComponentType = baseImpl.getType();
                        // Import the base implementation's package
                        final AadlPackage baseImplPkg = (AadlPackage) baseImpl.getNamespace().getOwner();
                        AadlImportsUtil.addImportIfNeeded(section, baseImplPkg);
                    } else {
                        throw new RuntimeException("Invalid base classifier: " + baseOperationResult);
                    }
                    // Get the base component type
                    if (baseComponentType == null) {
                        throw new RuntimeException("Unable to determine base component type");
                    }
                    if (!AadlNameUtil.namesAreEqual(section, baseComponentType.getNamespace())) {
                        // Import the package if necessary
                        final AadlPackage baseComponentTypePkg = (AadlPackage) baseComponentType.getNamespace().getOwner();
                        AadlImportsUtil.addImportIfNeeded(section, baseComponentTypePkg);
                        // Create an alias for the component type
                        final ClassifierCreationHelper.RenamedTypeDetails aliasDetails = classifierCreationHelper.getRenamedType(section, baseComponentTypePkg, baseComponentType.getName());
                        if (!aliasDetails.exists) {
                            final ComponentTypeRename ctr = section.createOwnedComponentTypeRename();
                            ctr.setName(aliasDetails.aliasName);
                            ctr.setCategory(baseComponentType.getCategory());
                            ctr.setRenamedComponentType(baseComponentType);
                        }
                    }
                } else if (newClassifier instanceof ComponentType && baseOperationResult instanceof ComponentType) {
                    final ComponentType newType = (ComponentType) newClassifier;
                    final TypeExtension extension = newType.createOwnedExtension();
                    extension.setExtended((ComponentType) baseOperationResult);
                } else if (newClassifier instanceof FeatureGroupType && baseOperationResult instanceof FeatureGroupType) {
                    final FeatureGroupType newFgt = (FeatureGroupType) newClassifier;
                    final GroupExtension extension = newFgt.createOwnedExtension();
                    extension.setExtended((FeatureGroupType) baseOperationResult);
                }
                final StepResultBuilder<Classifier> resultBuilder = StepResultBuilder.create(newClassifier);
                // Hint for adding to diagram
                if (pkgBoc != null && newClassifier != null) {
                    resultBuilder.showNewBusinessObject(pkgBoc, newClassifier);
                }
                return resultBuilder.build();
            });
        case NONE:
            return operation.map(prevResult -> StepResultBuilder.create((Classifier) null).build());
        default:
            throw new RuntimeException("Unexpected operation: " + part.getType());
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) AadlPackage(org.osate.aadl2.AadlPackage) PackageSection(org.osate.aadl2.PackageSection) FeatureGroupType(org.osate.aadl2.FeatureGroupType) TypeExtension(org.osate.aadl2.TypeExtension) ImplementationExtension(org.osate.aadl2.ImplementationExtension) Classifier(org.osate.aadl2.Classifier) EClass(org.eclipse.emf.ecore.EClass) Realization(org.osate.aadl2.Realization) GroupExtension(org.osate.aadl2.GroupExtension) ComponentTypeRename(org.osate.aadl2.ComponentTypeRename)

Example 9 with TypeExtension

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

the class AadlBusinessObjectProvider method getChildren.

private static Stream<?> getChildren(final Classifier classifier, final boolean includeGeneralizations, final ExtensionRegistryService extRegistryService) {
    Stream<?> children = Stream.empty();
    // Shapes
    children = Stream.concat(children, AadlFeatureUtil.getAllDeclaredFeatures(classifier).stream());
    if (classifier instanceof ComponentImplementation) {
        final ComponentImplementation ci = (ComponentImplementation) classifier;
        children = Stream.concat(children, AgeAadlUtil.getAllInternalFeatures(ci).stream());
        children = Stream.concat(children, AgeAadlUtil.getAllProcessorFeatures(ci).stream());
        children = Stream.concat(children, ci.getAllSubcomponents().stream());
    }
    if (classifier instanceof BehavioredImplementation) {
        children = Stream.concat(children, AgeAadlUtil.getAllSubprogramCallSequences((BehavioredImplementation) classifier).stream());
    }
    if (classifier instanceof ComponentClassifier) {
        children = Stream.concat(children, ((ComponentClassifier) classifier).getAllModes().stream());
    }
    // Annex Subclauses
    final Stream.Builder<AnnexSubclause> subclauseStreamBuilder = Stream.builder();
    for (final AnnexSubclause annexSubclause : getAllDefaultAnnexSubclauses(classifier)) {
        final AnnexSubclause parsedAnnexSubclause = getParsedAnnexSubclause(annexSubclause);
        final boolean specializedHandling = parsedAnnexSubclause != null && extRegistryService.getApplicableBusinessObjectHandler(parsedAnnexSubclause) != null;
        // Only contribute the annex object if a BOH for the annex does not exist. The annex plugin is expected to contribute the object as needed.
        if (!specializedHandling) {
            subclauseStreamBuilder.add(annexSubclause);
        }
    }
    children = Stream.concat(children, subclauseStreamBuilder.build());
    // Connections
    if (classifier instanceof ComponentClassifier) {
        children = Stream.concat(children, ((ComponentClassifier) classifier).getAllModeTransitions().stream());
    }
    if (classifier instanceof ComponentImplementation) {
        children = Stream.concat(children, ((ComponentImplementation) classifier).getAllConnections().stream());
    }
    final ComponentType componentType;
    if (classifier instanceof ComponentType) {
        componentType = (ComponentType) classifier;
    } else if (classifier instanceof ComponentImplementation) {
        componentType = ((ComponentImplementation) classifier).getType();
    } else {
        componentType = null;
    }
    if (componentType != null) {
        children = Stream.concat(children, componentType.getAllFlowSpecifications().stream());
    }
    // Add generalizations
    if (includeGeneralizations) {
        if (classifier instanceof ComponentType) {
            final ComponentType ct = ((ComponentType) classifier);
            final TypeExtension te = ct.getOwnedExtension();
            if (te != null) {
                children = Stream.concat(children, Stream.of(te));
            }
        } else if (classifier instanceof ComponentImplementation) {
            final ComponentImplementation componentImplementation = ((ComponentImplementation) classifier);
            // Implementation Extension
            final ImplementationExtension ie = componentImplementation.getOwnedExtension();
            if (ie != null) {
                children = Stream.concat(children, Stream.of(ie));
            } else {
                // Realization
                final Realization realization = componentImplementation.getOwnedRealization();
                if (realization != null) {
                    children = Stream.concat(children, Stream.of(realization));
                }
            }
        } else if (classifier instanceof FeatureGroupType) {
            final FeatureGroupType featureGroupType = ((FeatureGroupType) classifier);
            final GroupExtension ge = featureGroupType.getOwnedExtension();
            if (ge != null) {
                children = Stream.concat(children, Stream.of(ge));
            }
        }
    }
    return children;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentType(org.osate.aadl2.ComponentType) BehavioredImplementation(org.osate.aadl2.BehavioredImplementation) FeatureGroupType(org.osate.aadl2.FeatureGroupType) TypeExtension(org.osate.aadl2.TypeExtension) ImplementationExtension(org.osate.aadl2.ImplementationExtension) Realization(org.osate.aadl2.Realization) GroupExtension(org.osate.aadl2.GroupExtension) Stream(java.util.stream.Stream) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Aggregations

TypeExtension (org.osate.aadl2.TypeExtension)8 ImplementationExtension (org.osate.aadl2.ImplementationExtension)6 FeatureGroupType (org.osate.aadl2.FeatureGroupType)5 GroupExtension (org.osate.aadl2.GroupExtension)5 Realization (org.osate.aadl2.Realization)5 AadlPackage (org.osate.aadl2.AadlPackage)3 EObject (org.eclipse.emf.ecore.EObject)2 AbstractImplementation (org.osate.aadl2.AbstractImplementation)2 AbstractType (org.osate.aadl2.AbstractType)2 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)2 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 ComponentType (org.osate.aadl2.ComponentType)2 ConnectedElement (org.osate.aadl2.ConnectedElement)2 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2 PropertyAssociation (org.osate.aadl2.PropertyAssociation)2 ConfigurationException (com.google.inject.ConfigurationException)1 Injector (com.google.inject.Injector)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1