use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class PatternExplorer method getInvalidValuesStatement.
/**
* get the Valid Values Statement.
*
* @return SELECT statement for the invalid Value of select column
*/
public String getInvalidValuesStatement() {
// when the indicator is the use define match
IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
if (indicatorDefinition instanceof UDIndicatorDefinition) {
EList<TdExpression> list = ((UDIndicatorDefinition) indicatorDefinition).getViewInvalidValuesExpression();
return getQueryAfterReplaced(indicatorDefinition, list);
}
String regexPatternString = dbmsLanguage.getRegexPatternString(this.indicator);
String regexCmp = getRegexNotLike(regexPatternString);
// add null as invalid rows
String nullClause = dbmsLanguage.or() + columnName + dbmsLanguage.isNull();
// mzhao TDQ-4967 add "(" and ")" for regex and null clause.
// $NON-NLS-1$//$NON-NLS-2$
String pattCondStr = "(" + regexCmp + nullClause + ")";
return getValuesStatement(columnName, pattCondStr);
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class SimpleStatisticsExplorer method getSubClassQueryMap.
@Override
public Map<String, String> getSubClassQueryMap() {
Map<String, String> map = new HashMap<String, String>();
// MOD zshen feature 12919 adapt to pop-menu for Jave engin on result page
boolean isSqlEngine = ExecutionLanguage.SQL.equals(this.analysis.getParameters().getExecutionLanguage());
// MOD qiongli 2011-3-4,feature 19192:filter menue 'view rows' for columSet AnalysisType.
AnalysisType analysisType = this.analysis.getParameters().getAnalysisType();
// MOD qiongli 2012-8-29 hive don't support 'where in...'
boolean isHive = dbmsLanguage instanceof HiveDbmsLanguage;
switch(this.indicatorEnum) {
case RowCountIndicatorEnum:
// for columnset/column and jave engine, we didn't show the view rows menu
if (isSqlEngine) {
// when user define indicator
map.put(MENU_VIEW_ROWS, getComment(MENU_VIEW_ROWS) + getRowsStatement());
}
break;
case NullCountIndicatorEnum:
case BlankCountIndicatorEnum:
case DefValueCountIndicatorEnum:
case UserDefinedIndicatorEnum:
// when user define indicator
IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + (indicatorDefinition instanceof UDIndicatorDefinition ? getQueryForViewRows(indicatorDefinition) : getRowsStatement()) : null);
break;
case UniqueIndicatorEnum:
case DuplicateCountIndicatorEnum:
if (analysisType != AnalysisType.COLUMN_SET) {
if (!isHive) {
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + getRowsStatementWithSubQuery() : null);
} else if (!isSqlEngine) {
map.put(MENU_VIEW_ROWS, null);
}
}
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getValuesStatement(this.columnName) : null);
break;
case DistinctCountIndicatorEnum:
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getDistinctValuesStatement(this.columnName) : null);
break;
default:
}
return map;
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class IndicatorEditor method isSystemIndicator.
/**
* Judge if the current indicator definition is a system indicator
*
* @return true if it is system indicator false if it is UDI
*/
private boolean isSystemIndicator() {
IEditorInput editorInput = this.getEditorInput();
IndicatorDefinition definition = null;
if (editorInput instanceof IndicatorEditorInput) {
// from DQRespositoryView double click
definition = ((IndicatorEditorInput) editorInput).getIndicatorDefinition();
} else if (editorInput instanceof IndicatorDefinitionItemEditorInput) {
// from OpenItemEditorAction
definition = (IndicatorDefinition) ((IndicatorDefinitionItemEditorInput) editorInput).getModel();
} else if (editorInput instanceof FileEditorInput) {
// when open the indicator inside an analysis
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
if (FactoriesUtil.isUDIFile(file.getFileExtension())) {
definition = IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
}
}
if (definition instanceof UDIndicatorDefinition) {
return false;
} else {
return true;
}
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class UDIMasterPage method putTdExpressToTempMap.
@Override
public void putTdExpressToTempMap(final CCombo combo, final TdExpression expression) {
super.putTdExpressToTempMap(combo, expression);
UDIndicatorDefinition definition2 = (UDIndicatorDefinition) getCurrentModelElement();
if (IndicatorCategoryHelper.isUserDefMatching(category)) {
tempViewValidRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewValidRowsExpression(), tempViewValidRowsExpressionMap);
tempViewInvalidRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewInvalidRowsExpression(), tempViewInvalidRowsExpressionMap);
tempViewValidValuesExpressionMap = setToTempMap(expression, combo, definition2.getViewValidValuesExpression(), tempViewValidValuesExpressionMap);
tempViewInvalidValuesExpressionMap = setToTempMap(expression, combo, definition2.getViewInvalidValuesExpression(), tempViewInvalidValuesExpressionMap);
} else {
// get view rows tdExpress list, and set currect tdexpress to temp map
tempViewRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewRowsExpression(), tempViewRowsExpressionMap);
}
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateUDIIndicatorsWithNewModelTask method doExecute.
@Override
protected boolean doExecute() throws Exception {
boolean result = true;
File udiIndicatorFolder = getWorkspacePath().append(EResourceConstant.USER_DEFINED_INDICATORS.getPath()).toFile();
String[] indicatorFileExtentionName = { FactoriesUtil.DEFINITION };
try {
result &= FilesUtils.migrateFolder(udiIndicatorFolder, indicatorFileExtentionName, initIndicatorReplaceMap(), log);
if (isWorksapcePath()) {
for (IRepositoryViewObject viewObject : ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS)) {
ProxyRepositoryFactory.getInstance().reload(viewObject.getProperty());
}
}
ResourceService.refreshStructure();
} catch (Exception e) {
result = false;
log.error(e, e);
}
List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getUserDefinedIndicatorDefinitions();
for (IndicatorDefinition indiDefinition : indiDefinitions) {
if (indiDefinition != null) {
if (indiDefinition instanceof UDIndicatorDefinition) {
UDIndicatorDefinition udi = (UDIndicatorDefinition) indiDefinition;
udi = UDIUtils.createDefaultDrillDownList(udi);
result &= ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(udi).isOk();
}
}
}
DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
return result;
}
Aggregations