use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method getAllNamesByRepositoryNode.
/**
* method "getTableNamesByRepositoryNode" get All Table Names in current RepositoryNode's DatabaseConnectionItem.
*
* @param node current RepositoryNode
* @return List :all Table Names.
*/
@SuppressWarnings("unchecked")
public static Map<String, List<String>> getAllNamesByRepositoryNode(RepositoryNode node) {
Map<String, List<String>> allNames = new HashMap<String, List<String>>();
DatabaseConnectionItem item = getItem(getRoot(node));
DatabaseConnection connection = (DatabaseConnection) item.getConnection();
Set<MetadataTable> tablesFromEMF = ConnectionHelper.getTables(connection);
boolean isOdbc = connection.getSID() == null || connection.getSID().length() == 0;
String sid = isOdbc ? connection.getDatasourceName() : connection.getSID();
for (MetadataTable table : tablesFromEMF) {
String tableName = table.getSourceName();
if (tableName != null && !"".equals(tableName)) {
//$NON-NLS-1$
List<String> columnNames = new ArrayList<String>();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
tableName = "\"" + sid + "\".\"" + tableName + "\"";
List<MetadataColumn> columns = table.getColumns();
for (MetadataColumn column : columns) {
String columnName = column.getOriginalField();
if (columnName != null && !"".equals(columnName)) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
columnName = tableName + ".\"" + columnName + "\"";
columnNames.add(columnName);
}
}
allNames.put(tableName, columnNames);
}
}
return allNames;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class DBStructureComposite method updateStructureView.
/**
* Updates the structure view to reflect the change of Repository View.
*
* @see SQLBuilderDialog.repositoryChanged(RepositoryChangedEvent event)
* @param event
*/
protected void updateStructureView(RepositoryChangedEvent event) {
if (!isShowAllConnections) {
DatabaseConnectionItem originalConnection = getDisplayedConnection();
IRepositoryViewObject repositoryObject = event.getDelta().getRepositoryObject();
if (repositoryObject != null) {
DatabaseConnectionItem newConnection = (DatabaseConnectionItem) repositoryObject.getProperty().getItem();
if (!originalConnection.getProperty().getId().equals(newConnection.getProperty().getId())) {
return;
}
if (!originalConnection.getProperty().getLabel().equals(newConnection.getProperty().getLabel())) {
String newRepositoryName = newConnection.getProperty().getLabel();
this.builderDialog.getConnParameters().setRepositoryName(newRepositoryName);
this.builderDialog.getConnParameters().setRepositoryId(newConnection.getProperty().getId());
}
}
}
((DBTreeProvider) treeViewer.getContentProvider()).setInitialized(false);
treeViewer.setInput(new RepositoryNode(null, null, ENodeType.SYSTEM_FOLDER));
doExpand();
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method getALLQueryLabels.
/**
* dev Comment method "getALLQueryLabels".
*
* @param repositoryNode current RepositoryNode.
* @return all QueryLabels in Emf.
*/
@SuppressWarnings("unchecked")
public List<String> getALLQueryLabels(RepositoryNode repositoryNode) {
List<String> allQueries = new ArrayList<String>();
DatabaseConnectionItem item = getEMFItem(repositoryNode.getObject().getId());
DatabaseConnection connection = (DatabaseConnection) item.getConnection();
QueriesConnection queriesConnection = connection.getQueries();
if (queriesConnection != null) {
List<Query> qs = queriesConnection.getQuery();
for (Query q1 : qs) {
allQueries.add(q1.getLabel());
}
}
return allQueries;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class RenameDriverJarPathForDBConnectionMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
Connection connection = ((DatabaseConnectionItem) item).getConnection();
if (connection instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) connection;
String oldJarPath = dbConn.getDriverJarPath();
String newJarPath = null;
try {
if (oldJarPath != null && !"".equals(oldJarPath.trim())) {
//$NON-NLS-1$
IPath path = Path.fromOSString(oldJarPath);
if (path.isAbsolute()) {
newJarPath = path.lastSegment();
}
}
if (newJarPath != null) {
dbConn.setDriverJarPath(newJarPath);
ProxyRepositoryFactory.getInstance().save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class RenameAccessDbVersionInConnection method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem connectionItem = (DatabaseConnectionItem) item;
DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
if (connection instanceof DatabaseConnection) {
DatabaseConnection dbConnection = (DatabaseConnection) connection;
if (EDatabaseTypeName.ACCESS.equals(EDatabaseTypeName.getTypeFromDbType(dbConnection.getDatabaseType()))) {
boolean modified = false;
if (EDatabaseVersion4Drivers.ACCESS_2003.getVersionValue().toUpperCase().equals(dbConnection.getDbVersionString())) {
dbConnection.setDbVersionString(EDatabaseVersion4Drivers.ACCESS_2003.getVersionValue());
modified = true;
} else if (EDatabaseVersion4Drivers.ACCESS_2007.getVersionValue().toUpperCase().equals(dbConnection.getDbVersionString())) {
dbConnection.setDbVersionString(EDatabaseVersion4Drivers.ACCESS_2007.getVersionValue());
modified = true;
}
if (modified) {
try {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations