use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class DbmsLanguageFactory method createDbmsLanguage.
/**
* Method "createDbmsLanguage".
*
* @param analysis
* @return the dbms language associated to the connection of the given analysis or a default one.
*/
public static DbmsLanguage createDbmsLanguage(Analysis analysis, ExecutionLanguage... exeLanguage) {
final AnalysisContext context = analysis.getContext();
ExecutionLanguage theLanguage = null;
if (exeLanguage != null && exeLanguage.length > 0) {
theLanguage = exeLanguage[0];
} else {
theLanguage = analysis.getParameters().getExecutionLanguage();
}
if (theLanguage == ExecutionLanguage.JAVA) {
return createDbmsLanguage(SupportDBUrlType.JAVADEFAULTURL);
}
if (context != null) {
final DataManager dm = context.getConnection();
if (dm != null) {
return createDbmsLanguage(dm);
}
}
return new DbmsLanguage();
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class AnalysisExecutorHelper method check.
/**
* Method "check" checks that the analysis can be run.
*
* @param analysis the analysis to prepare
* @return true if ok.
*/
public static ReturnCode check(Analysis analysis) {
ReturnCode rc = new ReturnCode(Boolean.TRUE);
// --- check existence of context
AnalysisContext context = analysis.getContext();
if (context == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.ContextNull", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check that there exists at least on element to analyze
if (context.getAnalysedElements().size() == 0) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("ColumnAnalysisExecutor.AnalysisHaveAtLeastOneColumn"));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check that the connection has been set
DataManager connection = context.getConnection();
if (connection == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.NoConnectionFound", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
if (log.isInfoEnabled()) {
if (SoftwaredeploymentPackage.eINSTANCE.getDataProvider().isInstance(connection)) {
// MOD 20130225 TDQ-6632 the name of the item should be given (not the pathname)
// $NON-NLS-1$
log.info(Messages.getString("AnalysisExecutor.CONNECTIONTO", connection.getName()));
}
}
AnalysisResult results = analysis.getResults();
if (results == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.AnalysisnotNotPrepareCorrect", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check the the dependeny files are exists ADDED mzhao TDQ-10428---
rc = checkDependentFiles(analysis);
return rc;
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createAndInitAnalysis.
public static Analysis createAndInitAnalysis() {
Analysis ana = UnitTestBuildHelper.createRealAnalysis("anaA", null, false);
AnalysisParameters parameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
parameters.setExecutionLanguage(ExecutionLanguage.SQL);
ana.setParameters(parameters);
AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
ana.setContext(context);
Connection createConnection = ConnectionFactory.eINSTANCE.createConnection();
createConnection.setName("MySQL");
context.setConnection(createConnection);
return ana;
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class MatchAnalysisExecutorTest method testExecute.
/**
* Test method for
* {@link org.talend.dq.analysis.MatchAnalysisExecutor#execute(org.talend.dataquality.analysis.Analysis)}.
*/
@SuppressWarnings("nls")
@Test
public void testExecute() {
MatchAnalysisExecutor matchAnalysisExecutor = new MatchAnalysisExecutor();
Analysis analysis = AnalysisPackage.eINSTANCE.getAnalysisFactory().createAnalysis();
AnalysisContext context = AnalysisPackage.eINSTANCE.getAnalysisFactory().createAnalysisContext();
analysis.setContext(context);
AnalysisParameters params = AnalysisPackage.eINSTANCE.getAnalysisFactory().createAnalysisParameters();
analysis.setParameters(params);
TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.PREVIEW_ROW_NUMBER, String.valueOf(100));
// analysisResult.setAnalysis(analysis);
context.setConnection(delimitedFileconnection);
// $NON-NLS-1$
URL fileUrl = this.getClass().getResource("match_test_data");
metadataTable = UnitTestBuildHelper.getDefault().initFileConnection(fileUrl, delimitedFileconnection);
this.name = UnitTestBuildHelper.getDefault().initColumns(context, this.metadataTable);
// Scenario 1
// - Match key: name, no block key, levenshtein attribute algorithm. groupQualityThreshold = 0.9d, matchInterval
// = 0.95d .
double groupQualityThreshold = 0.9d;
double matchInterval = 0.95d;
assertScenario1(matchAnalysisExecutor, analysis, name, "name", groupQualityThreshold, matchInterval);
// Scenario 2
// - Same to scenario 1, EXCEPT matchInterval = 0.8d .
matchInterval = 0.8d;
assertScenario2(matchAnalysisExecutor, analysis, name, "name", groupQualityThreshold, matchInterval);
// Scenario 3
// - Same to scenario 2, EXCEPT groupQualityThreshold = 0.95d.
groupQualityThreshold = 0.95d;
assertScenario3(matchAnalysisExecutor, analysis, name, "name", groupQualityThreshold, matchInterval);
// Scenario 4
// - Same to scenario 3, EXCEPT a new blocking key = country.
assertScenario4(matchAnalysisExecutor, analysis, name, "name", groupQualityThreshold, matchInterval);
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutorTest method setUp.
/**
* DOC xqliu Comment method "setUp".
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// create TdTable
TdTable testTdTable = RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
testTdTable.setName("generateTable");
// create connection
DatabaseConnection testDatabaseConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
TaggedValueHelper.setTaggedValue(testDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.MYSQLDEFAULTURL.getDBKey());
// create catalog
Catalog testCatalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
// $NON-NLS-1$
testCatalog.setName("TBI");
testTdTable.setNamespace(testCatalog);
testCatalog.setNamespace(testDatabaseConnection);
testCatalog.getDataManager().add(testDatabaseConnection);
// create analysis
testAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
// create Analaysis result
AnalysisResult testAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
testAnalysis.setResults(testAnalysisResult);
// create analysis parameter
AnalysisParameters testAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
testAnalysis.setParameters(testAnalysisParameters);
// create analysis Content
AnalysisContext testAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
testAnalysis.setContext(testAnalysisContext);
testAnalysisContext.setConnection(testDatabaseConnection);
// create WhereRuleAide indicatorDefinition
testWhereRuleIndicatorDefinition = RulesFactory.eINSTANCE.createWhereRule();
// $NON-NLS-1$
testWhereRuleIndicatorDefinition.setLabel("rule1");
// create WhereRule indicator
testWhereRuleIndicator = IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
testAnalysisResult.getIndicators().add(testWhereRuleIndicator);
testWhereRuleIndicator.setAnalyzedElement(testTdTable);
testWhereRuleIndicator.setIndicatorDefinition(testWhereRuleIndicatorDefinition);
}
Aggregations