use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.
the class DeleteNodeContainerCommand method execute.
@Override
@SuppressWarnings("unchecked")
public void execute() {
connectionDeletedInfosMap = new MultiKeyMap();
process.setActivate(false);
List uniqueNameList = new ArrayList();
for (INode node : nodeList) {
if (node.getJobletNode() != null) {
continue;
}
uniqueNameList.add(node.getUniqueName());
NodeContainer nodeContainer = ((Node) node).getNodeContainer();
((Process) process).removeNodeContainer(nodeContainer);
List<IConnection> inputList = (List<IConnection>) node.getIncomingConnections();
List<IConnection> outputList = (List<IConnection>) node.getOutgoingConnections();
boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
for (IConnection connection : inputList) {
// see bug 0002633: "rejects" link disappears at times.
if (connection != null && connection.getSourceNodeConnector() != null) {
connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() - 1);
}
INode prevNode = connection.getSource();
if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
Node jobletnode = (Node) prevNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().remove(connection);
if (!nodeList.contains(jobletnode)) {
boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
storeMetadata(connection, jobletnode, true);
jobletnode.removeOutput(connection);
if (!builtInJobletNode) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
if (!nodeList.contains(prevNode)) {
boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
boolean remove = true;
if ((prevNode instanceof Node) && ((Node) prevNode).isELTMapComponent()) {
remove = false;
}
storeMetadata(connection, prevNode, remove);
prevNode.removeOutput(connection);
if (!builtInPrevNode && remove) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
for (IConnection connection : outputList) {
INode nextNode = connection.getTarget();
if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
Node jobletnode = (Node) nextNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().remove(connection);
if (!nodeList.contains(jobletnode)) {
jobletnode.removeInput(connection);
boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
if (!builtInJobletNode) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
if (!nodeList.contains(nextNode)) {
INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() - 1);
nextNode.removeInput(connection);
if (nextNode != null) {
for (int i = 0; i < nextNode.getIncomingConnections().size(); i++) {
Connection nextNodeConnection = (Connection) nextNode.getIncomingConnections().get(i);
nextNodeConnection.updateName();
}
}
if (nextNode.getExternalNode() instanceof AbstractNode) {
((AbstractNode) nextNode.getExternalNode()).removeInput(connection);
}
}
if (!builtIn) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
if (builtIn) {
for (IMetadataTable meta : node.getMetadataList()) {
String metaName = meta.getTableName();
process.removeUniqueConnectionName(metaName);
}
// for tmap remove join table names
final List<String> names = CorePlugin.getDefault().getMapperService().getJoinTableNames(node.getExternalData());
if (!names.isEmpty()) {
joinTableNames.addAll(names);
for (String name : joinTableNames) {
process.removeUniqueConnectionName(name);
}
}
}
}
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.
the class DeleteNodeContainerCommand method undo.
@Override
@SuppressWarnings("unchecked")
public void undo() {
process.setActivate(false);
for (INode node : nodeList) {
if (node.getJobletNode() != null) {
continue;
}
NodeContainer nodeContainer = ((Node) node).getNodeContainer();
this.process.addUniqueNodeName(node.getUniqueName());
((Process) process).addNodeContainer(nodeContainer);
List<Connection> inputList = (List<Connection>) node.getIncomingConnections();
List<Connection> outputList = (List<Connection>) node.getOutgoingConnections();
boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
for (Connection connection : inputList) {
// see bug 0004514: need to undo for 0002633
if (connection != null && connection.getSourceNodeConnector() != null) {
connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() + 1);
}
INode prevNode = connection.getSource();
if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
Node jobletnode = (Node) prevNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().add(connection);
restoreMetadata(connection, jobletnode);
}
if (!nodeList.contains(prevNode)) {
if (!prevNode.getOutgoingConnections().contains(connection)) {
prevNode.addOutput(connection);
}
restoreMetadata(connection, prevNode);
connection.reconnect();
connection.updateAllId();
boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME) && !builtInPrevNode) {
// for bug 10024
// see 10583
String name = connection.getUniqueName();
if (connection.getConnectorName().startsWith("TRIGGER_OUTPUT")) {
if (process.checkValidConnectionName(name)) {
process.addUniqueConnectionName(name);
}
} else {
process.addUniqueConnectionName(name);
}
}
}
}
for (IConnection connection : outputList) {
INode nextNode = connection.getTarget();
if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
Node jobletnode = (Node) nextNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().add(connection);
}
if (!nodeList.contains(nextNode)) {
if (!nextNode.getIncomingConnections().contains(connection)) {
nextNode.addInput(connection);
}
INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() + 1);
connection.reconnect();
if (nextNode.getExternalNode() instanceof AbstractNode) {
((AbstractNode) nextNode.getExternalNode()).addInput(connection);
}
}
if (!builtIn) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME)) {
// for bug 10024
// see 10583
String name = connection.getUniqueName();
// name = process.generateUniqueConnectionName(name);
process.addUniqueConnectionName(name);
}
}
}
if (builtIn) {
for (IMetadataTable meta : node.getMetadataList()) {
String metaName = meta.getTableName();
process.addUniqueConnectionName(metaName);
}
// tmap join table
for (String name : joinTableNames) {
process.addUniqueConnectionName(name);
}
}
}
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.
the class ConnectionDeleteCommand method undo.
@Override
public void undo() {
Process process = (Process) connectionList.get(0).getSource().getProcess();
for (Connection connection : connectionList) {
collpseJoblet(connection);
ConnectionDeletedInfo deletedInfo = connectionDeletedInfosMap.get(connection);
if (deletedInfo != null) {
INode source = connection.getSource();
if (source != null && deletedInfo.metadataTable != null) {
List<IMetadataTable> metaList = source.getMetadataList();
if (!metaList.contains(deletedInfo.metadataTable)) {
metaList.add(deletedInfo.metadataTableIndex, deletedInfo.metadataTable);
}
}
}
connection.reconnect();
INode target = connection.getTarget();
if (target.getExternalNode() instanceof AbstractNode) {
((AbstractNode) target.getExternalNode()).addInput(connection);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
if (nodeConnectorSource != null) {
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
}
nodeConnectorTarget = connection.getTargetNodeConnector();
if (nodeConnectorTarget != null) {
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
}
}
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.
the class ConnectionDeleteCommand method execute.
@Override
public void execute() {
connectionDeletedInfosMap = new HashMap<Connection, ConnectionDeleteCommand.ConnectionDeletedInfo>();
Process process = (Process) connectionList.get(0).getSource().getProcess();
for (Connection connection : connectionList) {
boolean re = deleteExpendNode(connection);
if (re) {
return;
}
ConnectionDeletedInfo deletedInfo = new ConnectionDeletedInfo();
connectionDeletedInfosMap.put(connection, deletedInfo);
INode source = connection.getSource();
if (source != null && source instanceof Node && !(((Node) source).isELTMapComponent())) {
deletedInfo.metadataTable = connection.getMetadataTable();
List<IMetadataTable> metaList = source.getMetadataList();
if (metaList != null && deletedInfo.metadataTable != null) {
deletedInfo.metadataTableIndex = metaList.indexOf(deletedInfo.metadataTable);
}
}
connection.disconnect();
final INode target = connection.getTarget();
if (target.getExternalNode() instanceof AbstractNode) {
((AbstractNode) target.getExternalNode()).removeInput(connection);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
if (nodeConnectorSource != null) {
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
}
nodeConnectorTarget = connection.getTargetNodeConnector();
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
}
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.
the class NodesSubTree method buildBigDataSubTree.
private void buildBigDataSubTree(INode node) {
if (((AbstractNode) node).isThereLinkWithRef()) {
this.isRefSubTree = true;
List<INode> newRefNodes = ((AbstractNode) node).getRefNodes();
if (newRefNodes != null) {
if (refNodes == null) {
refNodes = new ArrayList<INode>(newRefNodes);
} else {
refNodes.addAll(((AbstractNode) node).getRefNodes());
}
for (INode refNode : newRefNodes) {
buildBigDataSubTree(refNode);
}
}
}
for (IConnection connection : node.getOutgoingSortedConnections()) {
if (connection.getTarget().isActivate()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MAIN)) {
if (!connection.getLineStyle().hasConnectionCategory(IConnectionCategory.USE_ITERATE)) {
allMainSubTreeConnections.add(connection);
}
buildBigDataSubTree(connection.getTarget());
}
if (connection.getLineStyle().equals(EConnectionType.RUN_AFTER)) {
afterSubProcesses.add(connection.getTarget().getUniqueName());
}
if (connection.getLineStyle().equals(EConnectionType.ON_SUBJOB_OK)) {
beforeSubProcesses.add(connection.getTarget().getUniqueName());
}
}
}
nodes.add(node);
}
Aggregations