Search in sources :

Example 11 with SimpleStatIndicator

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

the class ModelElementAnalysisHandlerTest method testInitializeIndicator.

/**
 * Test method for
 * {@link org.talend.dq.analysis.ModelElementAnalysisHandler#initializeIndicator(org.talend.dataquality.indicators.Indicator)}
 * .
 */
@Test
public void testInitializeIndicator() {
    Pattern pattern = PatternFactory.eINSTANCE.createPattern();
    // $NON-NLS-1$
    pattern.setName("old name");
    // give a pattern indicator in the analysis result, which name is different with its pattern's name
    SqlPatternMatchingIndicator patternMatchingIndicator = PatternIndicatorFactory.createSqlPatternMatchingIndicator(pattern);
    patternMatchingIndicator.setIndicatorDefinition(DefinitionFactory.eINSTANCE.createIndicatorDefinition());
    // $NON-NLS-1$
    pattern.setName("new name");
    // $NON-NLS-1$
    assertEquals("old name", patternMatchingIndicator.getName());
    // if the pattern's name is changed, then this method should use the newest name for the pattern indicator.
    maHandler.initializeIndicator(patternMatchingIndicator);
    // $NON-NLS-1$
    assertEquals("new name", patternMatchingIndicator.getName());
    // user indicator
    Indicator userIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
    // $NON-NLS-1$
    userIndicator.setName("indicator name");
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // $NON-NLS-1$
    indicatorDefinition.setName("definition name");
    userIndicator.setIndicatorDefinition(indicatorDefinition);
    // $NON-NLS-1$
    assertEquals("indicator name", userIndicator.getName());
    // if the udi's name is changed, then this method should use the newest name for the udi.
    maHandler.initializeIndicator(userIndicator);
    // $NON-NLS-1$
    assertEquals("definition name", userIndicator.getName());
    // should not effect system indicators
    SimpleStatIndicator simpleStatIndicator = ColumnsetFactory.eINSTANCE.createSimpleStatIndicator();
    // $NON-NLS-1$
    simpleStatIndicator.setName("simple stat");
    simpleStatIndicator.setIndicatorDefinition(indicatorDefinition);
    assertNotSame(indicatorDefinition.getName(), simpleStatIndicator.getName());
    maHandler.initializeIndicator(simpleStatIndicator);
    assertNotSame(indicatorDefinition.getName(), simpleStatIndicator.getName());
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) SqlPatternMatchingIndicator(org.talend.dataquality.indicators.SqlPatternMatchingIndicator) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) Indicator(org.talend.dataquality.indicators.Indicator) SqlPatternMatchingIndicator(org.talend.dataquality.indicators.SqlPatternMatchingIndicator) Test(org.junit.Test)

Example 12 with SimpleStatIndicator

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

the class WorkbenchUtils method impactExistingAnalyses.

/**
 * DOC qiongli TDQ-3317:move this method from ReloadDatabaseAction. to this class .
 *
 * @param oldDataProvider
 * @throws PartInitException
 */
public static void impactExistingAnalyses(DataProvider oldDataProvider) throws PartInitException {
    EList<Dependency> clientDependencies = oldDataProvider.getSupplierDependency();
    List<Analysis> unsynedAnalyses = new ArrayList<Analysis>();
    for (Dependency dep : clientDependencies) {
        for (ModelElement mod : dep.getClient()) {
            // MOD mzhao 2009-08-24 The dependencies include "Property" and "Analysis"
            if (!(mod instanceof Analysis)) {
                continue;
            }
            Analysis ana = (Analysis) mod;
            unsynedAnalyses.add(ana);
        }
        for (Analysis analysis : unsynedAnalyses) {
            // Reload.
            IFile file = getTempAnalysisFile(analysis);
            Analysis tempAnalysis = (Analysis) AnaResourceFileHelper.getInstance().getModelElement(file);
            // MOD qiongli 2010-8-17,bug 14977
            if (tempAnalysis != null) {
                Resource eResource = tempAnalysis.eResource();
                Map<EObject, Collection<Setting>> referenceMaps = EcoreUtil.UnresolvedProxyCrossReferencer.find(eResource);
                Iterator<EObject> it = referenceMaps.keySet().iterator();
                ModelElement eobj = null;
                boolean isModified = false;
                while (it.hasNext()) {
                    eobj = (ModelElement) it.next();
                    Collection<Setting> settings = referenceMaps.get(eobj);
                    for (Setting setting : settings) {
                        if (setting.getEObject() instanceof AnalysisContext) {
                            tempAnalysis.getContext().getAnalysedElements().remove(eobj);
                            isModified = true;
                        } else if (setting.getEObject() instanceof Indicator) {
                            // the only indicator in the column set analysis. (Added TDQ-8842 20140512 yyin)
                            if (AnalysisType.COLUMN_SET.equals(tempAnalysis.getParameters().getAnalysisType())) {
                                // ~
                                ((SimpleStatIndicator) setting.getEObject()).getAnalyzedColumns().remove(eobj);
                            } else {
                                tempAnalysis.getResults().getIndicators().remove(setting.getEObject());
                            }
                            isModified = true;
                        }
                    }
                }
                if (isModified) {
                    saveTempAnalysis(file, tempAnalysis);
                }
                // Should reopen this analyis's editor if it is opened now. what ever it is modified or not.
                EventManager.getInstance().publish(tempAnalysis.getName(), EventEnum.DQ_ANALYSIS_REOPEN_EDITOR, null);
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) Dependency(orgomg.cwm.objectmodel.core.Dependency) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Indicator(org.talend.dataquality.indicators.Indicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) EObject(org.eclipse.emf.ecore.EObject) Collection(java.util.Collection) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator)

Example 13 with SimpleStatIndicator

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

the class ColumnSetAnalysisHandler method getSimpleStatIndicator.

/**
 * Method "getIndicators".
 *
 * @param column
 * @return the indicators attached to this column
 */
public Indicator getSimpleStatIndicator() {
    Indicator indicator = null;
    EList<Indicator> allIndics = analysis.getResults().getIndicators();
    for (Indicator indic : allIndics) {
        if (indic != null && indic instanceof SimpleStatIndicator) {
            indicator = indic;
            break;
        }
    }
    return indicator;
}
Also used : SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) 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)

Aggregations

SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ArrayList (java.util.ArrayList)8 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)8 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)5 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)4 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)4 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)4 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)4 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)3 TdColumn (org.talend.cwm.relational.TdColumn)3 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)3 EObject (org.eclipse.emf.ecore.EObject)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 Analysis (org.talend.dataquality.analysis.Analysis)2 AnalyzedDataSet (org.talend.dataquality.analysis.AnalyzedDataSet)2 DatePatternFreqIndicator (org.talend.dataquality.indicators.DatePatternFreqIndicator)2 LengthIndicator (org.talend.dataquality.indicators.LengthIndicator)2