use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutor method getValidStatement.
/**
* DOC xqliu Comment method "getValidStatement". 2009-10-29 bug 9702
*
* @param dataFilterAsString
* @param indicator
* @param valid
* @return
*/
public String getValidStatement(String dataFilterAsString, Indicator indicator, boolean valid) {
if (!isAnalyzedElementValid(indicator)) {
return PluginConstant.EMPTY_STRING;
}
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
if (!isIndicatorDefinitionValid(indicatorDefinition, AnalysisExecutorHelper.getIndicatorName(indicator))) {
return PluginConstant.EMPTY_STRING;
}
Expression sqlGenericExpression = dbms().getSqlExpression(indicatorDefinition);
if (!isExpressionValid(sqlGenericExpression, indicator)) {
return PluginConstant.EMPTY_STRING;
}
// --- get indicator parameters and convert them into sql expression
List<String> whereExpressionAnalysis = new ArrayList<String>();
if (StringUtils.isNotBlank(dataFilterAsString)) {
whereExpressionAnalysis.add(dataFilterAsString);
}
List<String> whereExpressionDQRule = new ArrayList<String>();
String setAliasA = PluginConstant.EMPTY_STRING;
final EList<JoinElement> joinConditions = indicator.getJoinConditions();
if (RulesPackage.eINSTANCE.getWhereRule().equals(indicatorDefinition.eClass())) {
WhereRule wr = (WhereRule) indicatorDefinition;
whereExpressionDQRule.add(wr.getWhereExpression());
// MOD scorreia 2009-03-13 copy joins conditions into the indicator
joinConditions.clear();
if (!isJoinConditionEmpty(indicator)) {
for (JoinElement joinelt : wr.getJoins()) {
JoinElement joinCopy = EcoreUtil.copy(joinelt);
joinConditions.add(joinCopy);
setAliasA = PluginConstant.EMPTY_STRING.equals(setAliasA) ? joinCopy.getTableAliasA() : setAliasA;
}
}
}
NamedColumnSet set = SwitchHelpers.NAMED_COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
String schemaName = getQuotedSchemaName(set);
// --- normalize table name
String catalogName = getQuotedCatalogName(set);
if (catalogName == null && schemaName != null) {
// try to get catalog above schema
final Schema parentSchema = SchemaHelper.getParentSchema(set);
final Catalog parentCatalog = CatalogHelper.getParentCatalog(parentSchema);
catalogName = parentCatalog != null ? parentCatalog.getName() : null;
}
String setName = dbms().toQualifiedName(catalogName, schemaName, quote(set.getName()));
// ### evaluate SQL Statement depending on indicators ###
String completedSqlString = null;
// --- default case
// allow join
String joinclause = (!joinConditions.isEmpty()) ? dbms().createJoinConditionAsString(set, joinConditions, catalogName, schemaName) : PluginConstant.EMPTY_STRING;
String genericSql = sqlGenericExpression.getBody();
// $NON-NLS-1$//$NON-NLS-2$
setAliasA = PluginConstant.EMPTY_STRING.equals(setAliasA) ? "*" : setAliasA + ".*";
// $NON-NLS-1$
genericSql = genericSql.replace("COUNT(*)", setAliasA);
completedSqlString = dbms().fillGenericQueryWithJoin(genericSql, setName, joinclause);
// ~
completedSqlString = addWhereToSqlStringStatement(whereExpressionAnalysis, whereExpressionDQRule, completedSqlString, valid);
return completedSqlString;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class CategoryHandler method getShowIndicatorsDefinitions.
/**
* DOC bZhou Comment method "getShowIndicatorsDefinitions".
*
* @return
*/
public static List<IndicatorDefinition> getShowIndicatorsDefinitions() {
// if (showIndicatorDefinitions == null) {
ArrayList<IndicatorDefinition> showIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
List<IndicatorDefinition> indicatorDefinitions = DefinitionHandler.getInstance().getIndicatorsDefinitions();
for (IndicatorDefinition indicatorDefinition : indicatorDefinitions) {
if (!indicatorDefinition.getSqlGenericExpression().isEmpty() && !getShouldNotIncludeIndicatorDefinitionUuidList().contains(ResourceHelper.getUUID(indicatorDefinition))) {
showIndicatorDefinitions.add(indicatorDefinition);
}
}
// }
return showIndicatorDefinitions;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class FunctionFrequencyStatExplorer method columnNameConvert.
@SuppressWarnings("deprecation")
private String columnNameConvert() {
String colName = columnName;
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
IndicatorDefinition indicatorDefinition;
String label = indicator.getIndicatorDefinition().getLabel();
if (label == null || PluginConstant.EMPTY_STRING.equals(label)) {
indicatorDefinition = indicator.getIndicatorDefinition();
} else {
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(label);
}
if (indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternFreqIndicator()) || indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternLowFreqIndicator())) {
// MOD zshen for bug 12675 2010-05-12
if (Java2SqlType.isNumbericInSQL(column.getSqlDataType().getJavaDataType())) {
colName = addFunctionTypeConvert(colName);
}
// ~12675
final EList<CharactersMapping> charactersMapping = indicatorDefinition.getCharactersMapping();
colName = dbmsLanguage.getPatternFinderFunction(colName, charactersMapping);
if (columnName == null) {
// no replacement found, try the default one
colName = dbmsLanguage.getPatternFinderDefaultFunction(colName);
}
}
return colName;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DependenciesHandler method getIndicatorDependency.
/**
* get Indicator Dependency.
*
* @return get the list for analysis which use parameter to be a Indicator
*/
public List<IRepositoryViewObject> getIndicatorDependency(IRepositoryViewObject viewObject) {
Item item = viewObject.getProperty().getItem();
List<IRepositoryViewObject> listAnalysisViewObject = new ArrayList<IRepositoryViewObject>();
if (item instanceof TDQIndicatorDefinitionItemImpl) {
TDQIndicatorDefinitionItemImpl tdqIndicatorItem = (TDQIndicatorDefinitionItemImpl) item;
IndicatorDefinition newIndicatorDefinition = tdqIndicatorItem.getIndicatorDefinition();
List<IRepositoryViewObject> allAnaList = new ArrayList<IRepositoryViewObject>();
try {
allAnaList.addAll(ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT, true));
} catch (PersistenceException e) {
log.error(e, e);
}
for (IRepositoryViewObject theAna : allAnaList) {
List<Indicator> indicators = IndicatorHelper.getIndicators(((TDQAnalysisItem) theAna.getProperty().getItem()).getAnalysis().getResults());
for (Indicator indicator : indicators) {
IndicatorDefinition oldIndicatorDefinition = indicator.getIndicatorDefinition();
if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
listAnalysisViewObject.add(theAna);
break;
}
}
}
}
return listAnalysisViewObject;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ResourceViewLabelProvider method decorateImage.
@Override
protected ImageDescriptor decorateImage(ImageDescriptor input, Object element) {
ImageDescriptor image = super.decorateImage(input, element);
if (element instanceof IFile) {
IFile file = (IFile) element;
String fileExtension = file.getFileExtension();
// MOD qiongli 2010-9-7,bug 14698,add 'try...catch'
try {
if (FactoriesUtil.isPatternFile(fileExtension)) {
image = ImageLib.getImageDescriptor(ImageLib.PATTERN_REG);
Pattern pattern = PatternResourceFileHelper.getInstance().findPattern(file);
if (pattern != null) {
if (!TaggedValueHelper.getValidStatus(pattern)) {
image = ImageLib.createInvalidIconDes(ImageLib.PATTERN_REG);
}
}
} else if (FactoriesUtil.isReportFile(fileExtension)) {
image = ImageLib.getImageDescriptor(ImageLib.REPORT_OBJECT);
} else if (FactoriesUtil.isUDIFile(fileExtension)) {
image = ImageLib.getImageDescriptor(ImageLib.IND_DEFINITION);
IndicatorDefinition udi = IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
if (udi != null) {
boolean validStatus = TaggedValueHelper.getValidStatus(udi) | UDIHelper.isUDIValid(udi);
if (!validStatus) {
image = ImageLib.createInvalidIconDes(ImageLib.IND_DEFINITION);
}
}
} else if (FactoriesUtil.isAnalysisFile(fileExtension)) {
// ADD qiongli 2010-8-9,feature 14252
Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
if (analysis != null) {
AnalysisHandler analysisHandler = new AnalysisHandler();
analysisHandler.setAnalysis(analysis);
if (analysisHandler.getResultMetadata().getExecutionNumber() != 0) {
if (!analysisHandler.getResultMetadata().isLastRunOk()) {
image = ImageLib.createErrorIcon(image);
} else if (analysisHandler.getResultMetadata().isOutThreshold()) {
image = ImageLib.createInvalidIcon(image);
}
}
}
}
} catch (Exception exc) {
log.error(exc, exc);
image = ImageLib.getImageDescriptor(ImageLib.DELETE_ACTION);
}
if (FactoriesUtil.isEmfFile(fileExtension)) {
Property property = PropertyHelper.getProperty(file);
if (property != null) {
Item item = property.getItem();
Boolean lockByOthers = ProxyRepositoryManager.getInstance().isLockByOthers(item);
Boolean lockByUserOwn = ProxyRepositoryManager.getInstance().isLockByUserOwn(item);
if (lockByOthers || lockByUserOwn) {
// $NON-NLS-1$
log.info(property.getLabel() + " is locked");
image = ImageLib.createLockedIcon(image);
}
}
}
} else if (element instanceof IFolder) {
IFolder folder = (IFolder) element;
if (ResourceManager.isMetadataFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.METADATA);
} else if (ResourceManager.isLibrariesFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.LIBRARIES);
} else if (ResourceManager.isDataProfilingFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.DATA_PROFILING);
} else if (ResourceManager.isDBConnectionFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.CONNECTION);
} else if (ResourceManager.isExchangeFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.EXCHANGE);
} else if (ResourceManager.isFileDelimitedFolder(folder)) {
image = ImageLib.getImageDescriptor(ImageLib.FILE_DELIMITED);
}
}
return image;
}
Aggregations