Search in sources :

Example 56 with Connection

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

the class CreateEndToEndFlowsSwitch method testConnection.

/**
 * @param conni
 * @param etei
 * @param result
 */
private boolean testConnection(ConnectionInstance conni, EndToEndFlowInstance etei) {
    Iterator<ConnectionReference> refIter = conni.getConnectionReferences().iterator();
    boolean match = false;
    while (refIter.hasNext()) {
        String name1 = refIter.next().getConnection().getName();
        String name2 = connections.get(0).getName();
        if (name1.equalsIgnoreCase(name2)) {
            Iterator<Connection> connIter = connections.iterator();
            connIter.next();
            match = true;
            while (match && refIter.hasNext() && connIter.hasNext()) {
                match &= refIter.next().getConnection().getName().equalsIgnoreCase(connIter.next().getName());
            }
            if (!refIter.hasNext() && connIter.hasNext()) {
                match = false;
            }
        }
    }
    if (match && connections.size() == 1) {
        // make sure connection instance goes in the same direction as the flow
        ComponentInstance connci = conni.getSource().getComponentInstance();
        FlowElementInstance fei = etei;
        while (fei instanceof EndToEndFlowInstance) {
            fei = ((EndToEndFlowInstance) fei).getFlowElements().get(((EndToEndFlowInstance) fei).getFlowElements().size() - 1);
        }
        if (fei instanceof FlowSpecificationInstance) {
            fei = fei.getComponentInstance();
        }
        ComponentInstance flowci = (ComponentInstance) fei;
        match = false;
        ComponentInstance ci = connci;
        while (!(ci instanceof SystemInstance)) {
            if (ci == flowci) {
                match = true;
                break;
            }
            ci = ci.getContainingComponentInstance();
        }
    }
    if (match) {
        // test if the connection instance is connected to the end of the ete instance
        // relevant if the flow goes through a port of a feature group and the connection
        // instance comes from an expanded fg connection
        ConnectionInstanceEnd src = conni.getSource();
        if (src instanceof FeatureInstance) {
            FeatureInstance firstFeature = (FeatureInstance) src;
            FeatureInstance lastFeature = getLastFeature(etei);
            if (lastFeature != null) {
                match = isSameorContains(lastFeature, firstFeature);
            }
        }
    }
    return match;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Connection(org.osate.aadl2.Connection) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) FlowElementInstance(org.osate.aadl2.instance.FlowElementInstance)

Example 57 with Connection

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

the class CreateEndToEndFlowsSwitch method processDataAccess.

/**
 * Add the ETE instance that goes through a data access feature. Instead of
 * the data access feature, add the accessed object to the ETE instance. The
 * access feature uniquely determines the accessed object.
 *
 * @param ci
 * @param etei
 * @param fe
 * @param iter
 */
