Search in sources :

Example 86 with IConnection

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;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) ElementParameter(org.talend.designer.core.model.components.ElementParameter) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 87 with IConnection

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;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 88 with IConnection

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();
}
Also used : DbMapComponent(org.talend.designer.dbmap.DbMapComponent) ExternalDbMapData(org.talend.designer.dbmap.external.data.ExternalDbMapData) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry) Before(org.junit.Before)

Example 89 with IConnection

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 90 with IConnection

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;
}
Also used : HashMap(java.util.HashMap) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Aggregations

IConnection (org.talend.core.model.process.IConnection)149 ArrayList (java.util.ArrayList)79 INode (org.talend.core.model.process.INode)63 List (java.util.List)60 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)57 Node (org.talend.designer.core.ui.editor.nodes.Node)47 HashMap (java.util.HashMap)36 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)33 IElementParameter (org.talend.core.model.process.IElementParameter)31 Map (java.util.Map)25 Connection (org.talend.designer.core.ui.editor.connections.Connection)25 INodeConnector (org.talend.core.model.process.INodeConnector)24 Point (org.eclipse.swt.graphics.Point)13 Process (org.talend.designer.core.ui.editor.process.Process)13 IJobletProviderService (org.talend.core.ui.IJobletProviderService)12 HashSet (java.util.HashSet)11 MetadataTable (org.talend.core.model.metadata.MetadataTable)10 IProcess (org.talend.core.model.process.IProcess)10 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)9 IExternalNode (org.talend.core.model.process.IExternalNode)8