Search in sources :

Example 11 with ExpressionFilterEntry

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

the class AbstractInOutTable method initFromExternalData.

@Override
protected void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    expressionFilterEntry = new ExpressionFilterEntry(this);
    tableMapSettingEntriesModel = new ExtendedTableModel<GlobalMapEntry>("Model for map setting", mapSettingEntries);
    if (externalMapperTable != null) {
        this.expressionFilterEntry.setExpression(externalMapperTable.getExpressionFilter());
        this.activateExpressionFilter = externalMapperTable.isActivateExpressionFilter();
        this.activateCondensedTool = externalMapperTable.isActivateCondensedTool();
        this.activateColumnNameFilter = externalMapperTable.isActivateColumnNameFilter();
        this.id = externalMapperTable.getId();
        this.isRepository = this.id == null ? false : true;
    }
    List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
    Map<String, ExternalMapperTableEntry> nameToPerTabEntry = new HashMap<String, ExternalMapperTableEntry>();
    if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
        for (ExternalMapperTableEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
            nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
        }
    }
    String originalTableName = null;
    if (metadataTable != null) {
        originalTableName = metadataTable.getTableName();
    }
    if (isRepository) {
        IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(id);
        if (table == null) {
            this.id = null;
            this.isRepository = false;
        } else {
            this.metadataTable = table;
            this.metadataTable.setTableName(originalTableName);
        }
    }
    if (metadataTable != null) {
        columns = this.metadataTable.getListColumns();
    }
    updateTableEntries(columns, nameToPerTabEntry);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HashMap(java.util.HashMap) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 12 with ExpressionFilterEntry

use of org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry 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)

Aggregations

ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)12 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)7 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)6 InputTable (org.talend.designer.mapper.model.table.InputTable)4 ArrayList (java.util.ArrayList)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)3 OutputTable (org.talend.designer.mapper.model.table.OutputTable)3 HashMap (java.util.HashMap)2 List (java.util.List)2 TableItem (org.eclipse.swt.widgets.TableItem)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)2 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)2 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)2