Search in sources :

Example 66 with Feature

use of com.google.cloud.vision.v1p4beta1.Feature in project osate2 by osate.

the class Aadl2InstanceUtil method getOutgoingConnection.

/**
 * find outgoing connection that goes through the feature of the specified component instance
 * @param ci Component instance
 * @param fi Feature instance
 * @return list of connection instances going through the feature
 */
public static EList<ConnectionInstance> getOutgoingConnection(ComponentInstance ci, FeatureInstance fi) {
    Feature f = fi.getFeature();
    EList<ConnectionInstance> result = new BasicEList<ConnectionInstance>();
    // allEnclosingConnectionInstances();
    Iterable<ConnectionInstance> it = ci.getSystemInstance().getAllConnectionInstances();
    for (ConnectionInstance connectionInstance : it) {
        ConnectionInstanceEnd src = connectionInstance.getSource();
        ComponentInstance srcci = src.getContainingComponentInstance();
        if (containedIn(srcci, ci)) {
            EList<ConnectionReference> connreflist = connectionInstance.getConnectionReferences();
            for (ConnectionReference connectionReference : connreflist) {
                ComponentInstance pci = connectionReference.getContext();
                Connection conn = connectionReference.getConnection();
                ConnectionEnd ce = conn.getAllSource();
                if (pci == ci.getContainingComponentInstance() && ce == f) {
                    // add connection if it goes through feature instance
                    result.add(connectionInstance);
                }
            }
        }
    }
    return result;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) BasicEList(org.eclipse.emf.common.util.BasicEList) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Connection(org.osate.aadl2.Connection) ConnectionEnd(org.osate.aadl2.ConnectionEnd) Feature(org.osate.aadl2.Feature)

Example 67 with Feature

use of com.google.cloud.vision.v1p4beta1.Feature in project osate2 by osate.

the class ChangeFeatureTypePropertySection method refresh.

@Override
public void refresh() {
    final Set<NamedElement> selectedFeatures = selectedBos.boStream(NamedElement.class).collect(Collectors.toSet());
    final Set<EClass> featureTypeOptions = new HashSet<>();
    // Add to options
    final Consumer<EClass> addFeatureTypeOption = (type) -> featureTypeOptions.add(type);
    // Get comboviewer selected value and populate available type options for comboviewer
    selectedFeatureType = AadlPropertySectionUtil.getTypeOptionsInformation(selectedFeatures, AadlFeatureUtil.getFeatureTypes(), (feature, type) -> isValidFeatureType(feature, type), addFeatureTypeOption);
    comboViewer.setInput(featureTypeOptions);
    // Set comboviewer selection
    if (selectedFeatureType != null) {
        comboViewer.setSelection(new StructuredSelection(selectedFeatureType));
    }
    comboViewer.getCombo().setEnabled(selectedFeatures.size() == 1);
}
Also used : InternalPropertySectionUtil(org.osate.ge.internal.ui.util.InternalPropertySectionUtil) Feature(org.osate.aadl2.Feature) InternalFeature(org.osate.aadl2.InternalFeature) ComboViewer(org.eclipse.jface.viewers.ComboViewer) AbstractFeature(org.osate.aadl2.AbstractFeature) IFilter(org.eclipse.jface.viewers.IFilter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) HashSet(java.util.HashSet) BusinessObjectSelection(org.osate.ge.BusinessObjectSelection) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EClass(org.eclipse.emf.ecore.EClass) Classifier(org.osate.aadl2.Classifier) AgeEmfUtil(org.osate.ge.internal.util.AgeEmfUtil) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) DirectionType(org.osate.aadl2.DirectionType) FeatureGroup(org.osate.aadl2.FeatureGroup) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProcessorFeature(org.osate.aadl2.ProcessorFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) AbstractPropertySection(org.eclipse.ui.views.properties.tabbed.AbstractPropertySection) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Set(java.util.Set) Collectors(java.util.stream.Collectors) AadlFeatureUtil(org.osate.ge.aadl2.internal.util.AadlFeatureUtil) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) Consumer(java.util.function.Consumer) Adapters(org.eclipse.core.runtime.Adapters) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) StringUtil(org.osate.ge.StringUtil) PropertySectionUtil(org.osate.ge.ui.PropertySectionUtil) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NamedElement(org.osate.aadl2.NamedElement) LabelProvider(org.eclipse.jface.viewers.LabelProvider) EClass(org.eclipse.emf.ecore.EClass) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NamedElement(org.osate.aadl2.NamedElement) HashSet(java.util.HashSet)

Example 68 with Feature

use of com.google.cloud.vision.v1p4beta1.Feature in project osate2 by osate.

the class CreateAadlConnectionPaletteCommand method canCreate.

