Search in sources :

Example 6 with InputTable

use of org.talend.designer.dbmap.model.emf.dbmap.InputTable in project tdi-studio-se by Talend.

the class DBMapDataImplTest method test4.

private void test4() {
    DBMapDataImpl mapData1 = new DBMapDataImpl();
    DBMapDataImpl mapData2 = new DBMapDataImpl();
    assertTrue(mapData1.equals(mapData2));
    final OutputTable persistentTable = DbmapFactory.eINSTANCE.createOutputTable();
    persistentTable.setMinimized(true);
    persistentTable.setName("table1");
    persistentTable.setTableName("tableName");
    final DBMapperTableEntry emfMapperTableEntry = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    emfMapperTableEntry.setExpression("expression1");
    emfMapperTableEntry.setName("entityName1");
    emfMapperTableEntry.setJoin(true);
    emfMapperTableEntry.setOperator("operator1");
    persistentTable.getDBMapperTableEntries().add(emfMapperTableEntry);
    mapData1.getOutputTables().add(persistentTable);
    final InputTable persistentTable2 = DbmapFactory.eINSTANCE.createInputTable();
    persistentTable2.setMinimized(true);
    persistentTable2.setName("table1");
    persistentTable2.setTableName("tableName");
    final DBMapperTableEntry emfMapperTableEntry2 = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    emfMapperTableEntry2.setExpression("expression1");
    emfMapperTableEntry2.setName("entityName");
    emfMapperTableEntry2.setJoin(true);
    emfMapperTableEntry2.setOperator("operator1");
    persistentTable2.getDBMapperTableEntries().add(emfMapperTableEntry2);
    mapData2.getOutputTables().add(persistentTable);
    assertFalse(mapData1.equals(mapData2));
}
Also used : InputTable(org.talend.designer.dbmap.model.emf.dbmap.InputTable) OutputTable(org.talend.designer.dbmap.model.emf.dbmap.OutputTable) DBMapperTableEntry(org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry)

Example 7 with InputTable

use of org.talend.designer.dbmap.model.emf.dbmap.InputTable in project tdi-studio-se by Talend.

the class DBMapDataImplTest method test1.

private void test1() {
    DBMapDataImpl mapData1 = new DBMapDataImpl();
    DBMapDataImpl mapData2 = new DBMapDataImpl();
    assertTrue(mapData1.equals(mapData2));
    final InputTable persistentTable = DbmapFactory.eINSTANCE.createInputTable();
    persistentTable.setMinimized(true);
    persistentTable.setName("table1");
    persistentTable.setAlias("alias1");
    persistentTable.setJoinType("type1");
    persistentTable.setTableName("tableName");
    final DBMapperTableEntry emfMapperTableEntry = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    emfMapperTableEntry.setExpression("expression1");
    emfMapperTableEntry.setName("entityName1");
    emfMapperTableEntry.setJoin(true);
    emfMapperTableEntry.setOperator("operator1");
    persistentTable.getDBMapperTableEntries().add(emfMapperTableEntry);
    mapData1.getInputTables().add(persistentTable);
    final InputTable persistentTable2 = DbmapFactory.eINSTANCE.createInputTable();
    persistentTable2.setMinimized(true);
    persistentTable2.setName("table1");
    persistentTable2.setAlias("alias1");
    persistentTable2.setJoinType("type1");
    persistentTable2.setTableName("tableName");
    final DBMapperTableEntry emfMapperTableEntry2 = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    emfMapperTableEntry2.setExpression("expression1");
    emfMapperTableEntry2.setName("entityName1");
    emfMapperTableEntry2.setJoin(true);
    emfMapperTableEntry2.setOperator("operator1");
    persistentTable2.getDBMapperTableEntries().add(emfMapperTableEntry2);
    mapData2.getInputTables().add(persistentTable2);
    assertTrue(mapData1.equals(mapData2));
}
Also used : InputTable(org.talend.designer.dbmap.model.emf.dbmap.InputTable) DBMapperTableEntry(org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry)

Example 8 with InputTable

use of org.talend.designer.dbmap.model.emf.dbmap.InputTable in project tdi-studio-se by Talend.

the class DbMapServiceTest method setUp.

@Before
public void setUp() throws Exception {
    nodeType = TalendFileFactory.eINSTANCE.createNodeType();
    DBMapData data = DbmapFactory.eINSTANCE.createDBMapData();
    nodeType.setNodeData(data);
    InputTable input = DbmapFactory.eINSTANCE.createInputTable();
    input.setName(oldValue);
    input.setTableName(oldValue);
    DBMapperTableEntry inputEntry = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    inputEntry.setName("column");
    data.getInputTables().add(input);
    input.getDBMapperTableEntries().add(inputEntry);
    OutputTable out = DbmapFactory.eINSTANCE.createOutputTable();
    out.setName("output");
    out.setTableName("output");
    DBMapperTableEntry outEntry = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
    outEntry.setName("column");
    outEntry.setExpression(oldValue + ".column");
    out.getDBMapperTableEntries().add(outEntry);
    data.getOutputTables().add(out);
}
Also used : InputTable(org.talend.designer.dbmap.model.emf.dbmap.InputTable) DBMapData(org.talend.designer.dbmap.model.emf.dbmap.DBMapData) DBMapperTableEntry(org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry) OutputTable(org.talend.designer.dbmap.model.emf.dbmap.OutputTable) Before(org.junit.Before)

