Search in sources :

Example 16 with InputTable

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

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(Collection<? extends IDataMapTable> tables) {
    for (IDataMapTable table : tables) {
        ExternalDbMapTable externalMapperTable = new ExternalDbMapTable();
        fillExternalTable(table, externalMapperTable);
        ArrayList<ExternalDbMapEntry> perTableEntries = new ArrayList<ExternalDbMapEntry>();
        boolean isInputTable = table instanceof InputTable;
        for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
            ExternalDbMapEntry externalMapperTableEntry = new ExternalDbMapEntry();
            externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            if (isInputTable) {
                externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
                externalMapperTableEntry.setJoin(((InputColumnTableEntry) dataMapTableEntry).isJoin());
            }
            perTableEntries.add(externalMapperTableEntry);
        }
        externalMapperTable.setMetadataTableEntries(perTableEntries);
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Example 17 with InputTable

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

the class MapperMain method getMetadataListIn.

/**
     * DOC amaumont Comment method "getMetadataListIn".
     */
public List<IMetadataTable> getMetadataListIn() {
    List<InputTable> tables = mapperManager.getInputTables();
    List<IMetadataTable> metadataTables = new ArrayList<IMetadataTable>(tables.size());
    for (InputTable table : tables) {
        metadataTables.add(table.getMetadataTable());
    }
    return metadataTables;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) ArrayList(java.util.ArrayList)

Example 18 with InputTable

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

the class ExternalDataConverter method prepareInputTables.

public ArrayList<InputTable> prepareInputTables(List<IOConnection> inputConnections, ExternalDbMapData externalData) {
    // Map<String, ExternalMapperTable> nameToInputPersistentTable = new HashMap<String, ExternalMapperTable>();
    // if (externalData != null) {
    // for (ExternalMapperTable persistentTable : externalData.getInputTables()) {
    // nameToInputPersistentTable.put(persistentTable.getName(), persistentTable);
    // }
    // }
    Map<String, IOConnection> nameToConnection = new HashMap<String, IOConnection>();
    for (IOConnection connection : inputConnections) {
        nameToConnection.put(connection.getName(), connection);
    }
    ArrayList<InputTable> inputDataMapTables = new ArrayList<InputTable>();
    if (externalData == null) {
        for (IOConnection connection : inputConnections) {
            InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
            inputTable.initFromExternalData(null);
            inputDataMapTables.add(inputTable);
        }
    } else {
        ArrayList<IOConnection> remainingConnections = new ArrayList<IOConnection>(inputConnections);
        for (ExternalDbMapTable persistentTable : externalData.getInputTables()) {
            String name = persistentTable.getTableName() != null ? persistentTable.getTableName() : persistentTable.getName();
            IOConnection connection = nameToConnection.get(name);
            if (connection != null) {
                remainingConnections.remove(connection);
                InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
                inputTable.initFromExternalData(persistentTable);
                inputDataMapTables.add(inputTable);
            }
        }
    // if(externalData.getInputTables().size() > 0) {
    // for (IOConnection connection : remainingConnections) {
    // InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
    // inputTable.initFromExternalData(null);
    // inputDataMapTables.add(inputTable);
    // }
    // }
    }
    // sort for put table with main connection at top position of the list
    Collections.sort(inputDataMapTables, new Comparator<InputTable>() {

        @Override
        public int compare(InputTable o1, InputTable o2) {
            if (o1.isMainConnection()) {
                return -1;
            } else if (o2.isMainConnection()) {
                return 1;
            }
            return 0;
        }
    });
    return inputDataMapTables;
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) HashMap(java.util.HashMap) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) ArrayList(java.util.ArrayList)

Aggregations

InputTable (org.talend.designer.dbmap.model.table.InputTable)18 ArrayList (java.util.ArrayList)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)5 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)5 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)4 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)4 HashMap (java.util.HashMap)3 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)3 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridData (org.eclipse.swt.layout.GridData)2 Control (org.eclipse.swt.widgets.Control)2 TableItem (org.eclipse.swt.widgets.TableItem)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 Problem (org.talend.core.model.process.Problem)2 ExternalDbMapTable (org.talend.designer.dbmap.external.data.ExternalDbMapTable)2