Search in sources :

Example 81 with Connection

use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.

the class ConnectionManagerTest method testCanRename.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.ConnectionManager#canRename(org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.core.model.process.EConnectionType, java.lang.String)}
     * .
     */
@Test
public void testCanRename() {
    try {
        connection = new Connection(source, target, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test", "test", "test", false);
        boolean canRename = ConnectionManager.canRename(source, target, EConnectionType.FLOW_MAIN, "test1");
        assertTrue(canRename);
        canRename = ConnectionManager.canRename(source, target, EConnectionType.FLOW_MAIN, "test");
        assertTrue(canRename);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test CanConnectToSource() method failure.");
    }
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) Test(org.junit.Test)

Example 82 with Connection

use of org.talend.designer.core.ui.editor.connections.Connection 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 83 with Connection

use of org.talend.designer.core.ui.editor.connections.Connection 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 84 with Connection

use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.

the class ProblemsAnalyserTest method createMapperComponent.

private MapperComponent createMapperComponent() {
    IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    IComponent tMapComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_DI.getName());
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("test1");
    Process process = new Process(property1);
    Node tMysqlInput_1 = new Node(tMysqlComponent, process);
    IMetadataTable tMysqlInput_1_table = tMysqlInput_1.getMetadataTable("tMysqlInput_1");
    createMetadataColumns(tMysqlInput_1_table, 2);
    Node tMysqlInput_2 = new Node(tMysqlComponent, process);
    IMetadataTable tMysqlInput_2_table = tMysqlInput_2.getMetadataTable("tMysqlInput_2");
    createMetadataColumns(tMysqlInput_2_table, 2);
    Node tMap_1 = new Node(tMapComponent, process);
    Connection row1 = new Connection(tMysqlInput_1, tMap_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row1", "row1", false);
    Connection row2 = new Connection(tMysqlInput_2, tMap_1, EConnectionType.FLOW_REF, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row2", "row2", false);
    tMap_1.getExternalNode().initialize();
    MapperComponent mapperComponent = (MapperComponent) tMap_1.getExternalNode();
    ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
    ExternalMapperTable externalTable = prepareExternalData(tMysqlInput_1_table);
    externalTable.setName(row1.getName());
    externalData.getInputTables().add(externalTable);
    externalTable = prepareExternalData(tMysqlInput_2_table);
    externalTable.setName(row2.getName());
    externalData.getInputTables().add(externalTable);
    return mapperComponent;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) Property(org.talend.core.model.properties.Property) MapperComponent(org.talend.designer.mapper.MapperComponent)

Aggregations

Connection (org.talend.designer.core.ui.editor.connections.Connection)84 IConnection (org.talend.core.model.process.IConnection)52 ArrayList (java.util.ArrayList)47 List (java.util.List)46 Node (org.talend.designer.core.ui.editor.nodes.Node)44 INode (org.talend.core.model.process.INode)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)28 Process (org.talend.designer.core.ui.editor.process.Process)24 IElementParameter (org.talend.core.model.process.IElementParameter)20 INodeConnector (org.talend.core.model.process.INodeConnector)18 HashMap (java.util.HashMap)12 IComponent (org.talend.core.model.components.IComponent)12 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)12 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)10 Property (org.talend.core.model.properties.Property)10 Test (org.junit.Test)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 Map (java.util.Map)8