Search in sources :

Example 16 with FilterTableEntry

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

the class ProblemsManager method checkProblemsForTableEntry.

public boolean checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData, boolean checkLookupProblem) {
    if (!mapperManager.isCheckSyntaxEnabled()) {
        return false;
    }
    if (forceRefreshData) {
        mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
        checkProblems();
    }
    String expression = tableEntry.getExpression();
    List<Problem> problems = null;
    if (expression == null || EMPTY_STRING.equals(expression.trim())) {
        problems = null;
    } else {
        // System.out.println("check=" + expression);
        if (codeLanguage == ECodeLanguage.PERL) {
            problems = codeChecker.checkProblemsForExpression(expression);
        } else if (codeLanguage == ECodeLanguage.JAVA) {
            PROBLEM_KEY_FIELD problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN;
            String entryName = tableEntry.getName();
            if (tableEntry instanceof FilterTableEntry || tableEntry instanceof ExpressionFilterEntry) {
                problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.FILTER;
                entryName = null;
            }
            problems = checkJavaProblemsForEntry(problemKeyField, tableEntry.getParent().getName(), entryName, forceRefreshData);
        }
        if (problems != null) {
            for (Iterator iter = problems.iterator(); iter.hasNext(); ) {
                Problem problem = (Problem) iter.next();
                ProblemStatus status = problem.getStatus();
                if (status != ProblemStatus.ERROR) {
                    iter.remove();
                }
            }
        } else {
            problems = null;
        }
    }
    if (problems != null) {
        if (problems.size() == 0) {
            tableEntry.setProblems(null);
        } else {
            hasProblems = true;
            tableEntry.setProblems(problems);
        }
    } else {
        tableEntry.setProblems(problems);
    }
    // check problem for M/R process , only needed if modify lookup expressions
    if (checkLookupProblem) {
        checkLookupExpressionProblem();
    }
    // no need to update again
    TableViewerCreator tableViewerCreator = mapperManager.retrieveTableViewerCreator(tableEntry);
    DataMapTableView retrieveDataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
    mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreator);
    return problems != null;
}
Also used : ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) Iterator(java.util.Iterator) Problem(org.talend.core.model.process.Problem) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) PROBLEM_KEY_FIELD(org.talend.designer.mapper.language.generation.JavaGenerationManager.PROBLEM_KEY_FIELD)

Example 17 with FilterTableEntry

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

the class TableEntriesManager method addTableEntry.

/**
     * DOC amaumont Comment method "addTableEntry".
     * 
     * @param dataMapTableEntry
     * @param index
     */
public void addTableEntry(ITableEntry dataMapTableEntry, Integer index) {
    if (dataMapTableEntry == null) {
        throw new IllegalArgumentException(Messages.getString(//$NON-NLS-1$
        "TableEntriesManager.exceptionMessage.dataMapTableEntryCannotNull"));
    }
    add(dataMapTableEntry);
    IDataMapTable dataMapTable = dataMapTableEntry.getParent();
    if (dataMapTableEntry instanceof IColumnEntry) {
        if (index == null) {
            dataMapTable.addColumnEntry((IColumnEntry) dataMapTableEntry);
        } else {
            dataMapTable.addColumnEntry((IColumnEntry) dataMapTableEntry, index);
        }
    } else if (dataMapTableEntry instanceof FilterTableEntry) {
        if (index == null) {
            ((OutputTable) dataMapTable).addFilterEntry((FilterTableEntry) dataMapTableEntry);
        } else {
            ((OutputTable) dataMapTable).addFilterEntry((FilterTableEntry) dataMapTableEntry, index);
        }
    } else if (dataMapTableEntry instanceof GlobalMapEntry) {
        if (index == null) {
            ((InputTable) dataMapTable).addGlobalMapEntry((GlobalMapEntry) dataMapTableEntry);
        } else {
            ((InputTable) dataMapTable).addGlobalMapEntry((GlobalMapEntry) dataMapTableEntry, index);
        }
    } else {
        String exceptionMessage = Messages.getString("TableEntriesManager.exceptionMessage.typeIsNotValid", //$NON-NLS-1$
        dataMapTableEntry.getClass().toString());
        throw new IllegalArgumentException(exceptionMessage);
    }
// TableEntriesManagerEvent event = new TableEntriesManagerEvent(EVENT_TYPE.ADD);
// event.entry = dataMapTableEntry;
// fireEvent(event);
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Aggregations

FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)17 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)7 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)7 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 TableItem (org.eclipse.swt.widgets.TableItem)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 ArrayList (java.util.ArrayList)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Color (org.eclipse.swt.graphics.Color)2 Point (org.eclipse.swt.graphics.Point)2 Table (org.eclipse.swt.widgets.Table)2 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)2 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1