use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method dummyMiddleElement.
private void dummyMiddleElement(boolean undo) {
Map<List<INode>, List<IConnection>> middConnMap = getAllMiddleConnections();
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
List<IConnection> notSameForConn = new ArrayList<IConnection>();
List<INode> notSameForNode = new ArrayList<INode>();
List<Node> connNodeList = new ArrayList<Node>();
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> nodeList = entry.getKey();
List<IConnection> connList = entry.getValue();
if (nodeList.size() == 2) {
INode firNode = nodeList.get(0);
INode secNode = nodeList.get(1);
if (!notSameForNode.contains(firNode)) {
notSameForNode.add(firNode);
}
if (!notSameForNode.contains(secNode)) {
notSameForNode.add(secNode);
}
for (IConnection conn : connList) {
if (!notSameForConn.contains(conn)) {
notSameForConn.add(conn);
} else {
continue;
}
Node source = (Node) conn.getSource();
if (source.getUniqueName() != firNode.getUniqueName() && (source.getUniqueName() != secNode.getUniqueName())) {
if (isSameSchemaInputOutput(source)) {
conn.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
source.setPropertyValue(EParameterName.DUMMY.getName(), true);
// source.setPropertyValue(EParameterName.ACTIVATE.getName(), source.isActivate());
connNodeList.add(source);
}
}
Node target = (Node) conn.getTarget();
if (target.getUniqueName() != firNode.getUniqueName() && (target.getUniqueName() != secNode.getUniqueName())) {
if (isSameSchemaInputOutput(target)) {
conn.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
target.setPropertyValue(EParameterName.DUMMY.getName(), true);
// target.setPropertyValue(EParameterName.ACTIVATE.getName(), target.isActivate());
connNodeList.add(target);
}
}
}
}
}
for (Node node : connNodeList) {
node.setPropertyValue(EParameterName.ACTIVATE.getName(), node.isActivate());
}
if (!value) {
for (Node node : nodeList) {
if (node.isActivate()) {
continue;
}
Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
while (outIte.hasNext()) {
Entry<IConnection, Node> en = outIte.next();
IConnection enConn = en.getKey();
if (!notSameForConn.contains(enConn)) {
// if (enConn.isActivate()) {
enConn.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
if (!notSameForNode.contains(enConn.getTarget()) && !hasActivateInputOutput((Node) enConn.getTarget())) {
enConn.getTarget().setPropertyValue(EParameterName.DUMMY.getName(), value);
}
// }
}
}
Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
while (inIte.hasNext()) {
Entry<IConnection, Node> en = inIte.next();
IConnection enConn = en.getKey();
if (!notSameForConn.contains(enConn)) {
// if (enConn.isActivate()) {
enConn.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
if (!notSameForNode.contains(enConn.getSource()) && !hasActivateInputOutput((Node) enConn.getSource())) {
enConn.getSource().setPropertyValue(EParameterName.DUMMY.getName(), value);
}
// }
}
}
}
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method getAllMiddleConnections.
private Map<List<INode>, List<IConnection>> getAllMiddleConnections() {
Map<List<INode>, List<IConnection>> middConnMap = new HashMap<List<INode>, List<IConnection>>();
Process process;
if (nodeList.size() > 0) {
process = (Process) nodeList.get(0).getProcess();
} else {
process = (Process) connectionList.get(0).getSource().getProcess();
}
List<? extends INode> nodes = process.getGraphicalNodes();
List<INode> jobletandnodeList = new ArrayList<INode>();
for (INode node : nodes) {
if (((Node) node).isJoblet() && !((Node) node).getNodeContainer().isCollapsed() && (((Node) node).getNodeContainer() instanceof AbstractJobletContainer)) {
for (NodeContainer nc : ((AbstractJobletContainer) ((Node) node).getNodeContainer()).getNodeContainers()) {
jobletandnodeList.add(nc.getNode());
}
} else {
jobletandnodeList.add(node);
}
}
for (INode node : jobletandnodeList) {
if (node.isActivate()) {
Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
boolean haveActivateTarget = false;
List<INode> nodeList = new ArrayList<INode>();
List<IConnection> connList = new ArrayList<IConnection>();
while (outIte.hasNext()) {
Entry<IConnection, Node> en = outIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateTarget = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateTarget) {
outMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
boolean haveActivateSource = false;
nodeList = new ArrayList<INode>();
connList = new ArrayList<IConnection>();
while (inIte.hasNext()) {
Entry<IConnection, Node> en = inIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateSource = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateSource) {
inMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
}
}
return middConnMap;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ChangeMergeOrderCommand method reOrder.
private List<Map<String, Object>> reOrder(List<Map<String, Object>> values) {
List<Map<String, Object>> newValues = new ArrayList<Map<String, Object>>();
if (values == null || values.isEmpty()) {
return newValues;
}
List<? extends IConnection> incomingConnections = this.mergeNode.getIncomingConnections();
for (IConnection conn : incomingConnections) {
if (conn.getLineStyle().hasConnectionCategory(org.talend.core.model.process.IConnectionCategory.FLOW)) {
String uniqueName = conn.getUniqueName();
List<Map<String, Object>> findConnValue = findConnValue(values, uniqueName);
if (findConnValue != null) {
newValues.addAll(findConnValue);
}
}
}
return newValues;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class CodeGenerator method getIncomingNameForMerge.
/**
* get the incomingName matching with inputId. Purpose: It will generate different parts for the merge node
* according the different incomingName.
*
* @param branchStartNode
* @param mergeNode
* @return
*/
private String getIncomingNameForMerge(INode branchStartNode, INode mergeNode) {
Map<INode, Integer> mergeInfo = branchStartNode.getLinkedMergeInfo();
int inputId = ((Integer) mergeInfo.values().toArray()[0]).intValue();
List<? extends IConnection> incomingConnections = mergeNode.getIncomingConnections();
for (int i = 0; i < incomingConnections.size(); i++) {
IConnection connec = incomingConnections.get(i);
if (connec.isActivate()) {
if (connec.getLineStyle().hasConnectionCategory(EConnectionType.MERGE)) {
// if find, then return
if (connec.getInputId() == inputId) {
return connec.getName();
}
}
}
}
return null;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class NodeConnectionsHelper method initOutputConnections.
/**
* Inits the {@link #dataOutputs}, {@link #connResponse}, {@link #connFault}
* connections.
*/
private void initOutputConnections() {
List<? extends IConnection> conns = node.getOutgoingSortedConnections();
dataOutputs = new ArrayList<IConnection>();
if (conns != null) {
for (IConnection conn : conns) {
if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
dataOutputs.add(conn);
}
}
}
List<? extends IConnection> connsResponse = node.getOutgoingConnections("RESPONSE");
List<? extends IConnection> connsFault = node.getOutgoingConnections("FAULT");
if (connsResponse.size() == 1) {
connResponse = connsResponse.get(0);
}
if (connsFault.size() == 1) {
connFault = connsFault.get(0);
}
}
Aggregations