use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems(ExternalDbMapData externalData) {
problems.clear();
if (externalData != null) {
List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
tablesWriteMode.addAll(inputTables);
tablesWriteMode.addAll(outputTables);
List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
ProblemsManager problemsManager = new ProblemsManager(mapperManager);
ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
for (AbstractInOutTable table : tablesReadMode) {
List<IColumnEntry> columnEntries = table.getColumnEntries();
problemsManager.checkProblemsForAllEntries(columnEntries);
for (IColumnEntry entry : columnEntries) {
List<Problem> problemsOfEntry = entry.getProblems();
if (problemsOfEntry != null) {
problemsLocal.addAll(problemsOfEntry);
}
}
}
problems.addAll(problemsLocal);
}
return getProblems();
}
use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.
the class TableEntriesManager method loadDbTableNameColumnNameToMetadaColumns.
public void loadDbTableNameColumnNameToMetadaColumns(List<IOConnection> connections) {
for (IOConnection connection : connections) {
IMetadataTable metadataTable = connection.getTable();
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
for (IMetadataColumn column : listColumns) {
addMetadataColumnFromDbTable(connection.getName(), column.getLabel(), column);
}
}
}
use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareOutputTables.
public ArrayList<OutputTable> prepareOutputTables(List<IOConnection> outputConnections, List<IMetadataTable> outputMetadataTables, ExternalDbMapData externalData) {
Map<String, ExternalDbMapTable> nameToOutpuPersistentTable = new HashMap<String, ExternalDbMapTable>();
if (externalData != null) {
for (ExternalDbMapTable persistentTable : externalData.getOutputTables()) {
nameToOutpuPersistentTable.put(persistentTable.getName(), persistentTable);
}
}
Map<String, IOConnection> nameToOutputConn = new HashMap<String, IOConnection>();
if (outputConnections != null) {
for (IOConnection connection : outputConnections) {
if (connection.getConnectionType().equals(EConnectionType.FLOW_MAIN) || connection.getConnectionType().equals(EConnectionType.FLOW_REF) || connection.getConnectionType().equals(EConnectionType.TABLE) || connection.getConnectionType().equals(EConnectionType.TABLE_REF)) {
nameToOutputConn.put(connection.getUniqueName(), connection);
}
}
}
ArrayList<OutputTable> outputDataMapTables = new ArrayList<OutputTable>();
for (IMetadataTable table : outputMetadataTables) {
IOConnection connection = nameToOutputConn.get(table.getTableName());
OutputTable outputTable = null;
if (connection != null) {
ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(connection.getUniqueName());
outputTable = new OutputTable(this.mapperManager, table.clone(), connection.getUniqueName(), connection.getName());
outputTable.initFromExternalData(persistentTable);
} else {
ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(table.getTableName());
if (persistentTable != null) {
outputTable = new OutputTable(this.mapperManager, table, persistentTable.getName(), persistentTable.getTableName());
outputTable.initFromExternalData(persistentTable);
} else {
outputTable = new OutputTable(this.mapperManager, table, table.getTableName(), table.getLabel());
}
}
if (outputTable != null) {
outputDataMapTables.add(outputTable);
}
}
return outputDataMapTables;
}
use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.
the class MapperMain method initIOConnections.
public void initIOConnections(IODataComponentContainer ioDataContainer) {
List<IODataComponent> inputsData = ioDataContainer.getInputs();
List<IODataComponent> ouputsData = ioDataContainer.getOuputs();
ioInputConnections = new ArrayList<IOConnection>(inputsData.size());
for (IODataComponent iData : inputsData) {
ioInputConnections.add(new IOConnection(iData));
}
ioOutputConnections = new ArrayList<IOConnection>(ouputsData.size());
for (IODataComponent oData : ouputsData) {
ioOutputConnections.add(new IOConnection(oData));
}
}
use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param renamingDependentEntries TODO
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
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;
}
}
if (dataMapTable instanceof OutputTable) {
List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
for (FilterTableEntry entry : constraintWhereEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
for (FilterTableEntry entry : constraintOtherEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
refreshSqlExpression();
if (!renamingDependentEntries) {
AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
if (currentTable instanceof InputTable) {
InputTable currentInputTable = (InputTable) currentTable;
String physicalTableName = currentInputTable.getTableName();
String alias = currentInputTable.getAlias();
InputTable physicalInputTable = null;
List<InputTable> inputTables = mapperManager.getInputTables();
if (alias != null) {
for (InputTable table : inputTables) {
if (table.equals(physicalTableName)) {
physicalInputTable = table;
}
}
} else {
physicalInputTable = currentInputTable;
}
if (physicalInputTable == null) {
List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
IOConnection connectionFound = null;
for (IOConnection connection : incomingConnections) {
if (connection.getName().equals(physicalTableName)) {
connectionFound = connection;
}
}
IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
if (metadataColumn != null) {
metadataColumn.setLabel(newColumnName);
}
}
for (InputTable table : inputTables) {
if ((// Physical table parent
alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
if (aliasTableEntry != null) {
processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
}
}
}
}
}
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
Aggregations