Search in sources :

Example 1 with AbstractInOutTableEntry

use of org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.

the class MapperManager method retrieveTableViewerCreator.

public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
    DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
    TableViewerCreator tableViewerCreator = null;
    if (view != null) {
        if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForColumns();
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForFilters();
        }
    }
    return tableViewerCreator;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 2 with AbstractInOutTableEntry

use of org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.

the class ExpressionProposalProvider method getVariables.

public List<Variable> getVariables() {
    List<Variable> variables = new ArrayList<Variable>();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            String variable = null;
            if (table instanceof VarsTable) {
                variable = entrySource.getExpression();
            } else {
                variable = LanguageProvider.getCurrentLanguage().getLocation(entrySource.getParentName(), entrySource.getName());
            }
            String talendType = null;
            boolean nullable = true;
            if (entrySource instanceof AbstractInOutTableEntry) {
                talendType = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().getTalendType();
                nullable = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().isNullable();
            } else if (entrySource instanceof VarTableEntry) {
                talendType = ((VarTableEntry) entrySource).getType();
                nullable = ((VarTableEntry) entrySource).isNullable();
            }
            if (talendType != null) {
                if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                    boolean exist = false;
                    for (Variable v : variables) {
                        if (variable != null && v.getName() != null && v.getName().trim().equals(variable.trim())) {
                            exist = true;
                            break;
                        }
                    }
                    if (!exist) {
                        variables.add(new Variable(variable, JavaTypesManager.getDefaultValueFromJavaIdType(talendType, nullable).toString(), talendType, nullable));
                    }
                } else {
                    //$NON-NLS-1$
                    variables.add(new Variable(variable, "", talendType, nullable));
                }
            }
        }
    }
    return variables;
}
Also used : VarsTable(org.talend.designer.mapper.model.table.VarsTable) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 3 with AbstractInOutTableEntry

use of org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(Collection<? extends AbstractDataMapTable> tables) {
    for (IDataMapTable table : tables) {
        ExternalMapperTable externalMapperTable = new ExternalMapperTable();
        fillExternalTable(table, externalMapperTable);
        ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
        boolean isVarTable = table instanceof VarsTable;
        boolean isInputTable = table instanceof InputTable;
        for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            if (isVarTable) {
                externalMapperTableEntry.setType(((VarTableEntry) dataMapTableEntry).getType());
                externalMapperTableEntry.setNullable(((VarTableEntry) dataMapTableEntry).isNullable());
            } else {
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            }
            if (isInputTable) {
                externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
            }
            perTableEntries.add(externalMapperTableEntry);
        }
        externalMapperTable.setMetadataTableEntries(perTableEntries);
    }
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 4 with AbstractInOutTableEntry

use of org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
    // for (int i = 0; i < tables.size(); i++) {
    if (tables.size() <= 0 || intables.size() <= 0) {
        return;
    }
    IDataMapTable outtable = tables.get(0);
    IDataMapTable intable = intables.get(0);
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    fillExternalTable(outtable, externalMapperTable);
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    List<IMetadataColumn> columnList = null;
    if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
        List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
        if (connList != null && connList.size() >= 1) {
            List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
            if (metaList != null && metaList.size() >= 1) {
                columnList = metaList.get(0).getListColumns();
            }
        }
    }
    for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
        if (columnList != null) {
            boolean find = false;
            for (IMetadataColumn column : columnList) {
                if (dataMapTableEntry.getName().equals(column.getLabel())) {
                    find = true;
                    break;
                }
            }
            if (find) {
                ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
                externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
                externalMapperTableEntry.setName(dataMapTableEntry.getName());
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
                perTableEntries.add(externalMapperTableEntry);
            }
        } else {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
            externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            perTableEntries.add(externalMapperTableEntry);
        }
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 5 with AbstractInOutTableEntry

use of org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.

the class AbstractInOutTable method updateTableEntries.

private void updateTableEntries(List<IMetadataColumn> columns, Map<String, ExternalMapperTableEntry> nameToPerTabEntry) {
    for (IMetadataColumn column : columns) {
        AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
        ExternalMapperTableEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
        if (externalMapperTableEntry != null) {
            columnEntry.setExpression(externalMapperTableEntry.getExpression());
            if (columnEntry instanceof InputColumnTableEntry) {
                InputColumnTableEntry entry = (InputColumnTableEntry) columnEntry;
                entry.setOperator(externalMapperTableEntry.getOperator());
            }
        // mapperManager.getProblemsManager().checkProblemsForTableEntry(columnEntry, false);
        }
        dataMapTableEntries.add(columnEntry);
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

AbstractInOutTableEntry (org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)5 ArrayList (java.util.ArrayList)3 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)3 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)3 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)2 VarsTable (org.talend.designer.mapper.model.table.VarsTable)2 VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)2 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)1 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)1 InputTable (org.talend.designer.mapper.model.table.InputTable)1 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)1 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)1 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)1