use of net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin in project tdq-studio-se by Talend.
the class SqlexplorerService method removeAliasInSQLExplorer.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.service.ISqlexplorerService#removeAliasInSQLExplorer(orgomg.cwm.foundation.softwaredeployment
* .DataProvider[])
*/
@Override
public void removeAliasInSQLExplorer(DataProvider... dataproviders) {
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
AliasManager aliasManager = sqlPlugin.getAliasManager();
DatabaseStructureView dsView = sqlPlugin.findDatabaseStructureView();
// alias from propertyFile map at the same time.
try {
Collection<Alias> aliases = aliasManager.getAliases();
if (aliases.isEmpty()) {
return;
}
for (DataProvider dataProvider : dataproviders) {
String aliasName = dataProvider.getName();
if (null == aliasName) {
continue;
}
Alias alias = aliasManager.getAlias(aliasName);
if (alias != null) {
sqlPlugin.getPropertyFile().remove(alias);
aliasManager.removeAlias(aliasName);
}
// if the ctabItem is open,close it.
if (dsView != null) {
dsView.closeCurrentCabItem(aliasName);
}
}
} catch (Exception e) {
log.error(e, e);
}
aliasManager.modelChanged();
}
use of net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin in project tdq-studio-se by Talend.
the class SqlexplorerService method updateDriverIfClassNotLoad.
/**
* if the sqlexplorer driver is unRegisted,load the driver jar by lib manage system.
*
* @param sqlPlugin
* @param connection
* @param databaseConnection
*/
public void updateDriverIfClassNotLoad(DatabaseConnection databaseConnection) {
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
DriverManager driverManager = sqlPlugin.getDriverModel();
String driverClassName = JavaSqlFactory.getDriverClass(databaseConnection);
if (driverClassName != null) {
String id = AliasAndManaDriverHelper.getInstance().joinManagedDriverId(databaseConnection);
ManagedDriver manDr = driverManager.getDriver(id);
if (manDr != null && !manDr.isDriverClassLoaded()) {
loadDriverByLibManageSystem(databaseConnection);
}
}
}
use of net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin in project tdq-studio-se by Talend.
the class SqlexplorerService method updateConnetionAliasByName.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.service.ISqlexplorerService#updateConnetionAliasByName(org.talend.core.model.metadata.
* builder.connection.Connection, java.lang.String)
*/
@Override
public void updateConnetionAliasByName(Connection connection, String aliasName) {
if (connection == null || aliasName == null) {
return;
}
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
// if the ctabItem is open,close it.
DatabaseStructureView view = sqlPlugin.findDatabaseStructureView();
if (view != null) {
view.closeCurrentCabItem(aliasName);
}
AliasManager aliasManager = sqlPlugin.getAliasManager();
Alias alias = aliasManager.getAlias(aliasName);
if (alias != null) {
try {
aliasManager.removeAlias(aliasName);
addConnetionAliasToSQLPlugin(connection);
} catch (Exception e) {
log.error(e, e);
}
}
}
use of net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin in project tdq-studio-se by Talend.
the class URLUtil method init.
private static void init() {
SQLExplorerPlugin defaultPlugin = SQLExplorerPlugin.getDefault();
baseURL = defaultPlugin.getBundle().getEntry("/");
initialized = true;
}
use of net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin in project tdq-studio-se by Talend.
the class SqlexplorerService method getDriver.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.service.ISqlexplorerService#getDriver(java.lang.String, java.lang.String)
*/
@Override
public Driver getDriver(String driverClassName, String jarsPath) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
Driver driver = null;
if (StringUtils.isNotEmpty(jarsPath)) {
try {
driver = this.createGenericJDBC(jarsPath, driverClassName);
} catch (Exception e) {
log.error(e, e);
}
return driver;
}
SQLExplorerPlugin sqlExplorerPlugin = SQLExplorerPlugin.getDefault();
if (sqlExplorerPlugin != null) {
net.sourceforge.sqlexplorer.dbproduct.DriverManager driverModel = sqlExplorerPlugin.getDriverModel();
try {
Collection<ManagedDriver> drivers = driverModel.getDrivers();
for (ManagedDriver managedDriver : drivers) {
LinkedList<String> jars = managedDriver.getJars();
List<URL> urls = new ArrayList<URL>();
for (int i = 0; i < jars.size(); i++) {
File file = new File(jars.get(i));
if (file.exists()) {
urls.add(file.toURI().toURL());
}
}
if (!urls.isEmpty()) {
try {
MyURLClassLoader cl;
cl = new MyURLClassLoader(urls.toArray(new URL[0]));
Class<?> clazz = cl.findClass(driverClassName);
if (clazz != null) {
driver = (Driver) clazz.newInstance();
if (driver != null) {
return driver;
}
}
} catch (ClassNotFoundException e) {
// do nothings
}
}
}
} catch (MalformedURLException e) {
// do nothings
}
}
if (driver == null) {
driver = (Driver) Class.forName(driverClassName).newInstance();
}
return driver;
}
Aggregations