use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class IndicatorHelper method setDataThresholds.
/**
* DOC scorreia Comment method "setDataThresholds".
*
* @param rangeIndicator
* @param dataThreshold
*/
private static void setDataThresholds(RangeIndicator rangeIndicator, String[] dataThreshold) {
if (rangeIndicator != null) {
IndicatorHelper.setDataThreshold(rangeIndicator, dataThreshold[0], dataThreshold[1]);
MinValueIndicator lowerValue = rangeIndicator.getLowerValue();
// MOD qiongli 2011-11-25,propgate the parameter to children ,convert the dataThreshold to
// IndicatorThreshold for MaxValueIndicator/MinValueIndicator.
IndicatorParameters parameters = rangeIndicator.getParameters();
if (parameters != null) {
if (lowerValue != null) {
IndicatorParameters lowParameters = lowerValue.getParameters();
if (lowParameters == null) {
lowParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
lowerValue.setParameters(lowParameters);
}
IndicatorHelper.setIndicatorThreshold(lowParameters, dataThreshold[0], dataThreshold[1]);
// IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
}
MaxValueIndicator upperValue = rangeIndicator.getUpperValue();
if (upperValue != null) {
IndicatorParameters upperParameters = upperValue.getParameters();
if (upperParameters == null) {
upperParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
upperValue.setParameters(upperParameters);
}
IndicatorHelper.setIndicatorThreshold(upperParameters, dataThreshold[0], dataThreshold[1]);
// IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
}
}
}
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class IndicatorHelper method setDataThreshold.
public static void setDataThreshold(Indicator indicator, String min, String max) {
IndicatorParameters parameters = indicator.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
indicator.setParameters(parameters);
}
setDataThreshold(parameters, min, max);
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class PatternIndicatorFactory method createRegexpMatchingIndicator.
/**
* Method "createRegexpMatchingIndicator".
*
* @param pattern the pattern from which the RegexpMatchingIndicator is created
* @return the new RegexpMatchingIndicator with the same name as the pattern
*/
public static RegexpMatchingIndicator createRegexpMatchingIndicator(Pattern pattern) {
RegexpMatchingIndicator patternMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
Domain validData = DomainFactory.eINSTANCE.createDomain();
validData.getPatterns().add(pattern);
indicParams.setDataValidDomain(validData);
patternMatchingIndicator.setParameters(indicParams);
patternMatchingIndicator.setName(pattern.getName());
return patternMatchingIndicator;
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class PatternIndicatorFactory method createSqlPatternMatchingIndicator.
/**
* Method "createSqlPatternMatchingIndicator".
*
* @param pattern the pattern from which the SqlPatternMatchingIndicator is created
* @return the new SqlPatternMatchingIndicator with the same name as the pattern
*/
public static SqlPatternMatchingIndicator createSqlPatternMatchingIndicator(Pattern pattern) {
SqlPatternMatchingIndicator patternMatchingIndicator = IndicatorsFactory.eINSTANCE.createSqlPatternMatchingIndicator();
IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
Domain validData = DomainFactory.eINSTANCE.createDomain();
validData.getPatterns().add(pattern);
indicParams.setDataValidDomain(validData);
patternMatchingIndicator.setParameters(indicParams);
patternMatchingIndicator.setName(pattern.getName());
return patternMatchingIndicator;
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class EMailValidationIndicator method initParameters.
boolean initParameters() {
// Check prerequisite
IndicatorParameters param = this.getParameters();
if (param == null) {
// $NON-NLS-1$
log.error("No parameter set in the user defined indicator " + this.getName());
return false;
}
Domain indicatorValidDomain = param.getIndicatorValidDomain();
if (indicatorValidDomain == null) {
// $NON-NLS-1$
log.error("No parameter set in the user defined indicator " + this.getName());
return false;
}
// else retrieve email from parameter
EList<JavaUDIIndicatorParameter> javaUDIIndicatorParameter = indicatorValidDomain.getJavaUDIIndicatorParameter();
for (JavaUDIIndicatorParameter p : javaUDIIndicatorParameter) {
if (EMAIL_PARAM.equalsIgnoreCase(p.getKey())) {
this.emailAddress = p.getValue();
} else if (INVALID_PARAM.equalsIgnoreCase(p.getKey())) {
this.storeInvalidData = true;
// TODO add more checks on the file
try {
this.tempInvalidData = new StringBuffer();
this.os = new FileOutputStream(new File(p.getValue()));
} catch (FileNotFoundException e) {
// $NON-NLS-1$
log.error("Invalid file path in the user defined indicator: " + this.getName(), e);
return false;
}
} else if (BUFFER_SIZE_PARAM.equalsIgnoreCase(p.getKey())) {
try {
this.buffSize = Integer.valueOf(p.getValue());
} catch (Exception e) {
// $NON-NLS-1$
log.error("Invalid buffer size: " + p.getValue(), e);
return false;
}
} else {
// log warn but keep running (don't return false)
if (!NAMING_PARAM.equalsIgnoreCase(p.getKey())) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
log.warn("Unknown parameter given to UDI: " + this.getName() + ": " + p.getKey() + " = " + p.getValue());
}
}
}
if (!this.isAddressValid(emailAddress)) {
log.error(// $NON-NLS-1$ //$NON-NLS-2$
"Invalid sender email set in parameters of the user defined indicator \"" + this.getName() + "\": " + emailAddress);
return false;
}
return true;
}
Aggregations