use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class IndicatorHelper method getIndicatorLeaves.
/**
* This method only used when running analysis. it get RowCountIndicator from RowCountIndicatorsAdapter.
*
* @param result
* @return all the leaf indicators
*/
public static List<Indicator> getIndicatorLeaves(AnalysisResult result) {
List<Indicator> leafIndicators = new ArrayList<>();
EList<Indicator> indicators = result.getIndicators();
RowCountIndicatorsAdapter.getInstance().clear();
for (Indicator indicator : indicators) {
for (Indicator indi : getIndicatorLeaves(indicator)) {
if (!leafIndicators.contains(indi)) {
leafIndicators.add(indi);
}
}
}
return leafIndicators;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class IndicatorHelper method getRowCountIndicator.
/**
* DOC scorreia Comment method "getRowCountIndicator".
*
* @param modelElement
* @param elementToIndicator
* @return
*/
public static RowCountIndicator getRowCountIndicator(ModelElement modelElement, Map<ModelElement, List<Indicator>> elementToIndicator) {
List<Indicator> list = elementToIndicator.get(modelElement);
RowCountIndicator rowCountIndicator = null;
if (list == null) {
return rowCountIndicator;
}
for (Indicator indicator : list) {
if (IndicatorsPackage.eINSTANCE.getRowCountIndicator().equals(indicator.eClass())) {
rowCountIndicator = (RowCountIndicator) indicator;
break;
}
}
return rowCountIndicator;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class AnalysisHelper method getUserDefinedIndicators.
public static List<IndicatorDefinition> getUserDefinedIndicators(Analysis analysis) {
List<IndicatorDefinition> rets = new ArrayList<IndicatorDefinition>();
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
if (indicator instanceof UserDefIndicator) {
rets.add(indicator.getIndicatorDefinition());
}
}
return rets;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class UDIHelper method updateJUDIsForAnalysis.
/**
* check all the indicators, convert common udi to a Java UDI if needed.
*
* @param analysis
*/
public static void updateJUDIsForAnalysis(Analysis analysis) {
EList<Indicator> allIndics = analysis.getResults().getIndicators();
List<Indicator> updatedIndWithJUDI = new ArrayList<Indicator>();
for (Indicator indicator : allIndics) {
// MOD TDQ-8177 sizhaoliu update only the UDIs
if (UDIHelper.isUDI(indicator) && UDIHelper.needUpdateJUDI(indicator)) {
try {
indicator = UDIHelper.adaptToJavaUDI(indicator);
} catch (Throwable e) {
ExceptionHandler.process(e);
}
}
updatedIndWithJUDI.add(indicator);
}
allIndics.clear();
allIndics.addAll(updatedIndWithJUDI);
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class UDIHelper method adaptToJavaUDI.
/**
* DOC mzhao feature 11128, If the execute engine and by the same time Java User Defined Indicator is also defined,
* then compute via Java UDI, here convert common udi to a Java UDI.
*
* @param udi
* @return
* @throws Exception
*/
public static Indicator adaptToJavaUDI(Indicator indicator) throws Throwable {
Indicator returnIndicator = getUDIFromMap(indicator);
if (returnIndicator != null) {
return returnIndicator;
}
UserDefIndicator adaptedUDI = null;
if (userDefIndSwitch.doSwitch(indicator) != null) {
EList<TaggedValue> taggedValues = indicator.getIndicatorDefinition().getTaggedValue();
String userJavaClassName = null;
String jarPath = null;
for (TaggedValue tv : taggedValues) {
if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
userJavaClassName = tv.getValue();
continue;
}
if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
jarPath = tv.getValue();
}
}
// MOD by zshen for feature 18724
if (validateJavaUDI(userJavaClassName, jarPath)) {
List<URL> jarUrls = new ArrayList<URL>();
for (File file : getContainJarFile(jarPath)) {
jarUrls.add(file.toURI().toURL());
}
TalendURLClassLoader cl;
// Note that the 2nd parameter (classloader) is needed to load class UserDefinitionIndicator from
// org.talend.dataquality plugin.
cl = new TalendURLClassLoader(jarUrls.toArray(new URL[jarUrls.size()]), UDIHelper.class.getClassLoader());
Class<?> clazz = null;
clazz = cl.findClass(userJavaClassName);
if (clazz != null) {
// MOD yyin 20121012 TDQ-6259
UserDefIndicator judi = (UserDefIndicator) clazz.newInstance();
// judi.setIndicatorDefinition(indicator.getIndicatorDefinition());
PropertyUtils.copyProperties(judi, indicator);
// judi.setAnalyzedElement(indicator.getAnalyzedElement());
adaptedUDI = judi;
JAVAUDIMAP.put(indicator, adaptedUDI);
}
}
}
return adaptedUDI;
}
Aggregations