Search in sources :

Example 1 with ColumnSetAnalysisHandler

use of org.talend.dq.analysis.ColumnSetAnalysisHandler in project tdq-studio-se by Talend.

the class ColumnSetAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    columnSetAnalysisHandler = new ColumnSetAnalysisHandler();
    columnSetAnalysisHandler.setAnalysis(getCurrentModelElement());
    stringDataFilter = columnSetAnalysisHandler.getStringDataFilter();
    analyzedColumns = columnSetAnalysisHandler.getAnalyzedColumns();
    if (columnSetAnalysisHandler.getSimpleStatIndicator() == null || columnSetAnalysisHandler.getSimpleStatIndicator().eIsProxy()) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        simpleStatIndicator = columnsetFactory.createSimpleStatIndicator();
        simpleStatIndicator.setRowCountIndicator(IndicatorsFactory.eINSTANCE.createRowCountIndicator());
        simpleStatIndicator.setDistinctCountIndicator(IndicatorsFactory.eINSTANCE.createDistinctCountIndicator());
        simpleStatIndicator.setDuplicateCountIndicator(IndicatorsFactory.eINSTANCE.createDuplicateCountIndicator());
        simpleStatIndicator.setUniqueCountIndicator(IndicatorsFactory.eINSTANCE.createUniqueCountIndicator());
    } else {
        simpleStatIndicator = (SimpleStatIndicator) columnSetAnalysisHandler.getSimpleStatIndicator();
    }
    if (columnSetAnalysisHandler.getAllmatchIndicator() == null) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        allMatchIndicator = columnsetFactory.createAllMatchIndicator();
        DefinitionHandler.getInstance().setDefaultIndicatorDefinition(allMatchIndicator);
    } else {
        allMatchIndicator = (AllMatchIndicator) columnSetAnalysisHandler.getAllmatchIndicator();
    }
    initializeIndicator(simpleStatIndicator);
    List<ModelElementIndicator> meIndicatorList = new ArrayList<ModelElementIndicator>();
    ModelElementIndicator currentIndicator = null;
    for (ModelElement element : analyzedColumns) {
        // MOD yyi 2011-02-16 17871:delimitefile
        MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(element);
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null && mdColumn == null) {
            continue;
        }
        if (tdColumn == null && mdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createDFColumnIndicator(RepositoryNodeHelper.recursiveFind(mdColumn));
        } else if (tdColumn != null) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(tdColumn);
            if (recursiveFind == null) {
                recursiveFind = RepositoryNodeHelper.createRepositoryNode(tdColumn);
            }
            currentIndicator = ModelElementIndicatorHelper.createModelElementIndicator(recursiveFind);
        }
        DataminingType dataminingType = MetadataHelper.getDataminingType(element);
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, element);
        Collection<Indicator> indicatorList = columnSetAnalysisHandler.getRegexMathingIndicators(element);
        if (null != currentIndicator) {
            currentIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
            meIndicatorList.add(currentIndicator);
        }
    }
    currentModelElementIndicators = meIndicatorList.toArray(new ModelElementIndicator[meIndicatorList.size()]);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ColumnSetAnalysisHandler(org.talend.dq.analysis.ColumnSetAnalysisHandler) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

ArrayList (java.util.ArrayList)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 TdColumn (org.talend.cwm.relational.TdColumn)1 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)1 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)1 DataminingType (org.talend.dataquality.indicators.DataminingType)1 Indicator (org.talend.dataquality.indicators.Indicator)1 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)1 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)1 ColumnsetFactory (org.talend.dataquality.indicators.columnset.ColumnsetFactory)1 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)1 ColumnSetAnalysisHandler (org.talend.dq.analysis.ColumnSetAnalysisHandler)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1