Search in sources :

Example 21 with IColumnEntry

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

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems(ExternalDbMapData externalData) {
    problems.clear();
    if (externalData != null) {
        List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
        List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
        ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
        MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
        List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
        ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
        List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
        ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
        List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
        tablesWriteMode.addAll(inputTables);
        tablesWriteMode.addAll(outputTables);
        List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
        ProblemsManager problemsManager = new ProblemsManager(mapperManager);
        ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
        for (AbstractInOutTable table : tablesReadMode) {
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            problemsManager.checkProblemsForAllEntries(columnEntries);
            for (IColumnEntry entry : columnEntries) {
                List<Problem> problemsOfEntry = entry.getProblems();
                if (problemsOfEntry != null) {
                    problemsLocal.addAll(problemsOfEntry);
                }
            }
        }
        problems.addAll(problemsLocal);
    }
    return getProblems();
}
Also used : ExternalDataConverter(org.talend.designer.dbmap.external.converter.ExternalDataConverter) ArrayList(java.util.ArrayList) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IConnection(org.talend.core.model.process.IConnection) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList) List(java.util.List) Problem(org.talend.core.model.process.Problem) MapperMain(org.talend.designer.dbmap.MapperMain) ProblemsManager(org.talend.designer.dbmap.managers.ProblemsManager)

Example 22 with IColumnEntry

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

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
    if (searchValue.equals("")) {
        uiManager.unselectAllEntriesOfAllTables();
        return;
    }
    // SearchPattern
    matcher.setPattern("*" + searchValue.trim() + "*");
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    int index = -1;
    // for the InputTables
    for (InputTable inputTable : inputTables) {
        for (IColumnEntry column : inputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
    // for the OutputTables
    for (OutputTable outputTable : outputTables) {
        // OutputTable Filters
        for (FilterTableEntry entry : outputTable.getWhereFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        for (FilterTableEntry entry : outputTable.getOtherFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        // OutputTable Columns
        for (IColumnEntry column : outputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 23 with IColumnEntry

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

the class ExpressionProposalProvider method getProposals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
     */
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    TableEntryLocation sourceEntryLocation = new TableEntryLocation();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            sourceEntryLocation.tableName = entrySource.getParentName();
            sourceEntryLocation.columnName = entrySource.getName();
            if (mapperManager.getUiManager().checkSourceLocationIsValid(entrySource, currentModifiedEntry)) {
                proposals.add(new EntryContentProposal(entrySource, this.currentLanguage));
            }
        }
        // for the globalMap
        if (table instanceof InputTable) {
            InputTable inputTable = (InputTable) table;
            List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
            for (GlobalMapEntry entry : globalMapEntries) {
                proposals.add(new EntryContentProposal(entry, this.currentLanguage));
            }
        }
    }
    for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
        proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
    }
    IContentProposal[] res = new IContentProposal[proposals.size()];
    res = proposals.toArray(res);
    return res;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) InputTable(org.talend.designer.mapper.model.table.InputTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 24 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry 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 25 with IColumnEntry

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

the class AutoMapper method map.

/**
     * DOC amaumont Comment method "map".
     */
public void map() {
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    HashMap<String, InputTable> nameToInputTable = new HashMap<String, InputTable>(inputTables.size());
    for (InputTable inputTable : inputTables) {
        nameToInputTable.put(inputTable.getName(), inputTable);
    }
    // output tables are the references
    for (OutputTable outputTable : outputTables) {
        List<IColumnEntry> outputEntries = outputTable.getColumnEntries();
        boolean mapFound = false;
        for (IColumnEntry outputEntry : outputEntries) {
            mapFound = false;
            if (mapperManager.checkEntryHasEmptyExpression(outputEntry)) {
                String outputColumnName = outputEntry.getName();
                for (InputTable inputTable : inputTables) {
                    List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
                    for (IColumnEntry inputEntry : inputColumnEntries) {
                        if (inputEntry.getName().equalsIgnoreCase(outputColumnName)) {
                            outputEntry.setExpression(currentLanguage.getLocation(inputTable.getName(), inputEntry.getName()));
                            mapFound = true;
                            break;
                        }
                    }
                    if (mapFound) {
                        break;
                    }
                }
            }
        }
        DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(outputTable);
        view.getTableViewerCreatorForColumns().getTableViewer().refresh();
    }
    mapperManager.getProblemsManager().checkProblems();
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    for (DataMapTableView view : outputsTablesView) {
        mapperManager.getUiManager().parseAllExpressions(view, true);
        mapperManager.getProblemsManager().checkProblemsForAllEntries(view, true);
    }
    mapperManager.getUiManager().refreshBackground(true, false);
}
Also used : HashMap(java.util.HashMap) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) ILanguage(org.talend.designer.mapper.language.ILanguage)

Aggregations

IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)42 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)16 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)10 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)10 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 InputTable (org.talend.designer.mapper.model.table.InputTable)8 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)8 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 TableViewer (org.eclipse.jface.viewers.TableViewer)6 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)5 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4