Search in sources :

Example 1 with VarTableEntry

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

the class VarsTable method initFromExternalData.

public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        List<ExternalDbMapEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
        if (metadataTableEntries != null) {
            for (ExternalDbMapEntry externalMapperTableEntry : metadataTableEntries) {
                IColumnEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getOperator());
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
                addColumnEntry(varTableEntry);
            }
        }
    } else {
        setMinimized(true);
    }
}
Also used : VarTableEntry(org.talend.designer.dbmap.model.tableentry.VarTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Example 2 with VarTableEntry

use of org.talend.designer.dbmap.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(DbLanguageConstants.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
        if (!MapperMain.isStandAloneMode()) {
            sb.append(DbLanguageConstants.CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
            format(metadataColumn.getTalendType()));
        }
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.dbType")).append(//$NON-NLS-1$
        format(metadataColumn.getType()));
        sb.append(DbLanguageConstants.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(DbLanguageConstants.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(DbLanguageConstants.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
        format(metadataColumn.getDefault()));
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
        format(metadataColumn.getComment()));
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
        sb.append(DbLanguageConstants.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(DbLanguageConstants.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(DbLanguageConstants.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
    }
    return sb.toString();
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) VarTableEntry(org.talend.designer.dbmap.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Example 3 with VarTableEntry

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

VarTableEntry (org.talend.designer.dbmap.model.tableentry.VarTableEntry)3 InputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)1 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)1 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)1 ExternalDbMapEntry (org.talend.designer.dbmap.external.data.ExternalDbMapEntry)1 OutputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry)1