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 MapperManager method replaceLocation.
/**
*
* DOC amaumont Comment method "replaceLocation".
*
* @param previousLocation
* @param newLocation
* @param dataMapExpressionParser
* @param table
* @param entry
* @return true if expression of entry has changed
*/
private boolean replaceLocation(final TableEntryLocation previousLocation, final TableEntryLocation newLocation, DataMapExpressionParser dataMapExpressionParser, IDataMapTable table, ITableEntry entry) {
if (entry.getExpression() == null || entry.getExpression().trim().length() == 0) {
return false;
}
boolean expressionHasChanged = false;
String currentExpression = entry.getExpression();
TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(currentExpression);
// loop on all locations of current expression
for (TableEntryLocation currentLocation : tableEntryLocations) {
if (currentLocation.equals(previousLocation)) {
currentExpression = dataMapExpressionParser.replaceLocation(currentExpression, previousLocation, newLocation);
expressionHasChanged = true;
}
}
if (expressionHasChanged) {
entry.setExpression(currentExpression);
DataMapTableView dataMapTableView = retrieveAbstractDataMapTableView(table);
TableViewerCreator tableViewerCreator = null;
if (entry instanceof IColumnEntry || entry instanceof FilterTableEntry) {
if (entry instanceof IColumnEntry) {
tableViewerCreator = dataMapTableView.getTableViewerCreatorForColumns();
} else if (entry instanceof FilterTableEntry) {
tableViewerCreator = dataMapTableView.getTableViewerCreatorForFilters();
}
tableViewerCreator.getTableViewer().refresh(entry);
} else if (entry instanceof ExpressionFilterEntry) {
dataMapTableView.getExpressionFilterText().setText(currentExpression);
}
uiManager.parseExpression(currentExpression, entry, false, true, false);
return true;
}
return false;
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class ExternalMapperData method getLinkedTableColumnsMapping.
public Map<String, Set<String>> getLinkedTableColumnsMapping() {
Map<String, Set<String>> tableColumnsMapping = new HashMap<String, Set<String>>();
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
List<ExternalMapperTable> tablesHasFilter = new ArrayList<ExternalMapperTable>();
tablesHasFilter.addAll(inputTables);
tablesHasFilter.addAll(outputTables);
for (ExternalMapperTable table : tablesHasFilter) {
TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(table.getExpressionFilter());
for (TableEntryLocation tableEntryLocation : tableEntryLocations) {
if (!tableColumnsMapping.containsKey(tableEntryLocation.tableName)) {
Set<String> columns = new HashSet<String>();
columns.add(tableEntryLocation.columnName);
tableColumnsMapping.put(tableEntryLocation.tableName, columns);
} else {
tableColumnsMapping.get(tableEntryLocation.tableName).add(tableEntryLocation.columnName);
}
}
}
List<ExternalMapperTable> tablesHasColumnExpression = new ArrayList<ExternalMapperTable>();
tablesHasColumnExpression.addAll(varsTables);
tablesHasColumnExpression.addAll(outputTables);
for (ExternalMapperTable table : tablesHasColumnExpression) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
for (ExternalMapperTableEntry entry : metadataTableEntries) {
TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(entry.getExpression());
for (TableEntryLocation tableEntryLocation : tableEntryLocations) {
if (!tableColumnsMapping.containsKey(tableEntryLocation.tableName)) {
Set<String> columns = new HashSet<String>();
columns.add(tableEntryLocation.columnName);
tableColumnsMapping.put(tableEntryLocation.tableName, columns);
} else {
tableColumnsMapping.get(tableEntryLocation.tableName).add(tableEntryLocation.columnName);
}
}
}
}
return tableColumnsMapping;
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class MapperComponent method renameMetadataColumnName.
@Override
protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) {
if (conectionName == null || oldColumnName == null || newColumnName == null) {
throw new NullPointerException();
}
if (externalData != null) {
// rename metadata column name
List<ExternalMapperTable> tables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
tables.addAll(externalData.getOutputTables());
ExternalMapperTable tableFound = null;
for (ExternalMapperTable table : tables) {
if (table.getName().equals(conectionName)) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
for (ExternalMapperTableEntry entry : metadataTableEntries) {
if (entry.getName().equals(oldColumnName)) {
entry.setName(newColumnName);
tableFound = table;
break;
}
}
break;
}
}
// it is necessary to update expressions only if renamed column come from input table
if (tableFound != null && externalData.getInputTables().indexOf(tableFound) != -1) {
TableEntryLocation oldLocation = new TableEntryLocation(conectionName, oldColumnName);
TableEntryLocation newLocation = new TableEntryLocation(conectionName, newColumnName);
replaceLocationsInAllExpressions(oldLocation, newLocation, false);
}
}
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class MapperComponent method renameInputConnection.
public void renameInputConnection(String oldConnectionName, String newConnectionName) {
if (oldConnectionName == null || newConnectionName == null) {
throw new NullPointerException();
}
if (externalData != null) {
List<ExternalMapperTable> inputTables = externalData.getInputTables();
for (ExternalMapperTable table : inputTables) {
if (table.getName().equals(oldConnectionName)) {
table.setName(newConnectionName);
TableEntryLocation oldLocation = new TableEntryLocation(oldConnectionName, null);
TableEntryLocation newLocation = new TableEntryLocation(newConnectionName, null);
replaceLocationsInAllExpressions(oldLocation, newLocation, true);
break;
}
}
}
}
Aggregations