Search in sources :

Example 16 with Feature

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

the class DefaultSelectSubprogramDialogModel method getSubprograms.

@Override
public List<Object> getSubprograms(final Object context) {
    // Build a list of subprograms
    final List<Object> subprograms = new ArrayList<Object>();
    // Data/Subprogram Group/Abstract Type
    if (context instanceof IEObjectDescription) {
        final IEObjectDescription desc = (IEObjectDescription) context;
        final Classifier contextClassifier = (Classifier) (desc.getEObjectOrProxy().eIsProxy() ? (Classifier) EcoreUtil.resolve(desc.getEObjectOrProxy(), bi.eResource()) : desc.getEObjectOrProxy());
        if (!contextClassifier.eIsProxy()) {
            for (final Feature tmpFeature : contextClassifier.getAllFeatures()) {
                if (tmpFeature instanceof SubprogramAccess) {
                    // Provides Subprogram Access
                    if (((SubprogramAccess) tmpFeature).getKind() == AccessType.PROVIDES) {
                        subprograms.add(tmpFeature);
                    }
                }
            }
        }
    } else if (context instanceof SubprogramGroupAccess) {
        // Requires Subprogram Group Access
        // Only subprogram group accesses with kind = Requires and which has a subprogram group classifier should be in the context list
        // Provides Subprogram Access
        final SubprogramGroupClassifier spgClassifier = (SubprogramGroupClassifier) ((SubprogramGroupAccess) context).getAllClassifier();
        addProvidesSubprogramAccessesForComponentClassifier(spgClassifier, subprograms);
    } else if (context instanceof FeatureGroup) {
        // Feature Group
        final FeatureGroup fg = (FeatureGroup) context;
        // Requires subprogram Access if not inverse and Provides subprogram access if is inverse
        final boolean inverted = fg.isInverse();
        for (final Feature tmpFeature : AadlFeatureUtil.getAllFeatures(fg.getAllFeatureGroupType())) {
            if (tmpFeature instanceof SubprogramAccess) {
                final AccessType accessKind = ((SubprogramAccess) tmpFeature).getKind();
                if ((!inverted && accessKind == AccessType.REQUIRES) || (inverted && accessKind == AccessType.PROVIDES)) {
                    subprograms.add(tmpFeature);
                }
            }
        }
    } else if (context instanceof SubprogramGroupSubcomponent) {
        // Subprogram Group Subcomponent
        // Provides Subprogram
        addProvidesSubprogramAccessesForComponentClassifier(((SubprogramGroupSubcomponent) context).getAllClassifier(), subprograms);
    } else if (context == processorContext) {
        // Subprogram Proxy
        for (final ProcessorFeature processorFeature : AgeAadlUtil.getAllProcessorFeatures(bi)) {
            if (processorFeature instanceof SubprogramProxy) {
                subprograms.add(processorFeature);
            }
        }
    } else if (context == nullContext) {
        // Null Context
        // Subprogram classifier reference
        final Aadl2Package aadl2Package = Aadl2Package.eINSTANCE;
        for (final IEObjectDescription desc : AadlModelAccessUtil.getAllEObjectsByType(bi.eResource(), aadl2Package.getComponentClassifier())) {
            // Add objects that have care either types or implementations of the same category as the classifier type
            final EClass classifierEClass = desc.getEClass();
            if (aadl2Package.getSubprogramClassifier().isSuperTypeOf(classifierEClass)) {
                subprograms.add(desc);
            }
        }
        // Requires Subprogram Access
        for (final Feature tmpFeature : bi.getAllFeatures()) {
            if (tmpFeature instanceof SubprogramAccess && ((SubprogramAccess) tmpFeature).getKind() == AccessType.REQUIRES) {
                subprograms.add(tmpFeature);
            }
        }
        // Subprogram Subcomponent
        for (final Subcomponent tmpSc : bi.getAllSubcomponents()) {
            if (tmpSc instanceof SubprogramSubcomponent) {
                subprograms.add(tmpSc);
            }
        }
        // Subprogram Prototype
        for (final Prototype prototype : bi.getAllPrototypes()) {
            if (prototype instanceof SubprogramPrototype) {
                subprograms.add(prototype);
            }
        }
    }
    return Collections.unmodifiableList(subprograms);
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) Prototype(org.osate.aadl2.Prototype) SubprogramGroupClassifier(org.osate.aadl2.SubprogramGroupClassifier) ArrayList(java.util.ArrayList) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) SubprogramGroupClassifier(org.osate.aadl2.SubprogramGroupClassifier) Feature(org.osate.aadl2.Feature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) SubprogramGroupAccess(org.osate.aadl2.SubprogramGroupAccess) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) EClass(org.eclipse.emf.ecore.EClass) SubprogramProxy(org.osate.aadl2.SubprogramProxy) SubprogramAccess(org.osate.aadl2.SubprogramAccess) Aadl2Package(org.osate.aadl2.Aadl2Package) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) ProcessorFeature(org.osate.aadl2.ProcessorFeature) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) AccessType(org.osate.aadl2.AccessType)

