Search in sources :

Example 11 with AnalysisResult

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

the class SQLPatternExplorerTest method setUp.

/**
 * DOC msjian Comment method "setUp".
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    UnitTestBuildHelper.initProjectStructure();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
        ITDQItemService tdqService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
        tdqService.createDQStructor();
    }
    sqlPatternExplorer = new SQLPatternExplorer();
    // mock setEntity
    SqlPatternMatchingIndicator indicator = creatSqlPatternMatchingIndicator();
    Analysis ana = UnitTestBuildHelper.createAndInitAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    createAnalysisResult.getIndicators().add(indicator);
    ana.setResults(createAnalysisResult);
    sqlPatternExplorer.setAnalysis(ana);
    // $NON-NLS-1$  //$NON-NLS-2$
    ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, "name1", "1");
    chartDataEntity.setLabelNull(false);
    // $NON-NLS-1$
    chartDataEntity.setKey("name1");
    sqlPatternExplorer.setEnitty(chartDataEntity);
    IndicatorDefinition definition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
    expression.setBody("SELECT * FROM tbi.customer ");
    // $NON-NLS-1$
    expression.setLanguage("SQL");
    definition.getSqlGenericExpression().add(expression);
    indicator.setIndicatorDefinition(definition);
    indicator.getInstantiatedExpressions().add(expression);
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) TdExpression(org.talend.cwm.relational.TdExpression) Analysis(org.talend.dataquality.analysis.Analysis) SqlPatternMatchingIndicator(org.talend.dataquality.indicators.SqlPatternMatchingIndicator) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) ITDQItemService(org.talend.core.ITDQItemService) Before(org.junit.Before)

Example 12 with AnalysisResult

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

the class ResourceViewLabelProviderTest method createAnalysis.

private void createAnalysis(String name, IPath createPath, Boolean isDelete) {
    Analysis analysis1 = AnalysisHelper.createAnalysis(name);
    TDQAnalysisItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(analysis1.getName());
    item1.setProperty(property1);
    item1.setAnalysis(analysis1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis1.setResults(analysisResult1);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 13 with AnalysisResult

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

the class ColumnSetIndicatorEvaluator method executeSqlQuery.

@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
    ReturnCode ok = new ReturnCode(true);
    AnalysisResult anaResult = analysis.getResults();
    EMap<Indicator, AnalyzedDataSet> indicToRowMap = anaResult.getIndicToRowMap();
    indicToRowMap.clear();
    if (isDelimitedFile) {
        ok = evaluateByDelimitedFile(sqlStatement, ok);
    } else {
        ok = evaluateBySql(sqlStatement, ok);
    }
    return ok;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 14 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult 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 15 with AnalysisResult

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

the class FrequencyTypeStateUtil method isWithRowCountIndicator.

public static boolean isWithRowCountIndicator(Indicator indicator) {
    ModelElement currentAnalyzedElement = indicator.getAnalyzedElement();
    InternalEObject eIndicator = (InternalEObject) indicator;
    AnalysisResult result = (AnalysisResult) eIndicator.eContainer();
    // MOD msjian TDQ-5960: fix a NPE
    if (result == null) {
        return false;
    }
    EList<Indicator> indicators = result.getIndicators();
    if (indicators != null) {
        for (Indicator indi : indicators) {
            ModelElement analyzedElement = indi.getAnalyzedElement();
            if (analyzedElement == currentAnalyzedElement) {
                if (indi instanceof RowCountIndicator) {
                    return true;
                } else if (indi instanceof CountsIndicator) {
                    CountsIndicator cindi = (CountsIndicator) indi;
                    return cindi.getRowCountIndicator() != null;
                }
            }
        }
    }
    return false;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) InternalEObject(org.eclipse.emf.ecore.InternalEObject) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) BenfordLawFrequencyIndicator(org.talend.dataquality.indicators.BenfordLawFrequencyIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

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