use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DataMapExpressionParserTest method testReplaceLocation_renamingColumn_underlineInColumn.
@Test
public void testReplaceLocation_renamingColumn_underlineInColumn() {
String result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.column_A", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.column_A", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.mycolumn_A", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.mycolumn_A", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.my_column_A", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.my_column_A", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.column_AB", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.column_AB", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.column_A_B", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.column_A_B", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.mycolumn_AB", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.mycolumn_AB", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.my_column_A_B", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.my_column_A_B", result);
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DataMapExpressionParserTest method testReplaceLocation_renamingColumn_same.
@Test
public void testReplaceLocation_renamingColumn_same() {
String result = expressionParser.replaceLocation("YYY.columnA == XXXYYY.columnA", new TableEntryLocation("YYY", "columnA"), new TableEntryLocation("YYY", "columnB"));
assertEquals("YYY.columnB == XXXYYY.columnA", result);
result = expressionParser.replaceLocation("YYY.column_A == XXXYYY.column_A", new TableEntryLocation("YYY", "column_A"), new TableEntryLocation("YYY", "column_B"));
assertEquals("YYY.column_B == XXXYYY.column_A", result);
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DataMapExpressionParserTest method testReplaceLocation_renamingColumn_middle.
@Test
public void testReplaceLocation_renamingColumn_middle() {
String result = expressionParser.replaceLocation("YYY.columnA == XXXYYY.mycolumnAB", new TableEntryLocation("YYY", "columnA"), new TableEntryLocation("YYY", "columnB"));
assertEquals("YYY.columnB == XXXYYY.mycolumnAB", result);
result = expressionParser.replaceLocation("YYY.columnA == XXXYYY.my_columnAB", new TableEntryLocation("YYY", "columnA"), new TableEntryLocation("YYY", "columnB"));
assertEquals("YYY.columnB == XXXYYY.my_columnAB", result);
result = expressionParser.replaceLocation("YYY.columnA == XXXYYY.my_columnA_B", new TableEntryLocation("YYY", "columnA"), new TableEntryLocation("YYY", "columnB"));
assertEquals("YYY.columnB == XXXYYY.my_columnA_B", result);
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class UIManager method parseFilterColumn.
public ParseExpressionResult parseFilterColumn(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
if (currentModifiedITableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry entry = (InputColumnTableEntry) currentModifiedITableEntry;
if (StringUtils.trimToNull(expression) == null) {
entry.setOperator(null);
}
}
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
boolean linkHasBeenAdded = false;
boolean linkHasBeenRemoved = false;
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
// tests to know if link must be removed if key is unchecked
boolean dontRemoveLink = (!isInputEntry || isInputEntry && (inputExpressionAppliedOrCanceled || !inputExpressionAppliedOrCanceled && !mapperManager.checkEntryHasInvalidUncheckedKey((InputColumnTableEntry) currentModifiedITableEntry)));
if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry) && (mapperManager.isAdvancedMap() || !mapperManager.isAdvancedMap() && dontRemoveLink)) {
ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
if (sourceTableEntry != null && sourcesForTarget.contains(sourceTableEntry)) {
Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
for (IMapperLink link : linksFromTarget) {
link.calculate();
}
}
}
}
mapperManager.orderLinks();
if (!mapperManager.isAdvancedMap()) {
if (dataMapTableView.getZone() == Zone.INPUTS) {
if (linkHasBeenAdded || linkHasBeenRemoved) {
checkTargetInputKey(currentModifiedITableEntry, checkInputKeyAutomatically, inputExpressionAppliedOrCanceled);
}
if (inputExpressionAppliedOrCanceled) {
openChangeKeysDialog((InputDataMapTableView) dataMapTableView);
}
}
}
return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
use of org.talend.designer.mapper.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
boolean atLeastOneLinkHasBeenRemoved = false;
for (DataMapTableView view : tableViews) {
IDataMapTable dataMapTable = view.getDataMapTable();
List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
for (IColumnEntry entry : metadataTableEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
// for the input/output table expression filter
if (dataMapTable instanceof AbstractInOutTable) {
ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
if (atLeastOneLinkHasBeenRemoved) {
new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
public void run() {
TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
Messages.getString("UIManager.propagateMessage"));
if (propagate) {
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
}
}
}).start();
}
}
Aggregations