Search in sources :

Example 1 with VarTableEntry

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

the class EntryContentProposal method getDescription.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposal#getDescription()
     */
public String getDescription() {
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    String separator = " - ";
    if (entry instanceof InputColumnTableEntry) {
        InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
        IMetadataColumn metadataColumn = inputEntry.getMetadataColumn();
        //$NON-NLS-1$ //$NON-NLS-2$
        sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(metadataColumn.getLabel()).append(//$NON-NLS-1$
        "' ");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
        if (!MapperMain.isStandAloneMode()) {
            sb.append(AbstractLanguage.CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
            format(metadataColumn.getTalendType()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
        if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
            sb.append(format(metadataColumn.getLength()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
        if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
            sb.append(format(metadataColumn.getPrecision()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
        format(metadataColumn.getDefault()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
        format(metadataColumn.getComment()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
    } else if (entry instanceof VarTableEntry) {
        //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
    } else if (entry instanceof GlobalMapEntry) {
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append("GlobalMap ");
        //$NON-NLS-1$ 
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.globalMapKey")).append("' :");
        sb.append(entry.getName());
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.Expr")).append("' :");
        sb.append(entry.getExpression());
    }
    return sb.toString();
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 2 with VarTableEntry

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

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

the class VarsTable method initFromExternalData.

public void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        List<ExternalMapperTableEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
        if (metadataTableEntries != null) {
            for (ExternalMapperTableEntry externalMapperTableEntry : metadataTableEntries) {
                VarTableEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getType());
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
                if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                    varTableEntry.setNullable(externalMapperTableEntry.isNullable());
                }
                addColumnEntry(varTableEntry);
            }
        }
    } else {
        setMinimized(true);
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry)

Example 4 with VarTableEntry

use of org.talend.designer.mapper.model.tableentry.VarTableEntry 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 5 with VarTableEntry

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

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
public 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.getParent().getClass() == targetEntry.getParent().getClass();
    if (hasSameZone) {
        boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
        boolean isVarTarget = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInputTarget) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVarTarget) {
            leveledLinks = getVarLinksForLevels();
        }
        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 || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
            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) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputTable(org.talend.designer.mapper.model.table.InputTable) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Aggregations

VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)2 InputTable (org.talend.designer.mapper.model.table.InputTable)2 VarsTable (org.talend.designer.mapper.model.table.VarsTable)2 AbstractInOutTableEntry (org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)2 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)1 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 ModifiedObjectInfo (org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo)1 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)1 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1