Search in sources :

Example 6 with AllMatchIndicator

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

the class ColumnSetAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    columnSetAnalysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    columnSetAnalysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    // columnSetAnalysisHandler.setName(columnSetAnalysisHandler.getName().replace(" ", ""));
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    // ~
    columnSetAnalysisHandler.clearAnalysis();
    simpleStatIndicator.getAnalyzedColumns().clear();
    allMatchIndicator.getAnalyzedColumns().clear();
    // set execute engine
    Analysis analysis = columnSetAnalysisHandler.getAnalysis();
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // set data filter
    columnSetAnalysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // save analysis
    List<IRepositoryNode> repositoryNodes = treeViewer.getColumnSetMultiValueList();
    Connection tdProvider = null;
    IRepositoryViewObject reposObject = null;
    if (repositoryNodes != null && repositoryNodes.size() != 0) {
        ConnectionItem item = (ConnectionItem) repositoryNodes.get(0).getObject().getProperty().getItem();
        tdProvider = item.getConnection();
        if (tdProvider.eIsProxy()) {
            // Resolve the connection again
            tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
        }
        analysis.getContext().setConnection(tdProvider);
        List<ModelElement> columnList = new ArrayList<ModelElement>();
        for (IRepositoryNode rd : repositoryNodes) {
            reposObject = rd.getObject();
            columnList.add(((MetadataColumnRepositoryObject) reposObject).getTdColumn());
        }
        simpleStatIndicator.getAnalyzedColumns().addAll(columnList);
        columnSetAnalysisHandler.addIndicator(columnList, simpleStatIndicator);
        // ~ MOD mzhao feature 13040. 2010-05-21
        allMatchIndicator.getCompositeRegexMatchingIndicators().clear();
        ModelElementIndicator[] modelElementIndicator = treeViewer.getModelElementIndicator();
        if (modelElementIndicator != null) {
            for (ModelElementIndicator modelElementInd : modelElementIndicator) {
                Indicator[] inds = modelElementInd.getPatternIndicators();
                for (Indicator ind : inds) {
                    if (ind instanceof RegexpMatchingIndicator) {
                        // MOD yyi 2011-06-15 22419:column set pattern for MDM
                        IRepositoryViewObject obj = modelElementInd.getModelElementRepositoryNode().getObject();
                        ModelElement analyzedElt = ((MetadataColumnRepositoryObject) obj).getTdColumn();
                        ind.setAnalyzedElement(analyzedElt);
                        allMatchIndicator.getCompositeRegexMatchingIndicators().add((RegexpMatchingIndicator) ind);
                    }
                }
            }
        }
        if (allMatchIndicator.getCompositeRegexMatchingIndicators().size() > 0) {
            allMatchIndicator.getAnalyzedColumns().addAll(columnList);
            columnSetAnalysisHandler.addIndicator(columnList, allMatchIndicator);
        }
    // ~
    } else {
        analysis.getContext().setConnection(null);
    }
    TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
    // 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(columnSetAnalysisHandler.getName());
    // TDQ-5581,if has removed emlements(patten),should remove dependency each other before saving.
    // 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) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) 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) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 7 with AllMatchIndicator

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

the class ColumnSetAnalysisHandler method getRegexMathingIndicators.

public Collection<Indicator> getRegexMathingIndicators(ModelElement modelElement) {
    Collection<Indicator> indics = new ArrayList<Indicator>();
    EList<Indicator> allIndics = analysis.getResults().getIndicators();
    for (Indicator indicator : allIndics) {
        if (indicator instanceof AllMatchIndicator) {
            AllMatchIndicator allMatchInd = (AllMatchIndicator) indicator;
            for (Indicator regexInd : allMatchInd.getCompositeRegexMatchingIndicators()) {
                if (regexInd.getAnalyzedElement() != null && regexInd.getAnalyzedElement().equals(modelElement)) {
                    indics.add(regexInd);
                }
            }
            break;
        }
    }
    return indics;
}
Also used : AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ArrayList(java.util.ArrayList) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 8 with AllMatchIndicator

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

the class ColumnSetAnalysisHandler method getAllmatchIndicator.

/**
 * DOC mzhao get AllMetchIndicator.
 *
 * @return
 */
public Indicator getAllmatchIndicator() {
    Indicator indicator = null;
    EList<Indicator> allIndics = analysis.getResults().getIndicators();
    for (Indicator indic : allIndics) {
        if (indic != null && indic instanceof AllMatchIndicator) {
            indicator = indic;
            break;
        }
    }
    return indicator;
}
Also used : AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 9 with AllMatchIndicator

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

the class DataExplorer method getAnalyzedElementName.

/**
 * Add qiongli handle ColumnSetMultiValueIndicator.
 *
 * @return
 */
protected String getAnalyzedElementName(Indicator ind) {
    if (ind.getAnalyzedElement() != null) {
        return dbmsLanguage.quote(ind.getAnalyzedElement().getName());
    }
    StringBuffer name = new StringBuffer(PluginConstant.EMPTY_STRING);
    EObject object = ind.eContainer();
    EList<ModelElement> eLs = null;
    if (object != null && object instanceof ColumnSetMultiValueIndicator) {
        eLs = ((ColumnSetMultiValueIndicator) object).getAnalyzedColumns();
    } else if (ind instanceof AllMatchIndicator) {
        eLs = ((AllMatchIndicator) ind).getAnalyzedColumns();
    }
    if (eLs != null && !eLs.isEmpty()) {
        for (ModelElement mColumn : eLs) {
            // $NON-NLS-1$
            name.append(dbmsLanguage.quote(mColumn.getName())).append(",");
        }
        if (eLs.size() > 0) {
            // $NON-NLS-1$
            return org.apache.commons.lang.StringUtils.removeEnd(name.toString(), ",");
        }
    }
    return name.toString();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) EObject(org.eclipse.emf.ecore.EObject) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator)

Example 10 with AllMatchIndicator

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

the class AnalysisHelper method getPatterns.

public static List<Pattern> getPatterns(Analysis analysis) {
    List<Pattern> rets = new ArrayList<Pattern>();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        if (indicator instanceof PatternMatchingIndicator) {
            IndicatorParameters parameters = ((PatternMatchingIndicator) indicator).getParameters();
            if (null != parameters && null != parameters.getDataValidDomain()) {
                rets.addAll(parameters.getDataValidDomain().getPatterns());
            }
        }
        // MOD yyi 2010-08-03 14292 Add dependency for children indicator in Column Set analysis
        if (indicator instanceof AllMatchIndicator) {
            EList<RegexpMatchingIndicator> list = ((AllMatchIndicator) indicator).getCompositeRegexMatchingIndicators();
            for (RegexpMatchingIndicator pattern : list) {
                IndicatorParameters parameters = pattern.getParameters();
                if (null != parameters && null != parameters.getDataValidDomain()) {
                    rets.addAll(parameters.getDataValidDomain().getPatterns());
                }
            }
        }
    // ~
    }
    return rets;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Aggregations

AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)11 Indicator (org.talend.dataquality.indicators.Indicator)10 ArrayList (java.util.ArrayList)7 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)7 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)6 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)5 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 Pattern (org.talend.dataquality.domain.pattern.Pattern)3 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)3 Analysis (org.talend.dataquality.analysis.Analysis)2 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)2 ColumnSetMultiValueIndicator (org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 HashMap (java.util.HashMap)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 BusinessException (org.talend.commons.exception.BusinessException)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1