private void processDataAccess(ComponentInstance ci, EndToEndFlowInstance etei, DataAccess da, FlowIterator iter) {
    // add connection(s), will be empty when starting the ETE
    if (connections.isEmpty()) {
        addLeafElement(ci, etei, da);
        continueFlow(ci.getContainingComponentInstance(), etei, iter, ci);
    } else {
        List<ConnectionInstance> connis = collectConnectionInstances(ci, etei);
        if (connis.isEmpty()) {
            error(etei, "Incomplete end-to-end flow instance " + etei.getName() + ": Missing connection instance to " + ((NamedElement) da).getName());
            connections.clear();
        } else {
            Iterator<ConnectionInstance> connIter = connis.iterator();
            boolean errorReported = false;
            state.push(iter);
            while (connIter.hasNext()) {
                EndToEndFlowInstance eteiClone = null;
                Stack<FlowIterator> stateClone = null;
                ConnectionInstance conni = connIter.next();
                boolean prepareNext = connIter.hasNext();
                EndToEndFlowElement leaf = null;
                ComponentInstance target = null;
                if (conni.getDestination() instanceof ComponentInstance) {
                    target = (ComponentInstance) conni.getDestination();
                    if (target.getCategory() == ComponentCategory.DATA) {
                        leaf = target.getSubcomponent();
                    }
                } else {
                    if (!errorReported) {
                        errorReported = true;
                        error(etei, "Data access feature " + da.getQualifiedName() + " is not a proxy for a data component.");
                    }
                }
                if (leaf != null) {
                    if (prepareNext) {
                        stateClone = clone(state);
                        eteiClone = EcoreUtil.copy(etei);
                        etei.setName(etei.getEndToEndFlow().getName());
                        eteiClone.getModesList().addAll(etei.getModesList());
                    }
                    etei.getFlowElements().add(conni);
                    addLeafElement(target, etei, leaf);
                    // prepare next connection filter
                    Connection lastConn = connections.get(connections.size() - 1);
                    connections.clear();
                    if (iter.hasNext()) {
                        Element obj = iter.next();
                        Connection nextConn = null;
                        if (obj instanceof FlowSegment) {
                            FlowElement fe = ((FlowSegment) obj).getFlowElement();
                            if (fe instanceof Connection) {
                                nextConn = (Connection) fe;
                            }
                        } else if (obj instanceof EndToEndFlowSegment) {
                            EndToEndFlowElement fe = ((EndToEndFlowSegment) obj).getFlowElement();
                            if (fe instanceof Connection) {
                                nextConn = (Connection) fe;
                            }
                        }
                        if (nextConn != null) {
                            int i = conni.getConnectionReferences().size() - 1;
                            Connection preConn = null;
                            while (i > 0 && preConn != lastConn) {
                                preConn = conni.getConnectionReferences().get(i--).getConnection();
                                if (preConn != lastConn) {
                                    connections.add(preConn);
                                }
                            }
                            connections.add(nextConn);
                        }
                    }
                    continueFlow(ci, etei, state.pop(), ci);
                    if (prepareNext) {
                        // add clone
                        etei.getContainingComponentInstance().getEndToEndFlows().add(eteiClone);
                        etei = eteiClone;
                        state = stateClone;
                        addETEI.add(etei);
                        if (etei.getFlowElements() == null || etei.getFlowElements().isEmpty()) {
                            created.add(myInfo = new ETEInfo(etei));
                        } else {
                            created.add(myInfo = new ETEInfo(myInfo.preConns, etei));
                        }
                    }
                }
            }
        }
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ModalElement(org.osate.aadl2.ModalElement) Element(org.osate.aadl2.Element) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) NamedElement(org.osate.aadl2.NamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) Connection(org.osate.aadl2.Connection) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) FlowSegment(org.osate.aadl2.FlowSegment) NamedElement(org.osate.aadl2.NamedElement)

Example 58 with Connection

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

the class CreateEndToEndFlowsSwitch method processETESegment.

/**
 * Add all flow instances that continue through the next flow element.
 *
 * @param ci the component instance we're in
 * @param etei the current flow instance
 * @param fe the next flow element
 * @param iter the position in the current ETE declaration
 * @param errorElement the model element that we attach errors to
 */
protected void processETESegment(ComponentInstance ci, EndToEndFlowInstance etei, Element fs, FlowIterator iter, NamedElement errorElement) {
    final Element fe;
    if (fs instanceof FlowSegment) {
        fe = ((FlowSegment) fs).getFlowElement();
    } else {
        fe = ((EndToEndFlowSegment) fs).getFlowElement();
    }
    if (fe instanceof Connection) {
        if (etei.getFlowElements() == null || etei.getFlowElements().isEmpty()) {
            myInfo.preConns.add((Connection) fe);
        } else {
            connections.add((Connection) fe);
        }
    } else {
        if (fe instanceof FlowSpecification) {
            final Subcomponent sc = (Subcomponent) (fs instanceof FlowSegment ? ((FlowSegment) fs).getContext() : ((EndToEndFlowSegment) fs).getContext());
            final ComponentInstance sci = ci.findSubcomponentInstance(sc);
            if (sci != null) {
                processSubcomponentFlow(sci, etei, (FlowSpecification) fe, iter);
            } else {
                error(etei.getContainingComponentInstance(), "Incomplete End-to-end flow instance " + etei.getName() + ": Could not find component instance for subcomponent " + sc.getName() + " in flow implementation " + errorElement.getName());
            }
        } else if (fe instanceof Subcomponent) {
            ComponentInstance sci = ci.findSubcomponentInstance((Subcomponent) fe);
            processFlowStep(sci, etei, fe, iter);
        } else if (fe instanceof DataAccess) {
            processDataAccess(ci, etei, (DataAccess) fe, iter);
        } else if (fe instanceof EndToEndFlow) {
            processEndToEndFlow(ci, etei, (EndToEndFlow) fe, iter);
        }
    }
}
Also used : EndToEndFlow(org.osate.aadl2.EndToEndFlow) FlowSpecification(org.osate.aadl2.FlowSpecification) ModalElement(org.osate.aadl2.ModalElement) Element(org.osate.aadl2.Element) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) NamedElement(org.osate.aadl2.NamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) Subcomponent(org.osate.aadl2.Subcomponent) Connection(org.osate.aadl2.Connection) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) FlowSegment(org.osate.aadl2.FlowSegment) DataAccess(org.osate.aadl2.DataAccess)