Example 17 with Feature

use of org.osate.aadl2.Feature 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 18 with Feature

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

the class AadlGraphics method getFeatureGraphic.

public static FeatureGraphic getFeatureGraphic(final EClass featureClass, DirectionType direction) {
    final FeatureGraphicBuilder builder = FeatureGraphicBuilder.create();
    // Configure the feature type
    final Aadl2Package aadl2Pkg = Aadl2Package.eINSTANCE;
    if (featureClass == aadl2Pkg.getAbstractFeature()) {
        builder.abstractFeature();
    } else if (featureClass == aadl2Pkg.getEventPort()) {
        builder.eventPort();
    } else if (featureClass == aadl2Pkg.getDataPort() || featureClass == aadl2Pkg.getParameter()) {
        builder.dataPort();
    } else if (featureClass == aadl2Pkg.getEventDataPort()) {
        builder.eventDataPort();
    } else if (featureClass == aadl2Pkg.getSubprogramAccess()) {
        builder.subprogramAccess();
    } else if (featureClass == aadl2Pkg.getSubprogramGroupAccess()) {
        builder.subprogramGroupAccess();
    } else if (featureClass == aadl2Pkg.getDataAccess()) {
        builder.dataAccess();
    } else if (featureClass == aadl2Pkg.getBusAccess()) {
        builder.busAccess();
    } else if (featureClass == aadl2Pkg.getFeatureGroup()) {
        builder.featureGroup();
    } else if (featureClass == aadl2Pkg.getPortProxy()) {
        builder.portProxy();
    } else if (featureClass == aadl2Pkg.getEventSource()) {
        builder.eventSource();
    } else if (featureClass == aadl2Pkg.getEventDataSource()) {
        builder.eventDataSource();
    } else if (featureClass == aadl2Pkg.getSubprogramProxy()) {
        builder.subprogramProxy();
    }
    switch(direction) {
        case IN:
            builder.input();
            break;
        case OUT:
            builder.output();
            break;
        case IN_OUT:
            builder.bidirectional();
            break;
    }
    return builder.build();
}
Also used : Aadl2Package(org.osate.aadl2.Aadl2Package) FeatureGraphicBuilder(org.osate.ge.graphics.internal.FeatureGraphicBuilder)

Example 19 with Feature

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

the class FeatureHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext featureBoc = ctx.getBusinessObjectContext();
    final NamedElement feature = featureBoc.getBusinessObject(NamedElement.class).get();
    final FeatureGraphic graphic = getGraphicalRepresentation(feature, featureBoc);
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(graphic).annotation(AadlGraphics.getFeatureAnnotation(feature.eClass())).style(StyleBuilder.create(AadlInheritanceUtil.isInherited(featureBoc) ? Styles.INHERITED_ELEMENT : Style.EMPTY).backgroundColor(AadlGraphics.getDefaultBackgroundColor(graphic.featureType)).labelsAboveTop().labelsLeft().build()).defaultDockingPosition(getDefaultDockingPosition(feature, featureBoc)).build());
}
Also used : FeatureGraphic(org.osate.ge.graphics.internal.FeatureGraphic) BusinessObjectContext(org.osate.ge.BusinessObjectContext) NamedElement(org.osate.aadl2.NamedElement)

Example 20 with Feature

use of org.osate.aadl2.Feature 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

ArrayList (java.util.ArrayList)100 Feature (org.osate.aadl2.Feature)86 Feature (com.google.cloud.vision.v1.Feature)74 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)71 Image (com.google.cloud.vision.v1.Image)71 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)68 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)68 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)65 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)59 ByteString (com.google.protobuf.ByteString)48 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)47 Classifier (org.osate.aadl2.Classifier)45 NamedElement (org.osate.aadl2.NamedElement)42 ImageSource (com.google.cloud.vision.v1.ImageSource)39 Subcomponent (org.osate.aadl2.Subcomponent)39 FeatureGroup (org.osate.aadl2.FeatureGroup)33 FeatureGroupType (org.osate.aadl2.FeatureGroupType)33 FileInputStream (java.io.FileInputStream)30 ComponentClassifier (org.osate.aadl2.ComponentClassifier)30 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28