Search in sources :

Example 11 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature 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 12 with Feature

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

the class FeatureInstanceTooltipContributor method addTooltipContents.

@Override
public void addTooltipContents(final TooltipContributorContext ctx) {
    ctx.getBusinessObjectContext().getBusinessObject(FeatureInstance.class).ifPresent(featureInstance -> {
        final Feature feature = featureInstance.getFeature();
        if (feature instanceof Feature || feature instanceof InternalFeature || feature instanceof ProcessorFeature) {
            // Determine the feature classifier
            final Classifier featureClassifier;
            if (feature instanceof EventDataSource) {
                final EventDataSource aadlFeature = (EventDataSource) feature;
                featureClassifier = aadlFeature.getDataClassifier();
            } else if (feature instanceof PortProxy) {
                final PortProxy aadlFeature = (PortProxy) feature;
                featureClassifier = aadlFeature.getDataClassifier();
            } else if (feature instanceof SubprogramProxy) {
                final SubprogramProxy aadlFeature = (SubprogramProxy) feature;
                featureClassifier = aadlFeature.getSubprogramClassifier();
            } else if (feature instanceof Feature) {
                final Feature aadlFeature = (Feature) feature;
                featureClassifier = aadlFeature.getAllClassifier();
            } else {
                featureClassifier = null;
            }
            // Build the text to contribute to the tooltip
            final StringBuffer tooltipContents = new StringBuffer();
            if (featureClassifier instanceof ComponentClassifier) {
                tooltipContents.append(((ComponentClassifier) featureClassifier).getCategory() + " " + featureClassifier.getQualifiedName());
            } else if (featureClassifier instanceof FeatureGroupType) {
                tooltipContents.append("feature group " + featureClassifier.getQualifiedName());
            } else if (featureClassifier == null) {
                tooltipContents.append("No Classifier");
            } else {
                tooltipContents.append(featureClassifier.getQualifiedName());
            }
            // Create the styled text describing the feature
            final Label lbl = new Label(ctx.getTooltip(), SWT.NONE);
            lbl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
            lbl.setText(tooltipContents.toString());
        }
    });
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) SubprogramProxy(org.osate.aadl2.SubprogramProxy) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) PortProxy(org.osate.aadl2.PortProxy) InternalFeature(org.osate.aadl2.InternalFeature) FeatureGroupType(org.osate.aadl2.FeatureGroupType) Label(org.eclipse.swt.widgets.Label) ProcessorFeature(org.osate.aadl2.ProcessorFeature) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) InternalFeature(org.osate.aadl2.InternalFeature) EventDataSource(org.osate.aadl2.EventDataSource)

Example 13 with Feature

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

the class AnalysisModel method getAllPropagationDestinationEnds.

/**
 * return all feature (or for access component) instances that are the
 * connection destination of the given feature instance The source and
 * destinations are assumed to be components with error models
 *
 * @param fi
 * @return list of ConnectionInstanceEnd
 */
public EList<ConnectionInstanceEnd> getAllPropagationDestinationEnds(ConnectionInstanceEnd fi) {
    EList<ConnectionInstanceEnd> result = new BasicEList<ConnectionInstanceEnd>();
    NamedElement f = null;
    if (fi instanceof FeatureInstance) {
        f = ((FeatureInstance) fi).getFeature();
    } else {
        f = ((ComponentInstance) fi).getSubcomponent();
    }
    for (PropagationPathRecord propagationPathRecord : propagationPaths) {
        PropagationPathEnd src = propagationPathRecord.getPathSrc();
        ErrorPropagation ep = src.getErrorPropagation();
        Feature srcf = EMV2Util.getFeature(ep);
        if (srcf != null && srcf == f) {
            PropagationPathEnd dst = propagationPathRecord.pathDst;
            ErrorPropagation dstep = dst.getErrorPropagation();
            if (dstep != null) {
                Feature dstf = EMV2Util.getFeature(dstep);
                ComponentInstance dstCI = dst.getComponentInstance();
                if (dstf != null) {
                    FeatureInstance dstfi = dstCI.findFeatureInstance(dstf);
                    result.add(dstfi);
                } else if (EMV2Util.isAccess(dstep)) {
                    result.add(dstCI);
                }
            }
        }
    }
    return result;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) BasicEList(org.eclipse.emf.common.util.BasicEList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) NamedElement(org.osate.aadl2.NamedElement) Feature(org.osate.aadl2.Feature)

