Search in sources :

Example 31 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.

the class ItemRecordTest method createAnalysis.

private Property createAnalysis(String name) throws PersistenceException {
    // create analysis
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    createAnalysis.setResults(createAnalysisResult);
    createAnalysis.setContext(createAnalysisContext);
    createAnalysis.setName(name);
    // create analysis item
    TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    createTDQAnalysisItem.setAnalysis(createAnalysis);
    Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    createAnalysisProperty.setLabel(name);
    createTDQAnalysisItem.setProperty(createAnalysisProperty);
    createAnalysisProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
    return createAnalysisProperty;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 32 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.

the class AElementPersistanceRealTest method testSaveWithDependenciesAnalysis.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#saveWithDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
 * .
 *
 * @throws PersistenceException
 */
@Test
public void testSaveWithDependenciesAnalysis() throws PersistenceException {
    AnalysisWriter createAnalysisWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
    String anaName = "AElementPersistanceRealTestanalysis5";
    // create analysis
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    createAnalysis.setResults(createAnalysisResult);
    createAnalysis.setContext(createAnalysisContext);
    createAnalysis.setName(anaName);
    // create analysis item
    TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    createTDQAnalysisItem.setAnalysis(createAnalysis);
    Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createAnalysisProperty.setLabel("AElementPersistanceRealTestanalysis5");
    createTDQAnalysisItem.setProperty(createAnalysisProperty);
    createAnalysisProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
    // create pattern match indicator
    WhereRuleIndicator whereRuleIndicator = IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
    // create definition
    createAnalysisResult.getIndicators().add(whereRuleIndicator);
    DQRule dqRule = RulesFactory.eINSTANCE.createWhereRule();
    whereRuleIndicator.setIndicatorDefinition(dqRule);
    TDQBusinessRuleItem createTDQBusinessRuleItem = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
    createTDQBusinessRuleItem.setDqrule(dqRule);
    Property createPatternProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createPatternProperty.setLabel("AElementPersistanceRealTestDQRule5");
    createTDQBusinessRuleItem.setProperty(createPatternProperty);
    createPatternProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQBusinessRuleItem, Path.EMPTY, false);
    // $NON-NLS-1$
    String exceptedFileName = anaName + "_0.1.ana";
    ReturnCode create = createAnalysisWriter.saveWithDependencies(createTDQAnalysisItem, createAnalysis);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName, createTDQAnalysisItem.getFilename());
    // $NON-NLS-1$
    String anaName2 = "ana52";
    // $NON-NLS-1$
    String exceptedFileName2 = anaName2 + "_0.1.ana";
    createAnalysis.setName(anaName2);
    create = createAnalysisWriter.saveWithDependencies(createTDQAnalysisItem, createAnalysis);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName2, createTDQAnalysisItem.getFilename());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) Property(org.talend.core.model.properties.Property) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) DQRule(org.talend.dataquality.rules.DQRule) Test(org.junit.Test)

Example 33 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.

the class ResourceUtils method createAnalysis.

