use of orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.
the class CatalogEvaluator method executeSqlQuery.
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
ReturnCode ok = new ReturnCode(true);
// --- preconditions
DataProvider dataProvider = this.getDataManager();
if (this.elementToIndicators.values().isEmpty()) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator1");
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
Indicator[] indics = this.getAllIndicators();
if (indics.length == 0) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator2", dataProvider);
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
for (Indicator indicator : indics) {
CatalogIndicator catalogIndicator = DataqualitySwitchHelper.CATALOG_SWITCH.doSwitch(indicator);
if (catalogIndicator == null) {
continue;
}
Catalog catalog = (Catalog) catalogIndicator.getAnalyzedElement();
String catName = catalog.getName();
// MOD yyi 2009-11-30 10187
if (!checkCatalog(catName)) {
// $NON-NLS-1$
ok.setReturnCode(Messages.getString("Evaluator.catalogNotExist", catName), false);
return ok;
}
// MOD qiongli 2012-8-9,Method 'Method not supported' not supported for HiveConnection
if (dbms().supportCatalogSelection()) {
connection.setCatalog(catName);
}
List<Schema> schemas = CatalogHelper.getSchemas(catalog);
if (schemas.isEmpty()) {
// no schema
evalCatalogIndic(catalogIndicator, catalog, ok);
} else {
catalogIndicator.setAnalyzedElement(catalog);
catalogIndicator.setSchemaCount(schemas.size());
// --- create SchemaIndicator for each pair of catalog schema
for (Schema tdSchema : schemas) {
// --- create SchemaIndicator for each catalog
SchemaIndicator schemaIndic = SchemaFactory.eINSTANCE.createSchemaIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(schemaIndic);
evalSchemaIndicLow(catalogIndicator, schemaIndic, catalog, tdSchema, ok);
}
}
}
return ok;
}
use of orgomg.cwm.foundation.softwaredeployment.DataProvider 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 orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.
the class CheckAndUpdateAnalysisDependencyTask method checkAndRemoveWrongDependencies.
/**
* check each analysis if it has only one client dependency, if more than one, remove the useless one.
*
* @param list
* @throws CoreException
*/
private void checkAndRemoveWrongDependencies(List<Analysis> analyses) throws CoreException {
for (Analysis analysis : analyses) {
if (analysis != null) {
boolean isAnalysisModified = false;
if (analysis.getContext().getAnalysedElements() == null || analysis.getContext().getAnalysedElements().size() < 1) {
continue;
}
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(analysis.getContext().getAnalysedElements().get(0));
if (tdColumn == null) {
continue;
}
// find the correct db connection from analyzed element
DataManager correctDB = ConnectionHelper.getConnection(tdColumn);
// check if the connection is correct or not
DataManager connection = analysis.getContext().getConnection();
if (connection == null || !correctDB.getName().equals(connection.getName())) {
analysis.getContext().setConnection(correctDB);
isAnalysisModified = true;
}
List<DataProvider> clientDependencyDB = null;
for (Dependency dependency : analysis.getClientDependency()) {
ModelElement supplier = dependency.getSupplier().get(0);
if (supplier instanceof DataProvider) {
if (supplier != null && correctDB.getName().equals(supplier.getName())) {
continue;
} else {
if (clientDependencyDB == null) {
clientDependencyDB = new ArrayList<DataProvider>();
}
clientDependencyDB.add((DataProvider) supplier);
}
}
}
if (clientDependencyDB != null) {
for (DataProvider uselessDB : clientDependencyDB) {
// if the db in client dependency do not equal to the correct db, remove it from both the
// analysis and db connection
removeDependenciesBetweenAnaCon(uselessDB, analysis);
isAnalysisModified = true;
}
}
if (isAnalysisModified) {
EMFSharedResources.getInstance().saveResource(analysis.eResource());
}
}
}
}
use of orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.
the class SchemaEvaluator method executeSqlQuery.
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
ReturnCode ok = new ReturnCode(true);
// --- preconditions
DataProvider dataProvider = this.getDataManager();
if (this.elementToIndicators.values().isEmpty()) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator1");
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
Indicator[] indics = this.getAllIndicators();
if (indics.length == 0) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator2", dataProvider);
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
for (Indicator indicator : indics) {
SchemaIndicator schemaIndicator = DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
if (schemaIndicator == null) {
continue;
}
Schema schema = (Schema) schemaIndicator.getAnalyzedElement();
String catName = schema.getName();
// MOD yyi 2009-11-30 10187
if (!checkSchema(schema)) {
// $NON-NLS-1$
ok.setReturnCode(Messages.getString("Evaluator.schemaNotExist", catName), false);
return ok;
}
// ~
// ADD xqliu 2010-01-06 bug 10919
EObject container = schema.eContainer();
if (container != null) {
Catalog catalog = SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
if (catalog != null) {
catName = catalog.getName();
// MOD gdbu 2011-4-21 bug : 20578
if (!ConnectionUtils.isOdbcProgress(connection) && !ConnectionUtils.isOdbcOracle(connection) && StringUtils.isNotEmpty(catName) && dbms().supportCatalogSelection()) {
connection.setCatalog(catName);
}
// ~20578
}
}
// ~
evalSchemaIndicLow(null, schemaIndicator, null, schema, ok);
}
return ok;
}
Aggregations