Example 14 with Feature

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

the class GetProperties method sumElementsDataSize.

private static double sumElementsDataSize(final NamedElement ne, UnitLiteral unit, Property DataSize, Property SourceDataSize, int nesting) {
    double res = 0.0;
    Classifier cl = null;
    if (ne instanceof Classifier) {
        cl = (Classifier) ne;
    } else if (ne instanceof FeatureInstance) {
        cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
    } else if (ne instanceof Feature) {
        cl = ((Feature) ne).getClassifier();
    } else if (ne instanceof DataSubcomponent) {
        cl = ((DataSubcomponent) ne).getClassifier();
    }
    if (cl != null) {
        if (cl instanceof FeatureGroupType) {
            EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
            for (Feature f : fl) {
                res = res + getDataSize(f, unit, DataSize, SourceDataSize, nesting);
            }
        } else if (cl instanceof DataImplementation) {
            for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
                if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
                    res = res + getDataSize(ds, unit, DataSize, SourceDataSize, nesting);
                }
            }
        }
    }
    return res;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataImplementation(org.osate.aadl2.DataImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

Example 15 with Feature

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

the class CreateErrorPropagationPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    final Object bo = ctx.getTarget().getBusinessObject();
    if (bo instanceof Feature) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the feature in the context of the EMV subclause. This is needed for reliable serialization.
            final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(ctx.getTarget(), ErrorModelGeUtil.getClassifierSourceBoc(ctx.getTarget()).get(), new ArrayList<>());
            newPropagation.setFeatureorPPRef(buildFeatureReference(subclause.eResource().getResourceSet(), path));
        });
    } else if (bo instanceof KeywordPropagationPoint) {
        final KeywordPropagationPoint kw = (KeywordPropagationPoint) bo;
        if (kw.getType() != KeywordPropagationPointType.ALL) {
            return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> newPropagation.setKind(kw.getType().getKind()));
        }
    } else if (bo instanceof PropagationPoint) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the propagation in the context of the EMV subclause.
            // Check inherited subclauses as well. This is needed for reliable serialization.
            final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(subclause.getContainingClassifier());
            final String boName = ((PropagationPoint) bo).getName();
            final PropagationPoint pp = combined.getPoints().filter(p -> Objects.equal(p.getName(), boName)).findAny().orElseThrow(() -> new AadlGraphicalEditorException("Unable to find propagation point"));
            final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
            ppRef.setFeatureorPP(pp);
            newPropagation.setFeatureorPPRef(ppRef);
        });
    }
    return Optional.empty();
}
Also used : URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPointType(org.osate.ge.errormodel.model.KeywordPropagationPointType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) PropagationTreeUtil(org.osate.ge.errormodel.combined.PropagationTreeUtil) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) ErrorModelUiUtil(org.osate.ge.errormodel.ui.ErrorModelUiUtil) BiConsumer(java.util.function.BiConsumer) DirectionType(org.osate.aadl2.DirectionType) Objects(com.google.common.base.Objects) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext) Operation(org.osate.ge.operations.Operation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) Display(org.eclipse.swt.widgets.Display) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) PropagationNode(org.osate.ge.errormodel.combined.PropagationNode) StringUtil(org.osate.ge.StringUtil) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) TargetedPaletteCommand(org.osate.ge.palette.TargetedPaletteCommand) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) EObject(org.eclipse.emf.ecore.EObject) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) Feature(org.osate.aadl2.Feature) URI(org.eclipse.emf.common.util.URI) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Aggregations

Feature (org.osate.aadl2.Feature)86 ArrayList (java.util.ArrayList)82 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 ByteString (com.google.protobuf.ByteString)48 ImageSource (com.google.cloud.vision.v1.ImageSource)39 Subcomponent (org.osate.aadl2.Subcomponent)31 FileInputStream (java.io.FileInputStream)30 Classifier (org.osate.aadl2.Classifier)29 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 NamedElement (org.osate.aadl2.NamedElement)24 ComponentClassifier (org.osate.aadl2.ComponentClassifier)22 FeatureGroup (org.osate.aadl2.FeatureGroup)20 FeatureGroupType (org.osate.aadl2.FeatureGroupType)19 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)19