public static Analysis createAnalysis(Indicator indicator) {
    AnalysisParameters createAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    setUUID(null, createAnalysisParameters);
    createAnalysisParameters.setAnalysisType(AnalysisType.MULTIPLE_COLUMN);
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    setUUID(null, createAnalysis);
    AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    setUUID(null, createAnalysisContext);
    // $NON-NLS-1$
    MetadataColumn createMetadataColumn = createMetadataColumn("columnName");
    createAnalysisContext.getAnalysedElements().add(createMetadataColumn);
    createAnalysis.setContext(createAnalysisContext);
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    setUUID(null, createAnalysisResult);
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    setUUID(null, createExecutionInformations);
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    createAnalysisResult.getIndicators().add(indicator);
    indicator.setAnalyzedElement(createMetadataColumn);
    createAnalysis.setResults(createAnalysisResult);
    createAnalysis.setParameters(createAnalysisParameters);
    // $NON-NLS-1$
    createAnalysis.setName("anaName");
    // $NON-NLS-1$
    MetadataHelper.setAuthor(createAnalysis, "shenze");
    createAnalysis.setCreationDate(new Date(System.currentTimeMillis()));
    setUUID(null, indicator);
    return createAnalysis;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Date(java.util.Date)

Example 34 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.

the class ColumnAnalysisSqlExecutor method createSqlStatement.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.analysis.AnalysisExecutor#createSqlStatement(org.talend.dataquality.analysis.Analysis)
     */
@Override
public String createSqlStatement(Analysis analysis) {
    this.cachedAnalysis = analysis;
    AnalysisResult results = analysis.getResults();
    assert results != null;
    try {
        // --- get data filter
        ModelElementAnalysisHandler handler = new ModelElementAnalysisHandler();
        handler.setAnalysis(analysis);
        String stringDataFilter = handler.getStringDataFilter();
        // --- get all the leaf indicators used for the sql computation
        Collection<Indicator> leafIndicators = IndicatorHelper.getIndicatorLeaves(results);
        // --- create one sql statement for each leaf indicator
        for (Indicator indicator : leafIndicators) {
            if (!this.continueRun()) {
                break;
            }
            if (!createSqlQuery(stringDataFilter, indicator)) {
                log.error(Messages.getString("ColumnAnalysisSqlExecutor.CREATEQUERYERROR", // $NON-NLS-1$
                AnalysisExecutorHelper.getIndicatorName(indicator)));
            // return null;
            }
        }
    } catch (AnalysisExecutionException e) {
        log.error(e, e);
        return null;
    }
    return PluginConstant.EMPTY_STRING;
}
Also used : AnalysisExecutionException(org.talend.cwm.exception.AnalysisExecutionException) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 35 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.

the class TableAnalysisSqlExecutor method createSqlStatement.

@Override
protected String createSqlStatement(Analysis analysis) {
    this.cachedAnalysis = analysis;
    AnalysisResult results = analysis.getResults();
    assert results != null;
    try {
        // --- get data filter
        stringDataFilter = ContextHelper.getDataFilterWithoutContext(analysis);
        // --- get all the leaf indicators used for the sql computation
        Collection<Indicator> leafIndicators = IndicatorHelper.getIndicatorLeavesBySingleNode(results);
        // --- create one sql statement for each leaf indicator
        for (Indicator indicator : leafIndicators) {
            if (!createSqlQuery(stringDataFilter, indicator, false)) {
                log.error(Messages.getString("ColumnAnalysisSqlExecutor.CREATEQUERYERROR", // $NON-NLS-1$
                AnalysisExecutorHelper.getIndicatorName(indicator)));
                return null;
            }
        }
    } catch (AnalysisExecutionException e) {
        log.error(e, e);
        return null;
    }
    return PluginConstant.EMPTY_STRING;
}
Also used : AnalysisExecutionException(org.talend.cwm.exception.AnalysisExecutionException) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Indicator(org.talend.dataquality.indicators.Indicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator)

Aggregations

AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)40 Analysis (org.talend.dataquality.analysis.Analysis)26 Test (org.junit.Test)15 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)15 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)14 ExecutionInformations (org.talend.dataquality.analysis.ExecutionInformations)13 Property (org.talend.core.model.properties.Property)11 PersistenceException (org.talend.commons.exception.PersistenceException)10 ItemState (org.talend.core.model.properties.ItemState)10 Path (org.eclipse.core.runtime.Path)8 TdColumn (org.talend.cwm.relational.TdColumn)8 TdTable (org.talend.cwm.relational.TdTable)8 Indicator (org.talend.dataquality.indicators.Indicator)8 IPath (org.eclipse.core.runtime.IPath)7 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)7 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)7 ReturnCode (org.talend.utils.sugars.ReturnCode)7 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)6 Before (org.junit.Before)5 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)4