Search in sources :

Example 41 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class AadlBusinessObjectProvider method getChildBusinessObjects.

@Override
public Stream<?> getChildBusinessObjects(final BusinessObjectProviderContext ctx) {
    final Object bo = ctx.getBusinessObjectContext().getBusinessObject();
    // An IProject is specified as the business object for contextless diagrams.
    if (bo instanceof IProject) {
        // Special handling for project
        final IProject project = (IProject) bo;
        // Perform an incremental project build to ensure new packages are included.
        try {
            project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
        Stream<Object> packages = getPackages(project);
        // If no packages were found, assume that the project needs to be built. This can happen if the Eclipse process is forcefully terminated.
        if (packages == null) {
            try {
                project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
            packages = getPackages(project);
        }
        return packages;
    } else if (bo instanceof AadlPackage) {
        return getChildren((AadlPackage) bo, ctx.getExtensionRegistry());
    } else if (bo instanceof Classifier) {
        return getChildren((Classifier) bo, true, ctx.getExtensionRegistry());
    } else if (bo instanceof FeatureGroup) {
        final FeatureGroupType fgt = AadlFeatureUtil.getFeatureGroupType(ctx.getBusinessObjectContext(), (FeatureGroup) bo);
        return fgt == null ? Stream.empty() : AadlFeatureUtil.getAllFeatures(fgt).stream();
    } else if (bo instanceof Subcomponent) {
        return getChildren((Subcomponent) bo, ctx.getBusinessObjectContext(), ctx.getExtensionRegistry());
    } else if (bo instanceof SubprogramCall) {
        return getChildren((SubprogramCall) bo);
    } else if (bo instanceof SubprogramCallSequence) {
        return getChildren((SubprogramCallSequence) bo);
    } else if (bo instanceof ModeTransition) {
        final ModeTransition mt = ((ModeTransition) bo);
        final String modeTransitionTriggersDesc = mt.getOwnedTriggers().stream().map(mtt -> mttHandler.getName(mtt)).collect(Collectors.joining(","));
        return Stream.concat(mt.getOwnedTriggers().stream(), Stream.of(new Tag(Tag.KEY_MODE_TRANSITION_TRIGGERS, modeTransitionTriggersDesc)));
    } else if (bo instanceof ComponentInstance) {
        return getChildren((ComponentInstance) bo);
    } else if (bo instanceof FeatureInstance) {
        return ((FeatureInstance) bo).getFeatureInstances().stream();
    } else if (bo instanceof Connection) {
        if (!((Connection) bo).isAllBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    } else if (bo instanceof ConnectionInstance) {
        if (!((ConnectionInstance) bo).isBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    }
    return Stream.empty();
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) FeatureGroup(org.osate.aadl2.FeatureGroup) AadlPackage(org.osate.aadl2.AadlPackage) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) SubprogramCallSequence(org.osate.aadl2.SubprogramCallSequence) FeatureGroupType(org.osate.aadl2.FeatureGroupType) Connection(org.osate.aadl2.Connection) ModeTransition(org.osate.aadl2.ModeTransition) Classifier(org.osate.aadl2.Classifier) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EObject(org.eclipse.emf.ecore.EObject) Tag(org.osate.ge.aadl2.internal.model.Tag) SubprogramCall(org.osate.aadl2.SubprogramCall)

Example 42 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class ConnectionHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    final Connection c = boc.getBusinessObject(Connection.class).orElseThrow();
    final QueryResult src = queryService.getFirstResult(SRC_QUERY, boc, c).orElse(null);
    final QueryResult dst = queryService.getFirstResult(DST_QUERY, boc, c).orElse(null);
    final boolean partial = (src != null && src.isPartial()) || (dst != null && dst.isPartial());
    final StyleBuilder sb = StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY);
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(GRAPHIC).style(sb.build()).source(src == null ? null : src.getBusinessObjectContext()).destination(dst == null ? null : dst.getBusinessObjectContext()).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) QueryService(org.osate.ge.services.QueryService) Connection(org.osate.aadl2.Connection) StyleBuilder(org.osate.ge.graphics.StyleBuilder) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 43 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class Aadl2OutlineTreeProvider method internalCreateChildren.

@Override
protected void internalCreateChildren(final IOutlineNode parentNode, final EObject modelElement) {
    if (modelElement instanceof Element) {
        final Element element = (Element) modelElement;
        final EObject annexRoot = AnnexUtil.getAnnexRoot(element);
        if (annexRoot != null) {
            // delegate to annex specific outline tree provider
            IParseResult annexParseResult = ParseResultHolder.Factory.INSTANCE.adapt(annexRoot).getParseResult();
            if (annexParseResult != null) {
                Injector injector = AnnexUtil.getInjector(annexParseResult);
                if (injector != null) {
                    try {
                        final IOutlineTreeStructureProvider outlineTree = injector.getInstance(IOutlineTreeStructureProvider.class);
                        if (outlineTree instanceof BackgroundOutlineTreeProvider) {
                            outlineTree.createChildren(parentNode, element);
                        } else {
                            Aadl2Activator.getInstance().getLog().log(new Status(IStatus.ERROR, Aadl2Activator.PLUGIN_ID, IStatus.OK, "Annex outline tree structure provider '" + outlineTree.getClass().getCanonicalName() + "' does not implement BackgroundOutlineTreeProvider", null));
                        }
                    } catch (ConfigurationException e) {
                    // ignore: no outline provider for this annex
                    }
                }
            }
        } else {
            for (EObject childElement : element.getChildren()) {
                if (childElement instanceof Realization || childElement instanceof TypeExtension || childElement instanceof ImplementationExtension || childElement instanceof ContainmentPathElement || childElement instanceof PropertyAssociation) {
                    continue;
                }
                if (element instanceof Connection && childElement instanceof ConnectedElement) {
                    continue;
                }
                createNode(parentNode, childElement);
            }
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IOutlineTreeStructureProvider(org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider) BackgroundOutlineTreeProvider(org.eclipse.xtext.ui.editor.outline.impl.BackgroundOutlineTreeProvider) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Connection(org.osate.aadl2.Connection) TypeExtension(org.osate.aadl2.TypeExtension) ImplementationExtension(org.osate.aadl2.ImplementationExtension) Realization(org.osate.aadl2.Realization) ConfigurationException(com.google.inject.ConfigurationException) Injector(com.google.inject.Injector) EObject(org.eclipse.emf.ecore.EObject) ConnectedElement(org.osate.aadl2.ConnectedElement) IParseResult(org.eclipse.xtext.parser.IParseResult)

Example 44 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateEndToEndFlowSpecificationTool method createEndToEndFlow.

/**
 * Create an EndToEndFlow based on user selections
 */
private EndToEndFlow createEndToEndFlow() {
    final EndToEndFlow endToEndFlow = (EndToEndFlow) createFlowDialog.pkg.getEFactoryInstance().create(createFlowDialog.pkg.getEndToEndFlow());
    endToEndFlow.setName(createFlowDialog.endToEndFlowName);
    segmentSelections.forEach(entry -> {
        final BusinessObjectContext boc = entry.getBoc();
        final EndToEndFlowSegment eTEFlowSegment = endToEndFlow.createOwnedEndToEndFlowSegment();
        final EndToEndFlowElement eTEFlowElement = (EndToEndFlowElement) boc.getBusinessObject();
        if (!(boc.getBusinessObject() instanceof Connection) && !(boc.getBusinessObject() instanceof DataSubcomponent) && !(boc.getBusinessObject() instanceof EndToEndFlow)) {
            final Context context = ToolUtil.findContext(boc);
            eTEFlowSegment.setContext(context);
        }
        eTEFlowSegment.setFlowElement(eTEFlowElement);
        endToEndFlow.getOwnedEndToEndFlowSegments().add(eTEFlowSegment);
    });
    modeFeatureSelections.forEach(modeFeatureBoc -> endToEndFlow.getInModeOrTransitions().add((ModeFeature) modeFeatureBoc.getBusinessObject()));
    return endToEndFlow;
}
Also used : EndToEndFlow(org.osate.aadl2.EndToEndFlow) BusinessObjectContext(org.osate.ge.BusinessObjectContext) Context(org.osate.aadl2.Context) DataSubcomponent(org.osate.aadl2.DataSubcomponent) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) Connection(org.osate.aadl2.Connection) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ModeFeature(org.osate.aadl2.ModeFeature) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement)

Example 45 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class EMV2Util method findConnectionErrorSourceForConnection.

/**
 * Find ConnectionErrorSource with given classifier by looking through all connection error sources
 * @param conni the connection instance whose connection declarations we're using
 * @return the connection error source or null
 */
public static ErrorSource findConnectionErrorSourceForConnection(ConnectionInstance conni) {
    for (ConnectionReference connref : conni.getConnectionReferences()) {
        Connection conn = connref.getConnection();
        Classifier cl = getAssociatedClassifier(conn);
        if (cl != null) {
            Collection<ErrorSource> ceslist = getAllConnectionErrorSources(cl);
            for (ErrorSource ces : ceslist) {
                if (ces.isAll() || ces.getSourceModelElement().getName().equalsIgnoreCase(conn.getName())) {
                    return ces;
                }
            }
        }
    }
    return null;
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier)

Aggregations

IOException (java.io.IOException)87 Connection (com.trilead.ssh2.Connection)70 Connection (org.ovirt.engine.sdk4.Connection)64 Connection (org.osate.aadl2.Connection)58 Connection (ch.ethz.ssh2.Connection)47 Test (org.junit.Test)35 Session (com.trilead.ssh2.Session)33 Connection (okhttp3.Connection)33 Connection (org.jboss.remoting3.Connection)33 Connection (com.google.cloud.bigquery.connection.v1.Connection)31 InputStream (java.io.InputStream)31 VmsService (org.ovirt.engine.sdk4.services.VmsService)30 Vm (org.ovirt.engine.sdk4.types.Vm)30 Request (okhttp3.Request)23 Response (okhttp3.Response)20 Subcomponent (org.osate.aadl2.Subcomponent)20 ArrayList (java.util.ArrayList)19 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)19 VmService (org.ovirt.engine.sdk4.services.VmService)18 ResponseBody (okhttp3.ResponseBody)17