use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateOracleAverageLengthTask method doExecute.
/*
* (non-Jsdoc)
*
* @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
*/
@Override
protected boolean doExecute() throws Exception {
// $NON-NLS-1$
IndicatorDefinition aveWithBlank = IndicatorDefinitionFileHelper.getSystemIndicatorByName("Average Length With Blank");
// $NON-NLS-1$
IndicatorDefinition aveWithNull = IndicatorDefinitionFileHelper.getSystemIndicatorByName("Average Length With Null");
IndicatorDefinition aveWithBlankNull = IndicatorDefinitionFileHelper.getSystemIndicatorByName(// $NON-NLS-1$
"Average Length With Blank and Null");
// $NON-NLS-1$
String newExpWithBlank = "SELECT SUM(LENGTH(<%=__COLUMN_NAMES__%>)), COUNT(*) FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>";
setNewExpression(aveWithBlank, newExpWithBlank);
setNewExpression(aveWithNull, newExpWithBlank);
setNewExpression(aveWithBlankNull, newExpWithBlank);
return true;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateRegularExpressionMatchingMysqlExpressionTask method doExecute.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
*/
@Override
protected boolean doExecute() throws Exception {
IndicatorDefinition indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(REGULAR_EXPRESSION_MATCHING_LABEL);
if (indicatorDefinition != null) {
EList<TdExpression> sqlGenericExpression = indicatorDefinition.getSqlGenericExpression();
if (sqlGenericExpression != null && sqlGenericExpression.size() > 0) {
boolean notFoundMysqlExpression = true;
for (TdExpression expression : sqlGenericExpression) {
if (expression != null && SupportDBUrlType.MYSQLDEFAULTURL.getLanguage().equals(expression.getLanguage())) {
notFoundMysqlExpression = false;
expression.setBody(MYSQL_EXPRESSION);
break;
}
}
if (notFoundMysqlExpression) {
TdExpression newExpression = BooleanExpressionHelper.createTdExpression(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage(), MYSQL_EXPRESSION);
sqlGenericExpression.add(newExpression);
} else {
// mysql expression have exist, so needn't to create a new mysql expression
}
}
}
return true;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateDependenciesFileTask method updateDependencies.
/**
* Method "updateDependencies" updates dependencies between elements in TOP.
*
* @param analysesSubFolder
* @throws CoreException
*/
private void updateDependencies(IFolder analysesSubFolder) throws CoreException {
for (IResource resource : analysesSubFolder.members()) {
if (resource instanceof IFolder) {
IFolder folder = (IFolder) resource;
updateDependencies(folder);
}
if (resource instanceof IFile) {
IFile file = (IFile) resource;
final Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
// update dependency between analyses and patterns
if (analysis != null) {
final List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
for (Pattern pattern : patterns) {
DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
AnaResourceFileHelper.getInstance().save(analysis);
}
// update dependency between analyses and dq rules
final List<IndicatorDefinition> userDefinedIndicators = AnalysisHelper.getUserDefinedIndicators(analysis);
for (IndicatorDefinition indicatorDefinition : userDefinedIndicators) {
DependenciesHandler.getInstance().setDependencyOn(analysis, indicatorDefinition);
AnaResourceFileHelper.getInstance().save(analysis);
}
}
}
}
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateIndicatorsForVertica method doExecute.
/**
* migrate these indicators for Vertica database:Pattern Frequency Table,Pattern Low Frequency Table,Regular
* Expression Matching.
*/
@Override
protected boolean doExecute() throws Exception {
DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
IndicatorDefinition patternMatchIndDef = definitionHandler.getDefinitionById(patternMatchIndiDefId);
IndicatorDefinition patternFreqIndDef = definitionHandler.getDefinitionById(patternFreqIndiDefId);
IndicatorDefinition patternLowPatternFreqIndDef = definitionHandler.getDefinitionById(lowPatternFreqIndiDefId);
IndicatorDefinition benFordIndDef = definitionHandler.getDefinitionById(benfordId);
boolean isNeedReload = false;
if (patternMatchIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternMatchIndDef, language)) {
IndicatorDefinitionFileHelper.addSqlExpression(patternMatchIndDef, language, patternMatchSQL);
IndicatorDefinitionFileHelper.save(patternMatchIndDef);
isNeedReload = true;
}
if (patternFreqIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternFreqIndDef, language)) {
IndicatorDefinitionFileHelper.addSqlExpression(patternFreqIndDef, language, patternFreqSQL);
IndicatorDefinitionFileHelper.addCharacterMapping(patternFreqIndDef, language, name, charToReplace, newReplaceChar);
IndicatorDefinitionFileHelper.save(patternFreqIndDef);
if (!isNeedReload) {
isNeedReload = true;
}
}
if (patternLowPatternFreqIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternLowPatternFreqIndDef, language)) {
IndicatorDefinitionFileHelper.addSqlExpression(patternLowPatternFreqIndDef, language, lowPatternFreqSQL);
IndicatorDefinitionFileHelper.addCharacterMapping(patternLowPatternFreqIndDef, language, name, charToReplace, newReplaceChar);
IndicatorDefinitionFileHelper.save(patternLowPatternFreqIndDef);
if (!isNeedReload) {
isNeedReload = true;
}
}
if (benFordIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(benFordIndDef, language)) {
IndicatorDefinitionFileHelper.addSqlExpression(benFordIndDef, language, benFordSQL);
IndicatorDefinitionFileHelper.save(benFordIndDef);
if (!isNeedReload) {
isNeedReload = true;
}
}
if (isNeedReload) {
definitionHandler.reloadIndicatorsDefinitions();
}
return true;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateLowerUpperQuartileForDB2Task method updateSqlForDB2.
private boolean updateSqlForDB2(String indicatorName, String sqlExpression) {
IndicatorDefinition indiDefinition = IndicatorDefinitionFileHelper.getSystemIndicatorByName(indicatorName);
if (indiDefinition != null && IndicatorDefinitionFileHelper.removeSqlExpression(indiDefinition, DB2)) {
List<TdExpression> remainExpLs = new ArrayList<TdExpression>();
remainExpLs.addAll(indiDefinition.getSqlGenericExpression());
indiDefinition.getSqlGenericExpression().clear();
IndicatorDefinitionFileHelper.addSqlExpression(indiDefinition, DB2, sqlExpression);
indiDefinition.getSqlGenericExpression().addAll(remainExpLs);
return IndicatorDefinitionFileHelper.save(indiDefinition);
}
return true;
}
Aggregations