use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class MapperManager method addInputAliasTable.
/**
* DOC amaumont Comment method "addAlias".
*/
public void addInputAliasTable() {
AliasDialog aliasDialog = new AliasDialog(this, tableManager.getPhysicalInputTableNames(), tableManager.getAliases(), tableManager.getVisibleTables());
if (!aliasDialog.open()) {
return;
}
List<IOConnection> incomingConnections = getComponent().getMapperMain().getIoInputConnections();
IOConnection connectionFound = null;
for (IOConnection connection : incomingConnections) {
if (connection.getName().equalsIgnoreCase(aliasDialog.getTableName())) {
connectionFound = connection;
break;
}
}
List<DataMapTableView> inputsTablesView = getUiManager().getInputsTablesView();
int sizeOutputsView = inputsTablesView.size();
Control lastChild = null;
if (sizeOutputsView - 1 >= 0) {
lastChild = inputsTablesView.get(sizeOutputsView - 1);
}
String alias = aliasDialog.getAlias();
//$NON-NLS-1$
boolean isPhysicalTable = alias.equals("") || alias.equalsIgnoreCase(aliasDialog.getTableName());
String aliasOrTableName = isPhysicalTable ? aliasDialog.getTableName() : alias;
IMetadataTable metadataTable = isPhysicalTable ? connectionFound.getTable() : connectionFound.getTable().clone();
boolean isInvisiblePhysicalTable = aliasDialog.isSameAsPhysicalTable(aliasOrTableName) && !aliasDialog.isSameAsVisibleTableName(aliasOrTableName);
InputTable inputTable = new InputTable(this, metadataTable, aliasOrTableName);
if (isInvisiblePhysicalTable) {
inputTable.setAlias(null);
} else {
inputTable.setAlias(aliasOrTableName);
}
inputTable.setTableName(aliasDialog.getTableName());
inputTable.initFromExternalData(null);
TablesZoneView tablesZoneViewInputs = uiManager.getTablesZoneViewInputs();
DataMapTableView dataMapTableView = uiManager.createNewInputTableView(lastChild, inputTable, tablesZoneViewInputs);
tablesZoneViewInputs.setSize(tablesZoneViewInputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewInputs.layout(true, true);
uiManager.moveInputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
tablesZoneViewInputs.layout();
uiManager.selectDataMapTableView(dataMapTableView, true, false);
uiManager.updateDropDownJoinTypeForInputs();
uiManager.parseAllExpressionsForAllTables();
uiManager.refreshSqlExpression();
getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
use of org.talend.designer.dbmap.model.table.InputTable 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) {
TableEntryLocation tableEntryLocationKey = new TableEntryLocation(dataMapTableEntry.getParentName(), previousColumnName);
// TableEntriesManager.buildLocation(dataMapTableEntry);
ITableEntry entry = tableEntries.get(tableEntryLocationKey);
if (entry != dataMapTableEntry) {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("TableEntriesManager.exceptionMessage.tableEntriesNotSame"));
}
tableEntries.remove(tableEntryLocationKey);
tableEntryLocationKey.columnName = newColumnName;
tableEntries.put(tableEntryLocationKey, dataMapTableEntry);
// update matching column
IMetadataColumn metadataColumn = null;
InputTable inputTable = isPhysicalTable(dataMapTableEntry.getParent());
if (inputTable != null) {
metadataColumn = getColumnFromDbTable(inputTable.getName(), dataMapTableEntry.getName());
removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
addMetadataColumnFromDbTable(inputTable.getTableName(), newColumnName, metadataColumn);
}
dataMapTableEntry.setName(newColumnName);
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class TableEntriesManager method addInternal.
/**
* DOC amaumont Comment method "add".
*
* @param dataMapTableEntry
*/
private void addInternal(ITableEntry dataMapTableEntry) {
tableEntries.put(TableEntryLocation.getNewInstance(dataMapTableEntry), dataMapTableEntry);
IDataMapTable dataMapTable = dataMapTableEntry.getParent();
InputTable inputTable = isPhysicalTable(dataMapTable);
if (inputTable != null) {
IMetadataColumn metadataColumn = ((InputColumnTableEntry) dataMapTableEntry).getMetadataColumn();
addMetadataColumnFromDbTable(inputTable.getTableName(), metadataColumn.getLabel(), metadataColumn);
}
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkDropIsValid.
/**
* DOC amaumont Comment method "checkDropHasValidTarget".
*/
private boolean checkDropIsValid() {
isInputToInput = false;
mapOneToOneAuthorized = true;
if (targetTableIsFiltersTable() || draggedData.getTransferableEntryList().size() <= 1) {
mapOneToOneAuthorized = false;
}
if (invalidKeyPressed) {
return false;
}
/*
* INPUT => INPUT
*/
if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
isInputToInput = true;
mapOneToOneAuthorized = false;
List<InputTable> inputTables = mapperManager.getInputTables();
int indexSourceInputTable = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTargetInputTable = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (indexSourceInputTable == indexTargetInputTable) {
return false;
} else {
return true;
}
}
/*
* OUTPUT => OUTPUT
*/
if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
isOutputToOutput = true;
mapOneToOneAuthorized = true;
List<OutputTable> outputTables = mapperManager.getOutputTables();
int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (indexSourceOutputTable == indexTargetOutputTable) {
return false;
} else {
return true;
}
}
TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS) {
/*
* OUTPUT => OUTPUT OUTPUT => INPUT
*/
return false;
}
return true;
}
use of org.talend.designer.dbmap.model.table.InputTable 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);
}
Aggregations