Search in sources :

Example 6 with IOConnection

use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.

the class ExternalDataConverter method prepareOutputTables.

private ArrayList<OutputTable> prepareOutputTables(List<IOConnection> outputConnections, List<IMetadataTable> outputMetadataTables, ExternalMapperData externalData) {
    Map<String, List<ExternalMapperTable>> nameToOutpuPersistentTable = new HashMap<String, List<ExternalMapperTable>>();
    if (externalData != null) {
        for (ExternalMapperTable persistentTable : externalData.getOutputTables()) {
            String key = persistentTable.getName();
            if (persistentTable.getIsJoinTableOf() != null) {
                key = persistentTable.getIsJoinTableOf();
            }
            List<ExternalMapperTable> list = nameToOutpuPersistentTable.get(key);
            if (list != null) {
                list.add(persistentTable);
            } else {
                list = new ArrayList<ExternalMapperTable>();
                list.add(persistentTable);
                nameToOutpuPersistentTable.put(key, list);
            }
        }
    }
    Map<String, IOConnection> nameMetadataToOutpuConn = new HashMap<String, IOConnection>();
    if (outputConnections != null) {
        for (IOConnection connection : outputConnections) {
            if (connection.getConnectionType().equals(EConnectionType.FLOW_MAIN) || connection.getConnectionType().equals(EConnectionType.FLOW_REF) || connection.getConnectionType().equals(EConnectionType.FLOW_MERGE)) {
                nameMetadataToOutpuConn.put(connection.getTable().getTableName(), connection);
            }
        }
    }
    ArrayList<OutputTable> outputDataMapTables = new ArrayList<OutputTable>();
    for (IMetadataTable table : outputMetadataTables) {
        IOConnection connection = nameMetadataToOutpuConn.get(table.getTableName());
        if (connection != null) {
            List<ExternalMapperTable> persistentTables = nameToOutpuPersistentTable.get(connection.getName());
            creatOutputTables(outputDataMapTables, persistentTables, connection.getTable(), connection, connection.getName());
        } else {
            List<ExternalMapperTable> persistentTables = nameToOutpuPersistentTable.get(table.getTableName());
            creatOutputTables(outputDataMapTables, persistentTables, table, null, table.getTableName());
        }
    }
    return outputDataMapTables;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with IOConnection

use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.

the class MapperMain method createModelFromExternalData.

public void createModelFromExternalData(IODataComponentContainer ioDataContainer, List<IMetadataTable> outputMetadataTables, ExternalMapperData externalData, boolean checkProblems) {
    List<IODataComponent> inputsData = ioDataContainer.getInputs();
    List<IODataComponent> ouputsData = ioDataContainer.getOuputs();
    ArrayList<IOConnection> inputs = new ArrayList<IOConnection>(inputsData.size());
    for (IODataComponent iData : inputsData) {
        inputs.add(new IOConnection(iData));
    }
    ArrayList<IOConnection> outputs = new ArrayList<IOConnection>(ouputsData.size());
    for (IODataComponent oData : ouputsData) {
        outputs.add(new IOConnection(oData));
    }
    createModelFromExternalData(inputs, outputs, outputMetadataTables, externalData, false);
}
Also used : IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 8 with IOConnection

use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.

the class OutputTable method hasReadOnlyMetadataColumns.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.mapper.model.table.AbstractInOutTable#hasReadOnlyMetadataColumns()
     */
@Override
public boolean hasReadOnlyMetadataColumns() {
    boolean hasReadOnlyMetadataColumns = false;
    IOConnection connection = getConnection();
    if (connection != null) {
        INode target = connection.getTarget();
        if (target != null) {
            hasReadOnlyMetadataColumns = connection.isReadOnly() || target.isReadOnly() || connection.getTable().isReadOnly();
            if (!hasReadOnlyMetadataColumns) {
                for (IElementParameter param : target.getElementParameters()) {
                    if (param.getFieldType() == EParameterFieldType.SCHEMA_TYPE) {
                        if (param.isReadOnly()) {
                            hasReadOnlyMetadataColumns = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    return hasReadOnlyMetadataColumns;
}
Also used : INode(org.talend.core.model.process.INode) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) IElementParameter(org.talend.core.model.process.IElementParameter)

Aggregations

IOConnection (org.talend.designer.mapper.external.connection.IOConnection)8 ArrayList (java.util.ArrayList)5 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)3 InputTable (org.talend.designer.mapper.model.table.InputTable)3 HashMap (java.util.HashMap)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 INode (org.talend.core.model.process.INode)2 MapperComponent (org.talend.designer.mapper.MapperComponent)2 MapperMain (org.talend.designer.mapper.MapperMain)2 ExternalDataConverter (org.talend.designer.mapper.external.converter.ExternalDataConverter)2 OutputTable (org.talend.designer.mapper.model.table.OutputTable)2 List (java.util.List)1 Test (org.junit.Test)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1 ICodeProblemsChecker (org.talend.core.language.ICodeProblemsChecker)1 IODataComponent (org.talend.core.model.components.IODataComponent)1 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 Problem (org.talend.core.model.process.Problem)1 TraceData (org.talend.core.model.process.TraceData)1