use of org.talend.core.model.metadata.IMetadataConnection in project tdq-studio-se by Talend.
the class ConnectionUtils method updataTaggedValueForConnectionItem.
/**
* Updata DB_PRODUCT tagged values for connection item in case they are not present in current file.
*
* @throws SQLException
*/
public static synchronized void updataTaggedValueForConnectionItem(Connection dataProvider) {
if (dataProvider instanceof DatabaseConnection && StringUtils.isBlank(TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_NAME, dataProvider))) {
Property property = PropertyHelper.getProperty(dataProvider);
if (property != null) {
Item item = property.getItem();
if (item != null) {
DatabaseConnection dbConn = (DatabaseConnection) dataProvider;
IMetadataConnection metaConnection = ConvertionHelper.convert(dbConn);
dbConn = (DatabaseConnection) MetadataFillFactory.getDBInstance(dataProvider).fillUIConnParams(metaConnection, dbConn);
if (dbConn != null && Platform.isRunning()) {
try {
ProxyRepositoryFactory.getInstance().save(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
}
}
use of org.talend.core.model.metadata.IMetadataConnection in project tdq-studio-se by Talend.
the class SqlexplorerService method loadManagedDriverForHive.
/**
* TDDQ-8113 load hive drive by DynamicClassLoader,then set the attribute for Hive ManagedDriver.
*
* @param connection
*/
private void loadManagedDriverForHive(DatabaseConnection connection) {
DriverManager driverManager = SQLExplorerPlugin.getDefault().getDriverModel();
String id = AliasAndManaDriverHelper.getInstance().joinManagedDriverId(connection);
ManagedDriver manDr = driverManager.getDriver(id);
IMetadataConnection metadataConnection = ConvertionHelper.convert(connection);
ClassLoader classLoader = null;
if (EDatabaseTypeName.IMPALA.getXmlName().equalsIgnoreCase(connection.getDatabaseType())) {
classLoader = AliasAndManaDriverHelper.getInstance().getImpalaClassLoader(metadataConnection);
} else {
classLoader = HiveClassLoaderFactory.getInstance().getClassLoader(metadataConnection);
}
if (classLoader != null && classLoader instanceof DynamicClassLoader) {
DynamicClassLoader dynClassLoader = (DynamicClassLoader) classLoader;
String libStorePath = dynClassLoader.getLibStorePath();
File libFolder = new File(libStorePath);
if (libFolder.exists()) {
List<String> relaPathLs = new ArrayList<String>();
relaPathLs.addAll(dynClassLoader.getLibraries());
Set<String> findAllJarPath = findAllJarPath(libFolder, relaPathLs);
if (!findAllJarPath.isEmpty()) {
manDr.getJars().addAll(findAllJarPath);
try {
manDr.registerHiveSQLDriver(connection);
} catch (ClassNotFoundException e) {
log.error(e);
} catch (InstantiationException e) {
log.error(e);
} catch (IllegalAccessException e) {
log.error(e);
}
}
}
}
}
use of org.talend.core.model.metadata.IMetadataConnection in project tdq-studio-se by Talend.
the class AliasAndManaDriverHelper method joinHiveManagedDriverId.
private String joinHiveManagedDriverId(DatabaseConnection dbConn) {
IMetadataConnection metadataConn = ConvertionHelper.convert(dbConn);
String url = metadataConn.getUrl();
StringBuffer str = new StringBuffer();
String id = PluginConstant.EMPTY_STRING;
if (url != null) {
if (url.startsWith(DatabaseConnConstants.HIVE_2_URL_FORMAT)) {
str.append("HIVE2");
} else {
str.append("HIVE");
}
String distroKey = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION);
String distroVersion = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION);
String hiveModel = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
str.append(":").append(distroKey).append(":").append(distroVersion).append(":").append(hiveModel);
id = str.toString();
}
return id;
}
Aggregations