Example 9 with InputTable

use of org.talend.designer.dbmap.model.emf.dbmap.InputTable in project tdi-studio-se by Talend.

the class DbMapService method updateEMFDBMapData.

@Override
public void updateEMFDBMapData(NodeType nodeType, String oldValue, String newValue) {
    AbstractExternalData nodeData = nodeType.getNodeData();
    if (nodeData instanceof DBMapData) {
        DBMapData dbMapData = (DBMapData) nodeData;
        for (InputTable input : dbMapData.getInputTables()) {
            if (input.getName().equals(oldValue) || input.getTableName().equals(oldValue)) {
                input.setName(newValue);
                input.setTableName(newValue);
            }
        }
        for (OutputTable output : dbMapData.getOutputTables()) {
            List<DBMapperTableEntry> entries = output.getDBMapperTableEntries();
            for (DBMapperTableEntry entry : entries) {
                String expression = entry.getExpression();
                if (expression != null && !"".equals(expression.trim())) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    int index = expression.lastIndexOf(".");
                    // at least "a.b"
                    if (index > 0) {
                        String connectionName = expression.substring(0, index);
                        if (oldValue.equals(connectionName)) {
                            entry.setExpression(newValue + expression.substring(index, expression.length()));
                        }
                    }
                }
            }
        }
    }
}
Also used : AbstractExternalData(org.talend.designer.core.model.utils.emf.talendfile.AbstractExternalData) InputTable(org.talend.designer.dbmap.model.emf.dbmap.InputTable) DBMapData(org.talend.designer.dbmap.model.emf.dbmap.DBMapData) OutputTable(org.talend.designer.dbmap.model.emf.dbmap.OutputTable) DBMapperTableEntry(org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry)

Example 10 with InputTable

use of org.talend.designer.dbmap.model.emf.dbmap.InputTable in project tdi-studio-se by Talend.

the class DbMapServiceTest method testUpdateEMFDBMapData.

@Test
public void testUpdateEMFDBMapData() {
    DbMapService service = new DbMapService();
    service.updateEMFDBMapData(nodeType, oldValue, newValue);
    DBMapData data = (DBMapData) nodeType.getNodeData();
    InputTable input = data.getInputTables().get(0);
    assertEquals("context.schema.context.table", input.getName());
    assertEquals("context.schema.context.table", input.getTableName());
    OutputTable out = data.getOutputTables().get(0);
    // output connection name should not be updated.
    assertEquals("output", out.getName());
    DBMapperTableEntry outEntry = out.getDBMapperTableEntries().get(0);
    assertEquals("context.schema.context.table.column", outEntry.getExpression());
}
Also used : InputTable(org.talend.designer.dbmap.model.emf.dbmap.InputTable) DBMapData(org.talend.designer.dbmap.model.emf.dbmap.DBMapData) OutputTable(org.talend.designer.dbmap.model.emf.dbmap.OutputTable) DBMapperTableEntry(org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry) Test(org.junit.Test)

Aggregations

InputTable (org.talend.designer.dbmap.model.emf.dbmap.InputTable)10 DBMapperTableEntry (org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry)8 OutputTable (org.talend.designer.dbmap.model.emf.dbmap.OutputTable)7 DBMapData (org.talend.designer.dbmap.model.emf.dbmap.DBMapData)5 ArrayList (java.util.ArrayList)2 ExternalDbMapEntry (org.talend.designer.dbmap.external.data.ExternalDbMapEntry)2 ExternalDbMapTable (org.talend.designer.dbmap.external.data.ExternalDbMapTable)2 FilterEntry (org.talend.designer.dbmap.model.emf.dbmap.FilterEntry)2 Before (org.junit.Before)1 Test (org.junit.Test)1 IODataComponentContainer (org.talend.core.model.components.IODataComponentContainer)1 IConnection (org.talend.core.model.process.IConnection)1 AbstractExternalData (org.talend.designer.core.model.utils.emf.talendfile.AbstractExternalData)1 Connection (org.talend.designer.core.ui.editor.connections.Connection)1 ExternalDbMapData (org.talend.designer.dbmap.external.data.ExternalDbMapData)1 VarTable (org.talend.designer.dbmap.model.emf.dbmap.VarTable)1