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;
}
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));
}
}
}
}
}
}
}
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);
}
}
}
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;
}
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;
}
Aggregations