Search in sources :

Example 1 with ColumnsetFactory

use of org.talend.dataquality.indicators.columnset.ColumnsetFactory in project tdq-studio-se by Talend.

the class RedundancyAnalysisDetailsPage method initialize.

@Override
public void initialize(FormEditor editor) {
    super.initialize(editor);
    // MOD xqliu 2009-06-10 bug7334
    stringDataFilterA = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 0);
    stringDataFilterB = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 1);
    // ~
    if (getCurrentModelElement().getResults().getIndicators().size() == 0) {
        ColumnsetFactory factory = ColumnsetFactory.eINSTANCE;
        rowMatchingIndicatorA = factory.createRowMatchingIndicator();
        rowMatchingIndicatorB = factory.createRowMatchingIndicator();
        Indicator[] currentIndicators = new Indicator[] { rowMatchingIndicatorA, rowMatchingIndicatorB };
        setDefaultIndDef(currentIndicators);
    } else {
        EList<Indicator> indicators = getCurrentModelElement().getResults().getIndicators();
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
    }
}
Also used : ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 2 with ColumnsetFactory

use of org.talend.dataquality.indicators.columnset.ColumnsetFactory 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)

Example 3 with ColumnsetFactory

use of org.talend.dataquality.indicators.columnset.ColumnsetFactory in project tdq-studio-se by Talend.

the class CorrelationAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    correlationAnalysisHandler = new ColumnCorrelationAnalysisHandler();
    correlationAnalysisHandler.setAnalysis(getCurrentModelElement());
    stringDataFilter = correlationAnalysisHandler.getStringDataFilter();
    analyzedColumns = correlationAnalysisHandler.getAnalyzedColumns();
    if (correlationAnalysisHandler.getIndicator() == null && columnSetMultiIndicator != null) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        // MOD qiongli 2010-6-18 bug 12766
        if (ColumnsetPackage.eINSTANCE.getCountAvgNullIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createCountAvgNullIndicator();
            // MOD xqliu 2010-04-06 bug 12161
            fillSimpleIndicators(columnSetMultiIndicator);
        // ~12161
        }
        if (ColumnsetPackage.eINSTANCE.getMinMaxDateIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createMinMaxDateIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createWeakCorrelationIndicator();
        }
    } else {
        columnSetMultiIndicator = (ColumnSetMultiValueIndicator) correlationAnalysisHandler.getIndicator();
    }
    if (columnSetMultiIndicator == null) {
        columnSetMultiIndicator = ColumnsetFactory.eINSTANCE.createCountAvgNullIndicator();
    }
    initializeIndicator(columnSetMultiIndicator);
    columnSetMultiIndicator.setStoreData(true);
    for (ModelElement element : analyzedColumns) {
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null) {
            continue;
        }
        // currentColumnIndicator = new ColumnIndicator(tdColumn);
        DataminingType dataminingType = correlationAnalysisHandler.getDatamingType(tdColumn);
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, tdColumn);
    }
}
Also used : ColumnCorrelationAnalysisHandler(org.talend.dq.analysis.ColumnCorrelationAnalysisHandler) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory)

Example 4 with ColumnsetFactory

use of org.talend.dataquality.indicators.columnset.ColumnsetFactory in project tdq-studio-se by Talend.

the class CorrelationAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    IRepositoryViewObject reposObject = null;
    Connection tdProvider = null;
    correlationAnalysisHandler.clearAnalysis();
    columnSetMultiIndicator.getAnalyzedColumns().clear();
    // set execute engine
    Analysis analysis = correlationAnalysisHandler.getAnalysis();
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // set data filter
    correlationAnalysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // save analysis
    List<RepositoryNode> repositoryNodeList = treeViewer.getColumnSetMultiValueList();
    if (repositoryNodeList != null && !repositoryNodeList.isEmpty()) {
        reposObject = repositoryNodeList.get(0).getObject();
        tdProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
        analysis.getContext().setConnection(tdProvider);
        List<TdColumn> columnLst = new ArrayList<TdColumn>();
        for (RepositoryNode repNode : repositoryNodeList) {
            columnLst.add((TdColumn) ((MetadataColumnRepositoryObject) repNode.getObject()).getTdColumn());
        }
        columnSetMultiIndicator.getAnalyzedColumns().addAll(columnLst);
        correlationAnalysisHandler.addIndicator(columnLst, columnSetMultiIndicator);
    } else {
        analysis.getContext().setConnection(null);
        // MOD by zshen for bug 12042.
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        ColumnSetMultiValueIndicator columnSetMultiValueIndicator = null;
        if (ColumnsetPackage.eINSTANCE.getCountAvgNullIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createCountAvgNullIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getMinMaxDateIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createMinMaxDateIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createWeakCorrelationIndicator();
        }
        fillSimpleIndicators(columnSetMultiValueIndicator);
        analysis.getResults().getIndicators().add(columnSetMultiValueIndicator);
    // ~12042
    }
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    // 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
    this.nameText.setText(analysis.getName());
    // ~
    // MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
    ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
    // MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
    // which is depended in the referred connection.
    // Extract saving log function.
    // @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
    logSaved(saved);
    treeViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) TdColumn(org.talend.cwm.relational.TdColumn) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain)

Aggregations

ColumnsetFactory (org.talend.dataquality.indicators.columnset.ColumnsetFactory)4 TdColumn (org.talend.cwm.relational.TdColumn)3 ArrayList (java.util.ArrayList)2 DataminingType (org.talend.dataquality.indicators.DataminingType)2 Indicator (org.talend.dataquality.indicators.Indicator)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)1 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)1 Analysis (org.talend.dataquality.analysis.Analysis)1 Domain (org.talend.dataquality.domain.Domain)1 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)1 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)1 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)1 ColumnSetMultiValueIndicator (org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator)1 RowMatchingIndicator (org.talend.dataquality.indicators.columnset.RowMatchingIndicator)1