Search in sources :

Example 26 with ComponentType

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

the class CreateGeneralizationPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetCreateConnectionOperationContext ctx) {
    final Object readonlySubtype = ctx.getSource().getBusinessObject();
    final Classifier supertype = ctx.getDestination().getBusinessObject(Classifier.class).orElse(null);
    // Ensure they are valid and are not the same
    if (readonlySubtype == null || supertype == null || readonlySubtype == supertype) {
        return Optional.empty();
    }
    // Rules:
    // Abstract types can be extended by any type.
    // Types can be extended by other types in their category
    // Implementations can extend other implementations with same category and abstract implementation in some cases.
    // Feature Group Types can extend other feature group types
    final boolean canCreate = (readonlySubtype instanceof ComponentType && (supertype instanceof AbstractType || supertype.getClass() == readonlySubtype.getClass())) || (readonlySubtype instanceof ComponentImplementation && (supertype instanceof AbstractImplementation || supertype.getClass() == readonlySubtype.getClass())) || (readonlySubtype instanceof FeatureGroupType && supertype instanceof FeatureGroupType);
    if (!canCreate) {
        return Optional.empty();
    }
    return Operation.createSimple(ctx.getSource(), Classifier.class, subtype -> {
        // Import the package if necessary
        if (subtype.getNamespace() instanceof PackageSection && subtype.getNamespace().getOwner() instanceof AadlPackage && supertype.getNamespace() instanceof PackageSection && supertype.getNamespace().getOwner() instanceof AadlPackage) {
            final PackageSection subtypeSection = (PackageSection) subtype.getNamespace();
            final AadlPackage supertypePackage = (AadlPackage) supertype.getNamespace().getOwner();
            AadlImportsUtil.addImportIfNeeded(subtypeSection, supertypePackage);
        }
        // Create the generalization
        final Object newBo;
        if (subtype instanceof ComponentType) {
            final ComponentType ct = (ComponentType) subtype;
            final TypeExtension te = ct.createOwnedExtension();
            te.setExtended((ComponentType) supertype);
            newBo = te;
        } else if (subtype instanceof ComponentImplementation) {
            final ComponentImplementation ci = (ComponentImplementation) subtype;
            final ImplementationExtension ie = ci.createOwnedExtension();
            ie.setExtended((ComponentImplementation) supertype);
            newBo = ie;
        } else if (subtype instanceof FeatureGroupType) {
            final FeatureGroupType fgt = (FeatureGroupType) subtype;
            final GroupExtension ge = fgt.createOwnedExtension();
            ge.setExtended((FeatureGroupType) supertype);
            newBo = ge;
        } else {
            return StepResult.abort();
        }
        return StepResultBuilder.create().showNewBusinessObject(ctx.getSource(), newBo).build();
    });
}
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) AbstractType(org.osate.aadl2.AbstractType) GroupExtension(org.osate.aadl2.GroupExtension) AbstractImplementation(org.osate.aadl2.AbstractImplementation)

Example 27 with ComponentType

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

