use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class AadlBaUtils method prototypeBindingResolverForDataComponentReference.
/**
* Returns the DataClassifier object associated to prototype binding in a DataComponentReference
*
* @param r the DataComponentRefenrence object from which the binding will be resolved
* @param dp the DataPrototpye object that enables to identify the targeted prototype binding
* @param parentContainer the object that contains the element binded to the
* given DataComponentRefenrence
* @return the DataClassifier object
*/
private static DataClassifier prototypeBindingResolverForDataComponentReference(DataComponentReference r, DataPrototype dp, NamedElement parentContainer) {
if (r.getData().size() > 1) {
DataHolder h = r.getData().get(r.getData().size() - 2);
NamedElement parent = h.getElement();
if (parent instanceof Classifier) {
Classifier c = (Classifier) parent;
return getDataClassifier(c.getOwnedPrototypeBindings(), dp);
}
if (parent instanceof Subcomponent) {
Subcomponent s = (Subcomponent) parent;
return getDataClassifier(s.getOwnedPrototypeBindings(), dp);
} else if (parent instanceof DataAccess) {
DataAccess da = (DataAccess) parent;
DataSubcomponentType parentDst = da.getDataFeatureClassifier();
Classifier c = (Classifier) parentDst;
DataClassifier matchedPrototype = getDataClassifier(c.getOwnedPrototypeBindings(), dp);
if (matchedPrototype == null) {
if (parentContainer instanceof ComponentType) {
ComponentType ct = (ComponentType) parentContainer;
for (Feature f : ct.getOwnedFeatures()) {
if (f instanceof DataAccess && f.getName().equals(parent.getName())) {
DataAccess containerDa = (DataAccess) f;
DataSubcomponentType containerDst = containerDa.getDataFeatureClassifier();
Classifier c2 = (Classifier) containerDst;
return getDataClassifier(c2.getOwnedPrototypeBindings(), dp);
}
}
}
}
} else if (parent instanceof DataPort) {
DataPort dataport = (DataPort) parent;
DataSubcomponentType parentDst = dataport.getDataFeatureClassifier();
Classifier c = (Classifier) parentDst;
DataClassifier matchedPrototype = getDataClassifier(c.getOwnedPrototypeBindings(), dp);
if (matchedPrototype == null) {
if (parentContainer instanceof ComponentType) {
ComponentType ct = (ComponentType) parentContainer;
for (Feature f : ct.getOwnedFeatures()) {
if (f instanceof DataPort && f.getName().equals(parent.getName())) {
DataPort containerDp = (DataPort) f;
DataSubcomponentType containerDst = containerDp.getDataFeatureClassifier();
Classifier c2 = (Classifier) containerDst;
return getDataClassifier(c2.getOwnedPrototypeBindings(), dp);
}
}
}
}
}
}
return null;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class Aadl2Utils method orderFeatures.
/**
* Returns the sorted (see FeaturePositionComparator) list of features (included
* inherited features) owned by the given Classifier object.
*
* @param cpt the given Classifier object
* @param inheritedBindings inherited prototype bindings
* @return the sorted list of features owned by the given Component object
*/
public static List<Feature> orderFeatures(Classifier cpt, List<PrototypeBinding> inheritedBindings) {
// List<PrototypeBinding> bindings = cpt.getOwnedPrototypeBindings();
List<PrototypeBinding> bindings = new ArrayList<PrototypeBinding>();
bindings.addAll(cpt.getOwnedPrototypeBindings());
bindings.addAll(inheritedBindings);
List<Feature> res = new ArrayList<Feature>();
for (Feature f : cpt.getAllFeatures()) {
res.add(getBindedFeature(bindings, f));
}
// res.addAll(cpt.getAllFeatures()) ;
FeaturePositionComparator comparator = new FeaturePositionComparator();
Collections.sort(res, comparator);
return res;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class CreateConnectionsSwitch method filterOutgoingConnections.
/**
* Get outgoing connections for specified feature port group connections are
* non-directional, i.e., they are always added
*
* @param conns
* a list of connections that go away from a subcomponent
* @param feature
* subcomponent feature that can be the source of a connection
* @return connections with feature as source for ConnectionInstances
*/
public List<Connection> filterOutgoingConnections(List<Connection> conns, Feature feature, Subcomponent sub) {
List<Connection> result = new ArrayList<Connection>(conns.size());
List<Feature> features = feature.getAllFeatureRefinements();
EList<Subcomponent> subs = sub.getAllSubcomponentRefinements();
for (Connection conn : conns) {
if ((features.contains(conn.getAllSource()) && subs.contains(conn.getAllSourceContext())) || (conn.isAllBidirectional() && features.contains(conn.getAllDestination()) && subs.contains(conn.getAllDestinationContext()))) {
result.add(conn);
}
}
return result;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class CreateEndToEndFlowsSwitch method isValidContinuation.
boolean isValidContinuation(EndToEndFlowInstance etei, ConnectionInstance conni, FlowSpecification fspec) {
/*
* Issue 2009: Check if the connection instance connects to the flow spec. Here we have a weird
* situation. If the subcomponent the flow spec is qualified by is only described by a component type, then
* connection end is going to match up with the beginning of the flow. That's fine. If the component
* has a classifier implementation AND the flow spec has a flow implementation, then everything will also
* fine: either the connection instance is correct and reaches the start of the flow implementation, or it
* is incorrect and doesn't. But we can also have the case that the subcomponent is described by a
* component implementation but the flow spec does not have a flow implementation. In this case we
* still may have the case the connection instance continues into the subcomponent and terminates at a
* subsubcomponent. But the flow spec that we have here will be at the edge of the original subcomponent.
* so the end connection instance will not match up with the start of the flow spec.
*
* So what we really need to do is walk backwards along the connections that make up the connection instance
* until we find one that connects to the flow because as wee the connection instance may "punch through" the
* subcomponent.
*/
final FlowEnd inEnd = fspec.getAllInEnd();
final Context flowCxt = inEnd.getContext();
final Feature flowIn = inEnd.getFeature();
final List<Feature> flowInRefined = flowIn.getAllFeatureRefinements();
final EList<ConnectionReference> connRefs = conni.getConnectionReferences();
int idx = connRefs.size() - 1;
boolean result = false;
while (!result && idx >= 0) {
final Connection conn = connRefs.get(idx).getConnection();
result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getDestination());
if (!result && conn.isBidirectional()) {
result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getSource());
}
idx -= 1;
}
return result;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class InstantiateModel method hasFeatureInstance.
/*
* check to see if the specified feature already exists as feature
* instance in the ancestry
*/
private boolean hasFeatureInstance(FeatureInstance fi, Feature f) {
EObject parent = fi;
while (parent instanceof FeatureInstance) {
Feature df = ((FeatureInstance) parent).getFeature();
if (df == f) {
return true;
}
parent = parent.eContainer();
}
return false;
}
Aggregations