Search in sources :

Example 1 with OutputColumnTableEntry

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

the class MapperManager method addNewColumnEntry.

/**
     * This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
     * want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
     * 
     * @param dataMapTableView
     * @param metadataColumn, can be null if added in VarsTable
     * @param index
     */
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    IColumnEntry dataMapTableEntry = null;
    if (dataMapTableView.getZone() == Zone.INPUTS) {
        dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
    } else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
        dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
    }
    tableEntriesManager.addTableEntry(dataMapTableEntry, index);
    return dataMapTableEntry;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Example 2 with OutputColumnTableEntry

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

the class LinkManager method unregisterLevelForRemovedLink.

/**
     * DOC amaumont Comment method "unregisterLevelForRemovedLink".
     * 
     * @param link
     * @param sourceGraphicalLinks
     */
protected void unregisterLevelForRemovedLink(IMapperLink link, Set<IMapperLink> sourceGraphicalLinks) {
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = link.getPointLinkDescriptor1().getTableEntry().getClass() == targetEntry.getClass();
    if (hasSameZone) {
        boolean isInput = targetEntry instanceof InputColumnTableEntry;
        boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInput) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isOutput) {
            leveledLinks = getOutputLinksForLevels();
        }
        boolean breakAll = false;
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                int lstSizeInternal = linksFromLevelsList.size();
                for (int i = 0; i < lstSizeInternal; i++) {
                    IMapperLink currentLink = linksFromLevelsList.get(i);
                    if (currentLink == link) {
                        linksFromLevelsList.remove(i);
                        if (linksFromLevelsList.size() == 0) {
                            leveledLinks.set(indexOfLeveledLink, null);
                        }
                        breakAll = true;
                        break;
                    }
                }
                // for (int i = 0; i < lstSizeInternal; i++) {
                if (breakAll) {
                    break;
                }
            }
        }
    // for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) List(java.util.List) ArrayList(java.util.ArrayList) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Example 3 with OutputColumnTableEntry

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

the class ProblemsManager method checkProblemsForTableEntry.

public void checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData) {
    // if (forceRefreshData) {
    // mapperManager.getComponent().refreshMapperConnectorData();
    // checkProblems();
    // }
    List<Problem> problems = new ArrayList<Problem>(0);
    String expression = tableEntry.getExpression();
    if (tableEntry instanceof InputColumnTableEntry) {
        InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
        IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
        IDbOperator dbOperator = operatorsManager.getOperatorFromValue(inputEntry.getOperator());
        boolean operatorIsSet = dbOperator != null;
        boolean expressionIsSet = expression != null && expression.trim().length() > 0;
        Problem problem = null;
        String errorMessage = null;
        String key = null;
        if (!operatorIsSet && expressionIsSet) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.operatorNotSet", new Object[] { inputEntry.getName() });
            key = KEY_OPERATOR_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        if (operatorIsSet && !expressionIsSet && !dbOperator.isMonoOperand()) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.inputExpressionEmpty", new Object[] { inputEntry.getParentName(), inputEntry.getName() });
            key = KEY_INPUT_EXPRESSION_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        Problem warningProblem = null;
        if (inputEntry.isUnmatchingEntry()) {
            InputTable inputTable = (InputTable) inputEntry.getParent();
            String message = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.entryDoesntMatch", new Object[] { inputEntry.getParentName(), inputEntry.getName(), inputTable.getTableName() });
            warningProblem = new Problem(null, message, ProblemStatus.WARNING);
            warningProblem.setKey(KEY_NO_MATCHING);
            problems.add(warningProblem);
        }
    } else if (tableEntry instanceof OutputColumnTableEntry) {
        String errorMessage = null;
        Problem problem = null;
        if (expression == null || EMPTY_STRING.equals(expression.trim())) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.outputExpressionEmpty", new Object[] { tableEntry.getParentName(), tableEntry.getName() });
        }
        if (errorMessage != null) {
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(KEY_OUTPUT_EXPRESSION_EMPTY);
            problems.add(problem);
        }
    }
    tableEntry.setProblems(problems.size() > 0 ? problems : null);
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) IDbOperator(org.talend.designer.dbmap.language.operator.IDbOperator) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry) IDbOperatorManager(org.talend.designer.dbmap.language.operator.IDbOperatorManager)

Example 4 with OutputColumnTableEntry

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

the class OutputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        @Override
        public String get(OutputColumnTableEntry bean) {
            return bean.getExpression();
        }

        @Override
        public void set(OutputColumnTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
            tableViewerCreatorForColumns.getTableViewer().refresh(bean);
        }
    });
    column.setModifiable(true);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.OUTPUTS }, false);
    column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        @Override
        public String get(OutputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        @Override
        public void set(OutputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
}
Also used : OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 5 with OutputColumnTableEntry

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

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
protected void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
    boolean hasAlreadyInputTarget = false;
    boolean hasAlreadyVarTarget = false;
    ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = sourceEntry.getClass() == targetEntry.getClass();
    boolean isInput = targetEntry instanceof InputColumnTableEntry;
    boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
    if (hasSameZone) {
        List<List<IMapperLink>> leveledLinks = null;
        if (isInput) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isOutput) {
            leveledLinks = getOutputLinksForLevels();
        }
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
                ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
                ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
                if (targetEntry == targetTableEntry) {
                    if (sourceTableEntry instanceof InputColumnTableEntry && targetTableEntry instanceof InputColumnTableEntry) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInput && !hasAlreadyInputTarget) {
            ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
            int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
            link.setLevel(firstEmptyIndex + 1);
            list.add(link);
            if (firstEmptyIndex < leveledLinks.size()) {
                leveledLinks.set(firstEmptyIndex, list);
            } else {
                leveledLinks.add(list);
            }
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) List(java.util.List) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.dbmap.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Aggregations

OutputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry)5 InputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)2 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1 Problem (org.talend.core.model.process.Problem)1 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)1 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)1 IDbOperator (org.talend.designer.dbmap.language.operator.IDbOperator)1 IDbOperatorManager (org.talend.designer.dbmap.language.operator.IDbOperatorManager)1 InputTable (org.talend.designer.dbmap.model.table.InputTable)1 VarTableEntry (org.talend.designer.dbmap.model.tableentry.VarTableEntry)1