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());
}
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);
}
}
}
}
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;
}
Aggregations