the class TypeExtensionImpl method setExtended.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setExtended(ComponentType newExtended) {
    ComponentType oldExtended = extended;
    extended = newExtended;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.TYPE_EXTENSION__EXTENDED, oldExtended, extended));
    }
}
Also used : ComponentType(org.osate.aadl2.ComponentType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 28 with ComponentType

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

the class ModeImpl method getPropertyValueInternal.

// Cannot make this final because I need to override in SystemOperationMode
public void getPropertyValueInternal(final Property prop, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final Classifier owner = getContainingClassifier();
    final boolean inType = (owner instanceof ComponentType);
    // local contained value
    if (!inType && !fromInstanceSlaveCall) {
        // owner could be null if we are looking up a property on a SystemOperationMode, which does not have a containing classifier.
        if (owner != null && pas.addLocalContained(this, owner)) {
            if (!all) {
                return;
            }
        }
    }
    // local value
    if (pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // not an implementation
    if ((inType || !inType && !fromInstanceSlaveCall) && prop.isInherit()) {
        if (owner != null) {
            owner.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
        } else {
            throw new InvalidModelException(this, "Mode is not contained in a component type or implementation");
        }
    }
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) ComponentType(org.osate.aadl2.ComponentType) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier)

Example 29 with ComponentType

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

the class AnnexHandler method getAnnexSubclauseIndex.

/**
 * Returns a 0 based index for referencing an annex subclause in a list that contains only annex subclauses with the same type and owner
 * @return
 */
public static int getAnnexSubclauseIndex(AnnexSubclause annexSubclause, final boolean useExtended) {
    // Get the default annex library if a parsed annex subclause was specified. This is needed for the comparison later in the function.
    if (!(annexSubclause instanceof DefaultAnnexSubclause)) {
        if (annexSubclause.eContainer() instanceof DefaultAnnexSubclause) {
            annexSubclause = (AnnexSubclause) annexSubclause.eContainer();
        } else {
            return -1;
        }
    }
    final String annexName = annexSubclause.getName();
    if (annexName == null) {
        return -1;
    }
    final Classifier cl = annexSubclause.getContainingClassifier();
    final List<Classifier> classifiers;
    if (useExtended) {
        classifiers = cl.getSelfPlusAllExtended();
        // Get all related classifiers
        if (cl instanceof ComponentImplementation) {
            final ComponentType ct = ((ComponentImplementation) cl).getType();
            if (ct != null) {
                classifiers.addAll(ct.getSelfPlusAllExtended());
            }
        }
    } else {
        classifiers = Arrays.asList(cl);
    }
    int index = 0;
    // Use reversed view of list so that base classifiers will be first. This is needed to ensure subclauses have unique indices
    for (final Classifier tmpClassifier : Lists.reverse(classifiers)) {
        for (final AnnexSubclause tmpSubclause : tmpClassifier.getOwnedAnnexSubclauses()) {
            if (tmpSubclause == annexSubclause) {
                return index;
            } else if (annexName.equalsIgnoreCase(tmpSubclause.getName())) {
                index++;
            }
        }
    }
    return -1;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) Classifier(org.osate.aadl2.Classifier) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 30 with ComponentType

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

the class AgeRenameParticipant method getDependentObjects.

private static Set<EObject> getDependentObjects(final EObject obj, final ResourceSet rs, final Map<URI, Set<URI>> externalReferencesMap) {
    final Set<EObject> results = new HashSet<>();
    final EObject objectOfInterest;
    // is the only known way of getting types related to the renames.
    if (obj instanceof ComponentTypeRename) {
        final ComponentType renamedComponentType = ((ComponentTypeRename) obj).getRenamedComponentType();
        objectOfInterest = renamedComponentType == null ? null : renamedComponentType;
    } else {
        objectOfInterest = obj;
    }
    if (objectOfInterest != null) {
        getRelatedObjects(Collections.singleton(objectOfInterest), rs, results, externalReferencesMap, obj instanceof Feature);
    }
    return results;
}
Also used : ComponentType(org.osate.aadl2.ComponentType) EObject(org.eclipse.emf.ecore.EObject) ComponentTypeRename(org.osate.aadl2.ComponentTypeRename) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Feature(org.osate.aadl2.Feature) HashSet(java.util.HashSet)

Aggregations

ComponentType (org.osate.aadl2.ComponentType)73 ComponentImplementation (org.osate.aadl2.ComponentImplementation)46 Classifier (org.osate.aadl2.Classifier)34 ArrayList (java.util.ArrayList)29 AnnexSubclause (org.osate.aadl2.AnnexSubclause)24 ComponentClassifier (org.osate.aadl2.ComponentClassifier)24 EObject (org.eclipse.emf.ecore.EObject)18 NamedElement (org.osate.aadl2.NamedElement)18 EventDataPort (org.osate.aadl2.EventDataPort)15 DataPort (org.osate.aadl2.DataPort)14 EventPort (org.osate.aadl2.EventPort)14 AadlPackage (org.osate.aadl2.AadlPackage)13 Feature (org.osate.aadl2.Feature)13 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)11 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)11 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)11 Event (com.ge.research.osate.verdict.dsl.verdict.Event)11 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)11 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)11 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)11