Search in sources :

Example 6 with TableEntryLocation

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

the class TableEntriesManager method renameEntryName.

/**
     * DOC amaumont Comment method "renameEntryName".
     * 
     * @param dataMapTableEntry
     * @param newColumnName
     * @param newColumnName
     */
public void renameEntryName(ITableEntry dataMapTableEntry, String previousColumnName, String newColumnName) {
    // System.out.println(previousColumnName + " -> " + newColumnName);
    // ExceptionHandler.process(new RuntimeException("test : " + previousColumnName + " -> " + newColumnName));
    // log.info(previousColumnName + " -> " + newColumnName); //$NON-NLS-1$
    TableEntryLocation tableEntryLocationKey = new TableEntryLocation(dataMapTableEntry.getParentName(), previousColumnName);
    // TableEntriesManager.buildLocation(dataMapTableEntry);
    ITableEntry entry = tableEntries.get(tableEntryLocationKey);
    if (entry != dataMapTableEntry) {
        //$NON-NLS-1$
        log.warn(Messages.getString("TableEntriesManager.exceptionMessage.tableEntriesNotSame"));
        return;
    }
    tableEntries.remove(tableEntryLocationKey);
    tableEntryLocationKey.columnName = newColumnName;
    tableEntries.put(tableEntryLocationKey, dataMapTableEntry);
    dataMapTableEntry.setName(newColumnName);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation)

Example 7 with TableEntryLocation

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

the class DataMapExpressionParser method addRefArrayPointer.

public String addRefArrayPointer(String expression, TableEntryLocation[] locations) {
    String returnedExpression = expression;
    PerlLanguage perlLanguage = (PerlLanguage) language;
    for (TableEntryLocation location : locations) {
        recompilePatternIfNecessary(StringHelper.replacePrms(perlLanguage.getSubstPatternToAddRefArrayPointer(), new Object[] { location.tableName }));
        if (returnedExpression != null) {
            matcher.setMultiline(true);
            Perl5Substitution substitution = new Perl5Substitution(//$NON-NLS-1$
            language.getPrefixTableRegexp() + "$1->" + perlLanguage.getPrefixFieldRegexp() + "$2" + perlLanguage.getSuffixFieldRegexp(), //$NON-NLS-1$
            Perl5Substitution.INTERPOLATE_ALL);
            returnedExpression = substitute(matcher, pattern, substitution, returnedExpression, Util.SUBSTITUTE_ALL);
        }
    }
    return returnedExpression;
}
Also used : Perl5Substitution(org.apache.oro.text.regex.Perl5Substitution) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) PerlLanguage(org.talend.designer.mapper.language.perl.PerlLanguage)

Example 8 with TableEntryLocation

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

the class DataMapExpressionParser method addTablePrefixToColumnName.

public String addTablePrefixToColumnName(String uniqueNameComponent, String expression, TableEntryLocation[] locations, boolean prefixTableNameWithComponentName, HashSet<TableEntryLocation> validColumnEntryLocations) {
    String returnedExpression = expression;
    for (TableEntryLocation location : locations) {
        recompilePatternIfNecessary(StringHelper.replacePrms(language.getSubstPatternForPrefixColumnName(), new Object[] { Perl5Compiler.quotemeta(location.tableName), Perl5Compiler.quotemeta(location.columnName) }));
        if (returnedExpression != null) {
            matcher.setMultiline(true);
            Perl5Substitution substitution = new Perl5Substitution(language.getPrefixTableRegexp() + (prefixTableNameWithComponentName ? uniqueNameComponent + "__" : "") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            "$1->" + language.getPrefixFieldRegexp() + //$NON-NLS-1$ //$NON-NLS-2$
            (validColumnEntryLocations.contains(location) ? uniqueNameComponent + "__$1__" : "") + "$2" + language.getSuffixFieldRegexp(), //$NON-NLS-1$
            Perl5Substitution.INTERPOLATE_ALL);
            returnedExpression = substitute(matcher, pattern, substitution, returnedExpression, Util.SUBSTITUTE_ALL);
        }
    }
    return returnedExpression;
}
Also used : Perl5Substitution(org.apache.oro.text.regex.Perl5Substitution) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation)

Example 9 with TableEntryLocation

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

the class DataMapExpressionParser method parseTableEntryLocations.

public TableEntryLocation[] parseTableEntryLocations(String expression) {
    resultList.clear();
    if (expression != null) {
        matcher.setMultiline(true);
        if (patternMatcherInput == null) {
            patternMatcherInput = new PatternMatcherInput(expression);
        } else {
            patternMatcherInput.setInput(expression);
        }
        recompilePatternIfNecessary(locationPattern);
        while (matcher.contains(patternMatcherInput, pattern)) {
            MatchResult matchResult = matcher.getMatch();
            resultList.add(new TableEntryLocation(matchResult.group(1), matchResult.group(2)));
        }
    }
    return resultList.toArray(new TableEntryLocation[0]);
}
Also used : PatternMatcherInput(org.apache.oro.text.regex.PatternMatcherInput) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) MatchResult(org.apache.oro.text.regex.MatchResult)

Example 10 with TableEntryLocation

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

the class ExpressionProposalProvider method getProposals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
     */
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    TableEntryLocation sourceEntryLocation = new TableEntryLocation();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            sourceEntryLocation.tableName = entrySource.getParentName();
            sourceEntryLocation.columnName = entrySource.getName();
            if (mapperManager.getUiManager().checkSourceLocationIsValid(entrySource, currentModifiedEntry)) {
                proposals.add(new EntryContentProposal(entrySource, this.currentLanguage));
            }
        }
        // for the globalMap
        if (table instanceof InputTable) {
            InputTable inputTable = (InputTable) table;
            List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
            for (GlobalMapEntry entry : globalMapEntries) {
                proposals.add(new EntryContentProposal(entry, this.currentLanguage));
            }
        }
    }
    for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
        proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
    }
    IContentProposal[] res = new IContentProposal[proposals.size()];
    res = proposals.toArray(res);
    return res;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) InputTable(org.talend.designer.mapper.model.table.InputTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Aggregations

TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)33 Test (org.junit.Test)14 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)7 ArrayList (java.util.ArrayList)6 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)6 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)5 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)5 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)5 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)5 HashSet (java.util.HashSet)4 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)3 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)3 DataMapExpressionParser (org.talend.designer.mapper.utils.DataMapExpressionParser)3 HashMap (java.util.HashMap)2 Perl5Substitution (org.apache.oro.text.regex.Perl5Substitution)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Point (org.eclipse.swt.graphics.Point)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2