use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
if (searchValue.equals("")) {
uiManager.unselectAllEntriesOfAllTables();
return;
}
// SearchPattern
matcher.setPattern("*" + searchValue.trim() + "*");
List<InputTable> inputTables = mapperManager.getInputTables();
List<VarsTable> varsTables = mapperManager.getVarsTables();
List<OutputTable> outputTables = mapperManager.getOutputTables();
int index = -1;
// for the InputTables
for (InputTable inputTable : inputTables) {
for (IColumnEntry column : inputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
// ExpressionFilter
ExpressionFilterEntry expressionFilterEntry = inputTable.getExpressionFilter();
if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, expressionFilterEntry);
index++;
searchMaps.put(index, map);
}
}
// for the VarsTables
for (VarsTable varsTable : varsTables) {
for (IColumnEntry column : varsTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
}
// for the OutputTables
for (OutputTable outputTable : outputTables) {
for (IColumnEntry column : outputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
// ExpressionFilter
ExpressionFilterEntry expressionFilterEntry = outputTable.getExpressionFilter();
if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, expressionFilterEntry);
index++;
searchMaps.put(index, map);
}
}
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class AutoMapper method map.
/**
* DOC amaumont Comment method "map".
*/
public void map() {
List<InputTable> inputTables = mapperManager.getInputTables();
List<OutputTable> outputTables = mapperManager.getOutputTables();
IDbLanguage currentLanguage = mapperManager.getCurrentLanguage();
HashMap<String, InputTable> nameToInputTable = new HashMap<String, InputTable>(inputTables.size());
for (InputTable inputTable : inputTables) {
nameToInputTable.put(inputTable.getName(), inputTable);
}
// output tables are the references
for (OutputTable outputTable : outputTables) {
List<IColumnEntry> outputEntries = outputTable.getColumnEntries();
boolean mapFound = false;
for (IColumnEntry outputEntry : outputEntries) {
mapFound = false;
if (mapperManager.checkEntryHasEmptyExpression(outputEntry)) {
String outputColumnName = outputEntry.getName();
for (InputTable inputTable : inputTables) {
List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
for (IColumnEntry inputEntry : inputColumnEntries) {
if (inputEntry.getName().equalsIgnoreCase(outputColumnName)) {
outputEntry.setExpression(currentLanguage.getLocation(inputTable.getName(), inputEntry.getName()));
mapFound = true;
break;
}
}
if (mapFound) {
break;
}
}
}
}
DataMapTableView view = mapperManager.retrieveIDataMapTableView(outputTable);
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
}
mapperManager.getProblemsManager().checkProblems();
List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
for (DataMapTableView view : outputsTablesView) {
mapperManager.getUiManager().parseAllExpressions(view, true);
mapperManager.getProblemsManager().checkProblemsForAllEntries(view, true);
}
mapperManager.getUiManager().refreshBackground(true, false);
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class CompleteDropTargetListener method updateExpressionsOfInsertedEntries.
/**
* DOC amaumont Comment method "updateExpressionsOfInsertedEntries".
*
* @param uiManager
* @param currentLanguage
* @param metadataEditorView
* @param currentIndex
* @param sourceEntriesOfEntriesBeingAdded
* @param targetTableIsConstraintsTable
* @param tableViewerCreatorTarget
* @param metadataColumnsBeingAdded
* @param metadataEditorEvent
*/
@SuppressWarnings("unchecked")
private void updateExpressionsOfInsertedEntries(IDbLanguage currentLanguage, MetadataTableEditorView metadataEditorView, int currentIndex, ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded, boolean targetTableIsConstraintsTable, TableViewerCreator tableViewerCreatorTarget, ArrayList<IMetadataColumn> metadataColumnsBeingAdded) // , MetadataEditorEvent metadataEditorEvent
{
UIManager uiManager = getUiManager();
if (metadataEditorView != null && !targetTableIsConstraintsTable) {
metadataEditorView.getMetadataTableEditor().addAll(currentIndex, metadataColumnsBeingAdded);
// metadataEditorEvent.indexStartInsert = currentIndex;
// IAction action = MetadataEditorActionFactory.getInstance().getAction(metadataEditorView,
// metadataEditorEvent);
// action.run(metadataEditorEvent);
Zone zoneTarget = getMapperManager().retrieveDataMapTableView(tableViewerCreatorTarget.getTable()).getZone();
List<IColumnEntry> lastCreatedTableEntries = uiManager.getLastCreatedInOutColumnEntries();
for (int i = 0; i < lastCreatedTableEntries.size(); i++) {
ITableEntry tableEntrySource = sourceEntriesOfEntriesBeingAdded.get(i);
ITableEntry dataMapTableEntry = lastCreatedTableEntries.get(i);
if (zoneTarget == Zone.INPUTS) {
setDefaultOperator((InputColumnTableEntry) dataMapTableEntry);
}
DataMapTableView dataMapTableView = getMapperManager().retrieveIDataMapTableView(tableEntrySource.getParent());
Zone zoneSource = dataMapTableView.getZone();
String location = null;
if (zoneSource == Zone.OUTPUTS) {
location = tableEntrySource.getExpression();
} else {
location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
}
if (location != null) {
//$NON-NLS-1$
dataMapTableEntry.setExpression(location + " ");
}
}
}
tableViewerCreatorTarget.getTableViewer().refresh();
List<ITableEntry> refreshedTableEntriesList = tableViewerCreatorTarget.getInputList();
for (ITableEntry tableEntry : refreshedTableEntriesList) {
uiManager.parseExpression(tableEntry.getExpression(), tableEntry, false, true, false);
}
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class DataMapTableView method unselectAllEntriesIfErrorDetected.
/**
* DOC amaumont Comment method "unselectAllEntriesIfErrorDetected".
*
* @param e
*/
protected void unselectAllEntriesIfErrorDetected(TableCellValueModifiedEvent e) {
if (e.column.getId().equals(ID_EXPRESSION_COLUMN)) {
ITableEntry currentEntry = (ITableEntry) e.bean;
TableViewer tableViewer = null;
if (currentEntry instanceof IColumnEntry) {
tableViewer = DataMapTableView.this.getTableViewerCreatorForColumns().getTableViewer();
} else if (currentEntry instanceof FilterTableEntry) {
if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) currentEntry).getFilterKind())) {
tableViewer = entendedTableViewerForOtherClauses.getTableViewerCreator().getTableViewer();
} else {
tableViewer = extendedTableViewerForFilters.getTableViewerCreator().getTableViewer();
}
}
if (currentEntry.getProblems() != null) {
tableViewer.getTable().deselectAll();
}
}
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewColumnEntry.
/**
* This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
* want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
*
* @param dataMapTableView
* @param metadataColumn, can be null if added in VarsTable
* @param index
*/
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
IColumnEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
String expression = metadataColumn.getExpression();
if (expression != null && !"".equals(expression)) {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn, expression);
} else {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
}
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
tableEntriesManager.addTableEntry(dataMapTableEntry, index);
return dataMapTableEntry;
}
Aggregations