use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(Collection<? extends AbstractDataMapTable> tables) {
for (IDataMapTable table : tables) {
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
fillExternalTable(table, externalMapperTable);
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
boolean isVarTable = table instanceof VarsTable;
boolean isInputTable = table instanceof InputTable;
for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
if (isVarTable) {
externalMapperTableEntry.setType(((VarTableEntry) dataMapTableEntry).getType());
externalMapperTableEntry.setNullable(((VarTableEntry) dataMapTableEntry).isNullable());
} else {
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
}
if (isInputTable) {
externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
}
perTableEntries.add(externalMapperTableEntry);
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
}
}
use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
// for (int i = 0; i < tables.size(); i++) {
if (tables.size() <= 0 || intables.size() <= 0) {
return;
}
IDataMapTable outtable = tables.get(0);
IDataMapTable intable = intables.get(0);
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
fillExternalTable(outtable, externalMapperTable);
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
List<IMetadataColumn> columnList = null;
if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
if (connList != null && connList.size() >= 1) {
List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
if (metaList != null && metaList.size() >= 1) {
columnList = metaList.get(0).getListColumns();
}
}
}
for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
if (columnList != null) {
boolean find = false;
for (IMetadataColumn column : columnList) {
if (dataMapTableEntry.getName().equals(column.getLabel())) {
find = true;
break;
}
}
if (find) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
} else {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
use of org.talend.designer.abstractmap.model.table.IDataMapTable 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;
}
use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.
the class UIManager method selectDataMapTableView.
/**
* Select a table view.
*
* @param dataMapTableView
* @param useNewCommand
* @param selectAllEntries TODO
*/
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
// tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
MetadataTableEditorView metadataTableEditorView = null;
MetadataTableEditorView otherMetadataTableEditorView = null;
final Zone currentZone = dataMapTableView.getZone();
List<? extends IDataMapTable> tables = null;
DataMapTableView previousSelectedTableView = null;
DataMapTableView newSelectedTableView = null;
if (currentZone == Zone.INPUTS) {
metadataTableEditorView = tabFolderEditors.getInputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
tables = mapperManager.getInputTables();
previousSelectedTableView = this.currentSelectedInputTableView;
setCurrentSelectedInputTableView((InputDataMapTableView) dataMapTableView);
newSelectedTableView = dataMapTableView;
} else if (currentZone == Zone.OUTPUTS) {
metadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditor();
tables = mapperManager.getOutputTables();
previousSelectedTableView = this.currentSelectedOutputTableView;
newSelectedTableView = dataMapTableView;
setCurrentSelectedOutputTableView((OutputDataMapTableView) dataMapTableView);
}
updateToolbarButtonsStates(currentZone);
final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveIDataMapTable(dataMapTableView);
MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && newSelectedTableView != previousSelectedTableView) {
if (useNewCommand) {
DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
mapperManager.executeCommand(command);
}
currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getTitle());
currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
// init actions listeners for list which contains metadata
metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {
/**
* DOC acer Comment method "handleEvent".
*
* @param event
*/
@Override
public void handleEvent(ListenableListEvent event) {
DataMapTableView view = mapperManager.retrieveIDataMapTableView(abstractDataMapTable);
if (event.type == TYPE.ADDED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
lastCreatedInOutColumnEntries.clear();
if (event.index != null) {
int index = event.index;
for (IMetadataColumn metadataColumn : metadataColumns) {
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index++));
}
} else if (event.indicesTarget != null) {
List<Integer> indicesTarget = event.indicesTarget;
int lstSize = indicesTarget.size();
for (int i = 0; i < lstSize; i++) {
Integer indice = indicesTarget.get(i);
IMetadataColumn metadataColumn = metadataColumns.get(i);
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("UIManager.1"));
}
refreshBackground(false, false);
if (event.index != null) {
dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
dataMapTableViewer.refresh();
dataMapTVCreator.getSelectionHelper().setSelection(event.index);
} else if (event.indicesTarget != null) {
dataMapTableViewer.refresh();
dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
dataMapTVCreator.getSelectionHelper().setSelection(selection);
}
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
if (event.type == TYPE.REMOVED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
for (IMetadataColumn metadataColumn : metadataColumns) {
ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
mapperManager.removeTableEntry(metadataTableEntry);
}
dataMapTableViewer.refresh();
dataMapTableView.resizeAtExpandedSize();
resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
refreshBackground(true, false);
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
if (event.type == TYPE.SWAPED) {
List<Integer> listIndexTarget = event.indicesTarget;
abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
// dataMapTableViewer.refresh();
refreshBackground(true, false);
}
}
});
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
// disable highlight for other DataMapTableView and highlight selected DataMapTableView
for (IDataMapTable table : tables) {
DataMapTableView otherDataMapTableView = mapperManager.retrieveIDataMapTableView(table);
otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
}
dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
}
if (selectAllEntries) {
dataMapTVCreator.getTable().selectAll();
selectAllLinks(dataMapTableView);
metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
if (currentZone == Zone.OUTPUTS) {
dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().selectAll();
dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().selectAll();
}
}
if (otherMetadataTableEditorView != null) {
otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.
the class UIManager method refreshSqlExpression.
/**
* Refresh Sql select query in the bottom tab and its title.
*/
public void refreshSqlExpression() {
if (getTabFolderEditors().getSelectionIndex() == 2) {
mapperManager.getComponent().restoreMapperModelFromInternalData();
OutputDataMapTableView selectedOutputTableView = getCurrentSelectedOutputTableView();
if (selectedOutputTableView == null) {
} else {
IDataMapTable dataMapTable = selectedOutputTableView.getDataMapTable();
String tableName = dataMapTable.getName();
DbGenerationManager generationMnager = mapperManager.getComponent().getGenerationManager();
String sql = generationMnager.buildSqlSelect(mapperManager.getComponent(), tableName);
getTabFolderEditors().getItem(2).setText(//$NON-NLS-1$
Messages.getString("TabFolderEditors.SqlSelectQuery", new Object[] { tableName }));
getTabFolderEditors().getStyledSqlText().setText(sql);
}
}
}
Aggregations