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);
}
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;
}
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;
}
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]);
}
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;
}
Aggregations