Example 59 with Connection

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

the class AadlUtil method getInstanceOrigin.

// /**
// * Find the Element whose location reference is close to the line number.
// *
// * @param modelelement The model element used as root of the search
// * @param location line number
// * @return Element
// */
// public static Element findElement(Element modelelement, int location) {
// return doFindElement(modelelement, location, modelelement);
// }
// 
// /**
// * Find an Element whose reference location is the largest less or equal to
// * the location we are looking for. This find method cannot assume that the
// * elements of the object model are visited in unparse order. Therefore we
// * search the whole containment tree for the closest element whose location
// * reference is less or equal to the desired location.
// *
// * @param modelelement The model element and its sub elements to be visited
// * @param location The location as line whose Element equivalent we are
// *            trying to find
// * @param closestLocation the last Element whose location reference is less
// *            or equal than the location
// * @return Element the last visited Element whose location reference matches
// *         the condition
// */
// private static Element doFindElement(Element modelelement, int location, Element closestLocation) {
// LocationReference loc = modelelement.getLocationReference();
// if (loc != null) {
// int thisline = loc.getLine();
// if (thisline > location) {
// return closestLocation;
// } else if (thisline == location) {
// return modelelement;
// } else {
// // out location is less than the desired location. Check if it
// // closer than the previously remembered location
// LocationReference closeloc = closestLocation.getLocationReference();
// if (closeloc == null) {
// closestLocation = modelelement;
// } else if (thisline > closeloc.getLine()) {
// closestLocation = modelelement;
// }
// }
// }
// EList<EObject> list = modelelement.eContents();//getOwnedElements();		for (Iterator<Element> it = list.iterator(); it.hasNext();) {
// for (Iterator<EObject> it = list.iterator(); it.hasNext();) {
// Element child = (Element) it.next();
// Element result = doFindElement(child, location, closestLocation);
// if (result != closestLocation) {
// closestLocation = result;
// }
// }
// return closestLocation;
// }
// 
// private static final String PropertySetLabel = "propertySet[@name=";
// private static final String PackageLabel = "aadlPackage[@name=";
public static Element getInstanceOrigin(InstanceObject io) {
    List<? extends NamedElement> el = io.getInstantiatedObjects();
    Element target = null;
    if (el.size() == 0) {
        return null;
    } else if (el.size() == 1) {
        target = el.get(0);
    } else if (el.size() > 1) {
        for (NamedElement o : el) {
            if (o instanceof Connection) {
                Connection conn = (Connection) o;
                if ((conn.getAllSourceContext() instanceof Subcomponent && conn.getAllDestinationContext() instanceof Subcomponent) || (conn.getAllSourceContext() == null || conn.getAllDestinationContext() == null)) {
                    target = conn;
                    break;
                }
            }
        }
        if (target instanceof InstanceObject) {
            target = el.get(0);
        }
    }
    return target;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) ModalElement(org.osate.aadl2.ModalElement) Element(org.osate.aadl2.Element) RefinableElement(org.osate.aadl2.RefinableElement) FlowElement(org.osate.aadl2.FlowElement) ConnectedElement(org.osate.aadl2.ConnectedElement) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ThreadGroupSubcomponent(org.osate.aadl2.ThreadGroupSubcomponent) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) NamedElement(org.osate.aadl2.NamedElement)

Example 60 with Connection

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

the class ComponentImplementationImpl method getAllConnections.

/**
 * get list of all connection objects of a component implementation,
 * including ancestor features In case of refined connections the refined
 * connection is returned in the list.
 *
 * @return List of connection objects
 */
// XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
public EList<Connection> getAllConnections() {
    final EList<Classifier> ancestors = getSelfPlusAllExtended();
    final BasicEList<Connection> returnlist = new BasicEList<Connection>();
    // Process from farthest ancestor to self
    for (ListIterator<Classifier> li = ancestors.listIterator(ancestors.size()); li.hasPrevious(); ) {
        final ComponentImplementation current = (ComponentImplementation) li.previous();
        final EList<Connection> currentItems = current.getOwnedConnections();
        if (currentItems != null) {
            for (Iterator<Connection> i = currentItems.iterator(); i.hasNext(); ) {
                final Connection fe = i.next();
                final Connection rfe = fe.getRefined();
                if (rfe != null) {
                    returnlist.remove(rfe);
                }
                returnlist.add(fe);
            }
        }
    }
    return returnlist;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) BasicEList(org.eclipse.emf.common.util.BasicEList) FeatureConnection(org.osate.aadl2.FeatureConnection) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection) Classifier(org.osate.aadl2.Classifier)

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