private boolean canCreate(final BusinessObjectContext ownerBoc, final BusinessObjectContext srcBoc, final BusinessObjectContext dstBoc) {
    // Get the connection elements for the source and destination
    final ConnectedElement srcConnectedElement = getConnectedElementForBusinessObjectContext(srcBoc, connectionType, false, ownerBoc);
    if (srcConnectedElement == null) {
        return false;
    }
    final ConnectedElement dstConnectedElement = getConnectedElementForBusinessObjectContext(dstBoc, connectionType, !(srcConnectedElement.getContext() instanceof Subcomponent), ownerBoc);
    // Ensure they are valid and are not the same
    if (dstConnectedElement == null || EcoreUtil.equals(srcConnectedElement, dstConnectedElement)) {
        return false;
    }
    // Don't allow connecting two features owned by the same classifier
    if (!(srcConnectedElement.getContext() instanceof Subcomponent || srcConnectedElement.getContext() instanceof SubprogramCall) && srcConnectedElement.getConnectionEnd() instanceof Feature && !(dstConnectedElement.getContext() instanceof Subcomponent || dstConnectedElement.getContext() instanceof SubprogramCall) && dstConnectedElement.getConnectionEnd() instanceof Feature) {
        return false;
    }
    final Class<?> connectionEndType = getConnectionEndType(connectionType);
    if (connectionEndType == null || !connectionEndType.isInstance(dstConnectedElement.getConnectionEnd())) {
        return false;
    }
    return ownerBoc == null ? false : getClassifierOpBuilder().canBuildOperation(ownerBoc.getBusinessObject());
}
Also used : SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ConnectedElement(org.osate.aadl2.ConnectedElement) SubprogramCall(org.osate.aadl2.SubprogramCall) Feature(org.osate.aadl2.Feature)

Example 69 with Feature

use of com.google.cloud.vision.v1p4beta1.Feature in project osate2 by osate.

the class CreateFlowSourceSinkSpecificationPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    return ctx.getTarget().getBusinessObject(Feature.class).map(feature -> {
        final DirectionType requiredDirection;
        if (flowKind == FlowKind.SOURCE) {
            requiredDirection = DirectionType.OUT;
        } else if (flowKind == FlowKind.SINK) {
            requiredDirection = DirectionType.IN;
        } else {
            return null;
        }
        final List<ComponentType> potentialOwners = FlowSpecificationCreationUtil.getPotentialOwnersByFeature(ctx.getTarget(), ctx.getQueryService());
        if (potentialOwners.isEmpty() || !FlowSpecificationCreationUtil.isValidFlowEnd(feature, ctx.getTarget(), requiredDirection, ctx.getQueryService())) {
            return null;
        }
        final BusinessObjectContext container = FlowSpecificationCreationUtil.getFlowSpecificationOwnerBoc(ctx.getTarget(), ctx.getQueryService());
        if (container == null) {
            return null;
        }
        return Operation.createWithBuilder(createOp -> {
            AadlUiUtil.selectClassifier(createOp, potentialOwners).modifyPreviousResult(ct -> {
                final FlowSpecification fs = ct.createOwnedFlowSpecification();
                fs.setKind(flowKind);
                fs.setName(FlowSpecificationCreationUtil.getNewFlowSpecificationName(ct));
                // Create the appropriate flow end depending on the type being created
                final FlowEnd flowEnd;
                if (flowKind == FlowKind.SOURCE) {
                    flowEnd = fs.createOutEnd();
                } else if (flowKind == FlowKind.SINK) {
                    flowEnd = fs.createInEnd();
                } else {
                    throw new RuntimeException("Unexpected flow kind: " + flowKind);
                }
                flowEnd.setFeature(feature);
                flowEnd.setContext(FlowSpecificationCreationUtil.getContext(ctx.getTarget(), ctx.getQueryService()));
                // Clear the no flows flag
                ct.setNoFlows(false);
                return StepResultBuilder.create().showNewBusinessObject(container, fs).build();
            });
        });
    });
}
Also used : DirectionType(org.osate.aadl2.DirectionType) ComponentType(org.osate.aadl2.ComponentType) FlowSpecification(org.osate.aadl2.FlowSpecification) Feature(org.osate.aadl2.Feature) BusinessObjectContext(org.osate.ge.BusinessObjectContext) FlowEnd(org.osate.aadl2.FlowEnd)

Example 70 with Feature

use of com.google.cloud.vision.v1p4beta1.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)

Aggregations

Feature (org.osate.aadl2.Feature)82 ArrayList (java.util.ArrayList)78 Feature (com.google.cloud.vision.v1.Feature)72 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)69 Image (com.google.cloud.vision.v1.Image)69 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)66 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)66 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)63 ByteString (com.google.protobuf.ByteString)47 ImageSource (com.google.cloud.vision.v1.ImageSource)38 FileInputStream (java.io.FileInputStream)30 Subcomponent (org.osate.aadl2.Subcomponent)29 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)27 Classifier (org.osate.aadl2.Classifier)27 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 ComponentClassifier (org.osate.aadl2.ComponentClassifier)22 NamedElement (org.osate.aadl2.NamedElement)22 FeatureGroup (org.osate.aadl2.FeatureGroup)18 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)17 FeatureGroupType (org.osate.aadl2.FeatureGroupType)16