use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class PostgresGenerationManagerTest method mockConnection.
private IConnection mockConnection(String schemaName, String tableName, String[] columns) {
Connection connection = mock(Connection.class);
Node node = mock(Node.class);
ElementParameter param = new ElementParameter(node);
param.setName("ELT_SCHEMA_NAME");
param.setValue(schemaName);
when(node.getElementParameter("ELT_SCHEMA_NAME")).thenReturn(param);
param = new ElementParameter(node);
param.setName("ELT_TABLE_NAME");
param.setValue(tableName);
when(node.getElementParameter("ELT_TABLE_NAME")).thenReturn(param);
when(connection.getName()).thenReturn(schemaName + "." + tableName);
when(connection.getSource()).thenReturn(node);
IMetadataTable table = new MetadataTable();
table.setLabel(tableName);
table.setTableName(tableName);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : columns) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(columnName);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
table.setListColumns(listColumns);
when(connection.getMetadataTable()).thenReturn(table);
return connection;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class DbGenerationManagerTest method createConnection.
private IConnection createConnection(String schemaName, String tableName, String label, String[] columns) {
Connection connection = mock(Connection.class);
when(connection.getName()).thenReturn(tableName);
IMetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(tableName);
metadataTable.setTableName(tableName);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : columns) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(label);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
metadataTable.setListColumns(listColumns);
when(connection.getMetadataTable()).thenReturn(metadataTable);
return connection;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class DbGenerationManagerTest method setUp.
@Before
public void setUp() throws Exception {
dbMapComponent = new DbMapComponent();
ExternalDbMapData externalDbMapData = new ExternalDbMapData();
dbMapComponent.setExternalData(externalDbMapData);
List<ExternalDbMapTable> inputTables = new ArrayList<>();
externalDbMapData.setInputTables(inputTables);
ExternalDbMapTable externalDbMapTable = new ExternalDbMapTable();
inputTables.add(externalDbMapTable);
externalDbMapTable.setName("t1");
externalDbMapTable.setAlias("t1");
externalDbMapTable.setTableName("t1");
externalDbMapTable.setJoinType("NO_JOIN");
tableEntries = new ArrayList<>();
externalDbMapTable.setMetadataTableEntries(tableEntries);
extMapEntry = new ExternalDbMapEntry("id", "t1.id");
tableEntries.add(extMapEntry);
List<IConnection> incomingConnections = new ArrayList<IConnection>();
String[] columns = new String[] { "\\\"id\\\"" };
incomingConnections.add(createConnection("t1", "t1", "id", columns));
dbMapComponent.setIncomingConnections(incomingConnections);
dbManager = new GenericDbGenerationManager();
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class XMLMapperHelper method hasAggregateColumn.
private static boolean hasAggregateColumn(final INode xmlMapperNode) {
boolean hasAggregateColumn = false;
List<? extends IConnection> outConnections = (List<? extends IConnection>) xmlMapperNode.getOutgoingConnections();
XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
if (xmlMapData != null && outConnections != null && outConnections.size() > 0) {
List<OutputXmlTree> outputTables = xmlMapData.getOutputTrees();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : outConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (OutputXmlTree outputTable : outputTables) {
String tableName = outputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
List<TreeNode> editableNodes = new ArrayList<TreeNode>();
for (TreeNode node : outputTable.getNodes()) {
getEditableNodes(node, editableNodes);
}
for (TreeNode node : editableNodes) {
if (((OutputTreeNode) node).isAggregate()) {
hasAggregateColumn = true;
break;
}
}
}
}
return hasAggregateColumn;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class XMLMapperHelper method hasMultiLoops.
private static boolean hasMultiLoops(final INode xmlMapperNode) {
boolean hasMultiLoops = false;
List<? extends IConnection> outConnections = (List<? extends IConnection>) xmlMapperNode.getOutgoingConnections();
XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
if (xmlMapData != null && outConnections != null && outConnections.size() > 0) {
List<OutputXmlTree> outputTables = xmlMapData.getOutputTrees();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : outConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (OutputXmlTree outputTable : outputTables) {
String tableName = outputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
if (outputTable.isMultiLoops()) {
hasMultiLoops = true;
break;
}
}
}
return hasMultiLoops;
}
Aggregations