use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class SetParallelizationCommand method setDeparallelization.
private void setDeparallelization(INode node) {
if (node.isActivate()) {
for (IConnection con : node.getIncomingConnections()) {
EConnectionType lineStyle = con.getLineStyle();
if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.NONE.getName()).setValue(Boolean.FALSE);
con.setPropertyValue(EParameterName.DEPARTITIONER.getName(), Boolean.TRUE);
}
}
if (node.getOutgoingConnections().size() > 0) {
setParallelization(node);
}
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class Connection method orderConnectionsByMetadata.
private void orderConnectionsByMetadata() {
List<IMetadataTable> tableList = source.getMetadataList();
List<IConnection> connectionList = (List<IConnection>) source.getOutgoingConnections();
List<IConnection> tmpList = new ArrayList<IConnection>(connectionList);
connectionList.clear();
for (IMetadataTable table : tableList) {
String tableName = table.getTableName();
for (IConnection connection : tmpList) {
if (connection.isActivate() && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && connection.getMetadataTable() != null && connection.getMetadataTable().getTableName() != null && connection.getMetadataTable().getTableName().equals(tableName) && connection.getConnectorName().equals(table.getAttachedConnector())) {
connectionList.add(connection);
}
}
}
// add connections without metadata
for (IConnection connection : tmpList) {
if (!connectionList.contains(connection)) {
connectionList.add(connection);
}
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionPart method createFigure.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure()
*/
@Override
protected IFigure createFigure() {
IConnection conn = (IConnection) getModel();
ConnectionFigure connection = new ConnectionFigure(conn, conn.getSourceNodeConnector().getConnectionProperty(conn.getLineStyle()), conn.getSource());
if (DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
connection.setLineWidth(2);
connection.setConnectionRouter(new TalendBorderItemRectilinearRouter());
} else {
connection.setLineWidth(1);
}
if (((Connection) getModel()).isActivate()) {
connection.setAlpha(-1);
} else {
connection.setAlpha(Connection.ALPHA_VALUE);
}
if (PluginChecker.isAutoParalelPluginLoaded()) {
connection.updateStatus();
}
return connection;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class SetParallelizationCommand method isComponentNeedRepartion.
private boolean isComponentNeedRepartion(IConnection con, Node needToPar) {
String partitioning = needToPar.getComponent().getPartitioning();
if (partitioning.equals("AUTO")) {
if (ParallelExecutionUtils.existPreviousPar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousDepar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousRepar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousNone((Node) con.getSource())) {
return false;
}
return true;
} else {
// compare the target node's key with the previous tPartitioner's hashKeys to see if need repartitioning.
boolean needRepar = false;
IConnection previousParCon = ParallelExecutionUtils.getPreviousParCon((Node) con.getSource());
if (previousParCon != null) {
String[] partitionKey = partitioning.split("\\.");
IElementParameter parTableCon = previousParCon.getElementParameter(HASH_KEYS);
IElementParameter parTableNode = needToPar.getElementParameter(partitionKey[0]);
if (parTableNode != null) {
// for the partition key
String clumnKeyListName = "KEY_COLUMN";
String clumnNodeListName = partitionKey[1];
List<String> parKeyValues = new ArrayList<String>();
List<String> columnKeyValues = new ArrayList<String>();
ElementParameter nodeElemForList = null;
for (Map conColumnListMap : (List<Map>) parTableCon.getValue()) {
if (conColumnListMap.get(clumnKeyListName) instanceof String) {
parKeyValues.add((String) conColumnListMap.get(clumnKeyListName));
}
}
for (Object nodeItemList : parTableNode.getListItemsValue()) {
if (((ElementParameter) nodeItemList).getFieldType().equals(EParameterFieldType.PREV_COLUMN_LIST) || ((ElementParameter) nodeItemList).getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
nodeElemForList = (ElementParameter) nodeItemList;
break;
}
}
if (nodeElemForList != null) {
for (Map nodeColumnListMap : (List<Map>) parTableNode.getValue()) {
Object value = nodeColumnListMap.get(clumnNodeListName);
if (nodeColumnListMap.get(clumnNodeListName) instanceof String) {
columnKeyValues.add((String) value);
} else if (value instanceof Integer) {
Integer index = (Integer) value;
if (nodeElemForList.getListItemsDisplayName().length > index) {
columnKeyValues.add(nodeElemForList.getListItemsDisplayName()[index]);
}
}
}
}
if (columnKeyValues.size() > 0) {
if (columnKeyValues.equals(parKeyValues)) {
needRepar = false;
} else {
needRepar = true;
}
}
}
}
return needRepar;
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class TableByRowController method updateSubjobStarts.
/**
* DOC nrousseau Comment method "updateSubjobStarts".
*
* @param param
*/
public static void updateSubjobStarts(IElement element, IElementParameter param) {
if (!param.isBasedOnSubjobStarts() || !(element instanceof Node)) {
return;
}
// Each time one link of the type SUBJOB_START_ORDER will be connected or disconnected
// it will update the value of this table.
List<String> uniqueNameStarts = new ArrayList<String>();
Node node = (Node) element;
List<IConnection> incomingSubjobStartsConn = (List<IConnection>) node.getIncomingConnections(EConnectionType.SYNCHRONIZE);
for (IConnection connection : incomingSubjobStartsConn) {
uniqueNameStarts.add(connection.getSource().getUniqueName());
}
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
List<Map<String, Object>> newParamValues = new ArrayList<Map<String, Object>>();
String[] codes = param.getListItemsDisplayCodeName();
for (String currentUniqueNameStart : uniqueNameStarts) {
Map<String, Object> newLine = null;
boolean found = false;
for (int k = 0; k < paramValues.size() && !found; k++) {
Map<String, Object> currentLine = paramValues.get(k);
if (currentLine.get(codes[0]).equals(currentUniqueNameStart)) {
found = true;
newLine = currentLine;
}
}
if (!found) {
newLine = TableController.createNewLine(param);
newLine.put(codes[0], currentUniqueNameStart);
}
newParamValues.add(newLine);
}
paramValues.clear();
paramValues.addAll(newParamValues);
}
Aggregations