Search in sources :

Example 16 with AnalysisContext

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();
}
Also used : ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 17 with AnalysisContext

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;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult)

Example 18 with AnalysisContext

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;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 19 with AnalysisContext

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);
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) URL(java.net.URL) Test(org.junit.Test)

Example 20 with AnalysisContext

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);
}
Also used : TdTable(org.talend.cwm.relational.TdTable) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Catalog(orgomg.cwm.resource.relational.Catalog) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Before(org.junit.Before)

Aggregations

AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)40 Analysis (org.talend.dataquality.analysis.Analysis)30 Test (org.junit.Test)17 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)15 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)13 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)13 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 TdColumn (org.talend.cwm.relational.TdColumn)11 TdTable (org.talend.cwm.relational.TdTable)11 ArrayList (java.util.ArrayList)9 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)8 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)7 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)7 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)7 DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 IPath (org.eclipse.core.runtime.IPath)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Property (org.talend.core.model.properties.Property)6 TdExpression (org.talend.cwm.relational.TdExpression)6