use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionManager method getAllSourceNode.
/**
* DOC bqian Comment method "getAllSourceNode".
*
* @param source
* @param list
*/
private static void getAllSourceNode(INode source, List<INode> list) {
List<? extends IConnection> connections = source.getIncomingConnections();
for (IConnection connection : connections) {
INode node = connection.getSource();
list.add(node);
getAllSourceNode(node, list);
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionManager method countNbMergeOutgoing.
private static int countNbMergeOutgoing(INode node, Set<INode> checkedNode) {
int curNb = 0;
if (checkedNode.contains(node)) {
return 0;
}
checkedNode.add(node);
if (node.getComponent().useMerge()) {
// if the component use merge even if there is no connection, then add one merge.
curNb++;
}
for (IConnection curConnec : node.getOutgoingConnections()) {
if (curConnec.getLineStyle().equals(EConnectionType.FLOW_MERGE)) {
curNb++;
} else if (curConnec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
// if main, then test the next component to check if there is a merge
curNb += countNbMergeOutgoing(curConnec.getTarget(), checkedNode);
}
}
return curNb;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionManager method canConnectToTarget.
public static boolean canConnectToTarget(INode source, INode oldTarget, INode newTarget, EConnectionType lineStyle, String connectorName, String connectionName, boolean refactorJoblet) {
newlineStyle = lineStyle;
if (source.equals(newTarget)) {
return false;
}
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isTriggerNode(newTarget) && !service.canConnectTriggerNode(newTarget, lineStyle)) {
return false;
}
// can't connect from joblet's node, bug 21411
if (service.isJobletComponent(source.getJobletNode())) {
return false;
}
}
}
INode processStartNode = source.getProcessStartNode(true);
// if the target is the start of the (source) process, then can't connect.
if (processStartNode.equals(newTarget)) {
return false;
}
// to avoid different db elt input link to map.
if (newTarget.isELTComponent() && newTarget.getComponent().getName().endsWith("Map")) {
//$NON-NLS-1$
String targetName = newTarget.getComponent().getOriginalFamilyName();
String sourceName = processStartNode.getComponent().getOriginalFamilyName();
if (!targetName.equals(sourceName) && !(lineStyle.hasConnectionCategory(IConnectionCategory.DEPENDENCY))) {
return false;
}
}
// fix bug 0004935: Error on job save
if (checkCircle(source, newTarget)) {
return false;
}
if (newTarget.isFileScaleComponent()) {
if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW) && !connectorName.equals("FSCOMBINE")) {
//$NON-NLS-1$
return false;
}
}
// Modify Connection Type depending old and new target.
if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
// if the connection type is not the default one, then we don't change automatically.
// && newlineStyle.getName().equals(newConnectionType)) {
newlineStyle = EConnectionType.FLOW_MAIN;
if (newTarget.getComponent().useLookup()) {
int nbMain = 0;
for (IConnection connec : newTarget.getIncomingConnections()) {
if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
nbMain++;
}
}
if (nbMain >= 1) {
newlineStyle = EConnectionType.FLOW_REF;
} else {
newlineStyle = EConnectionType.FLOW_MAIN;
}
} else if (newTarget.getComponent().useMerge()) {
newlineStyle = EConnectionType.FLOW_MERGE;
}
}
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(newTarget) && !lineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
List<INodeConnector> inputConnector = service.getFreeTriggerBuiltConnectors(newTarget, lineStyle, true);
if (inputConnector.isEmpty()) {
return false;
}
isJoblet = true;
}
}
if (!isJoblet) {
INodeConnector connectorFromType = newTarget.getConnectorFromType(newlineStyle);
int maxInput = connectorFromType.getMaxLinkInput();
if (maxInput != -1 && (connectorFromType.getCurLinkNbInput() >= maxInput)) {
return false;
}
}
if (!canConnect(source, newTarget, lineStyle, connectionName, refactorJoblet)) {
return false;
}
return true;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionManager method testIfNoStartAfterAddConnection.
private static boolean testIfNoStartAfterAddConnection(Node source, Node target) {
// connection is added only to test if there is still a start
// it will be removed after the test
INode targetStartNode = target.getProcessStartNode(true);
INode sourceStartNode = source.getProcessStartNode(true);
Connection connection = new Connection(source, target, newlineStyle, false);
((List<IConnection>) source.getOutgoingConnections()).add(connection);
((List<IConnection>) target.getIncomingConnections()).add(connection);
boolean noStart = (!((Node) sourceStartNode).checkIfCanBeStart()) && ((targetStartNode == null) || (!((Node) targetStartNode).checkIfCanBeStart()));
((List<IConnection>) source.getOutgoingConnections()).remove(connection);
((List<IConnection>) target.getIncomingConnections()).remove(connection);
return noStart;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class SetParallelizationCommand method setParallelization.
private void setParallelization(INode node) {
if (node.isActivate()) {
if (node.getOutgoingConnections().size() > 0) {
for (IConnection con : node.getOutgoingConnections()) {
EConnectionType lineStyle = con.getLineStyle();
if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
if (!lineStyle.equals(EConnectionType.FLOW_MERGE)) {
boolean isEndRow = con.getTarget().getOutgoingConnections().size() == 0;
boolean isStartRow = node.isStart();
if (ParallelExecutionUtils.isPartitionKeysExist(con)) {
ParallelExecutionUtils.reSetParKeyValuesForCon(con);
}
if (!isEndRow && isComponentCanParlization(con, (Node) con.getTarget())) {
// tPartitioner,need do Repartitioner automatic
if (isExistParalInSubjob(existParallelMap, node) && !isStartRow && isComponentNeedRepartion(con, (Node) con.getTarget())) {
setRepartioner(con);
} else {
// when pervious con is par/repar/none,keep current is none
if (isExistParalInSubjob(existParallelMap, node) && (ParallelExecutionUtils.existPreviousPar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousNone((Node) con.getSource()) || ParallelExecutionUtils.existPreviousRepar((Node) con.getSource()))) {
setNone(con);
} else {
setPartioner(con, lineStyle, isStartRow);
}
}
} else {
if (!con.getSource().isStart()) {
setDepartioner(con);
}
}
} else {
setParallelization(con.getTarget());
}
} else {
// in case the con here is not data flow,such as onSubjobOk,we skip to next target
setParallelization(con.getTarget());
}
}
} else {
if (!node.isStart()) {
setDeparallelization(node);
}
}
}
}
Aggregations