use of org.talend.dataquality.rules.WhereRule in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method getOwnedWhereRuleNodes.
/**
* DOC xqliu Comment method "getOwnedWhereRuleFiles". ADD xqliu 2009-04-30 bug 6808
*
* @param tableIndicator
* @param whereRuleFolder
* @return
*/
private Object[] getOwnedWhereRuleNodes(TableIndicator tableIndicator) {
ArrayList<RuleRepNode> ret = new ArrayList<RuleRepNode>();
Indicator[] indicators = tableIndicator.getIndicators();
for (Indicator indicator : indicators) {
if (IndicatorHelper.isWhereRuleIndicator(indicator)) {
Object obj = indicator.getIndicatorDefinition();
if (obj != null && obj instanceof WhereRule) {
WhereRule wr = (WhereRule) obj;
RuleRepNode recursiveFindRuleSql = RepositoryNodeHelper.recursiveFindRuleSql(wr);
if (recursiveFindRuleSql != null) {
ret.add(recursiveFindRuleSql);
}
}
}
}
return ret.toArray();
}
use of org.talend.dataquality.rules.WhereRule in project tdq-studio-se by Talend.
the class DQRuleMasterDetailsPage method getWhereRuleRepNodeFromInput.
/**
* get PatternRepNode From editorInput
*
* @param editorInput
* @return
*/
private RuleRepNode getWhereRuleRepNodeFromInput(IEditorInput editorInput) {
if (editorInput instanceof FileEditorInput) {
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
if (file != null) {
WhereRule whereRule = DQRuleResourceFileHelper.getInstance().findWhereRule(file);
whereRule = (WhereRule) EObjectHelper.resolveObject(whereRule);
return RepositoryNodeHelper.recursiveFindRuleSql(whereRule);
}
} else if (editorInput instanceof BusinessRuleItemEditorInput) {
return ((BusinessRuleItemEditorInput) editorInput).getRepNode();
}
return null;
}
use of org.talend.dataquality.rules.WhereRule in project tdq-studio-se by Talend.
the class TDQResourceChangeHandler method create.
@Override
public Resource create(IProject project, Item item, int classID, IPath path) {
String fileExtension = FileConstants.ITEM_EXTENSION;
Resource itemResource = null;
try {
switch(classID) {
case org.talend.dataquality.properties.PropertiesPackage.TDQ_ANALYSIS_ITEM:
fileExtension = FileConstants.ANA_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT, false, fileExtension);
AnalysisWriter createAnalysisWrite = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createAnalysisWrite();
Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
createAnalysisWrite.addResourceContent(itemResource, analysis);
createAnalysisWrite.addDependencies(analysis);
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_REPORT_ITEM:
fileExtension = FileConstants.REP_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_REPORT_ELEMENT, false, fileExtension);
ReportWriter createReportWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createReportWriter();
Report report = ((TDQReportItem) item).getReport();
createReportWriter.addResourceContent(itemResource, report);
createReportWriter.addDependencies(report);
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_INDICATOR_DEFINITION_ITEM:
fileExtension = FileConstants.DEF_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_INDICATOR_ELEMENT, false, fileExtension);
IndicatorDefinition indicatorDefinition = ((TDQIndicatorDefinitionItem) item).getIndicatorDefinition();
IndicatorDefinitionWriter createIndicatorDefinitionWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createIndicatorDefinitionWriter();
createIndicatorDefinitionWriter.addResourceContent(itemResource, indicatorDefinition);
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_PATTERN_ITEM:
fileExtension = FileConstants.PAT_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_PATTERN_ELEMENT, false, fileExtension);
Pattern pattern = ((TDQPatternItem) item).getPattern();
PatternWriter createPatternWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createPatternWriter();
createPatternWriter.addResourceContent(itemResource, pattern);
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_BUSINESS_RULE_ITEM:
fileExtension = FileConstants.RULE_EXTENSION;
// MOD gdbu 2011-6-10 bug : 21823 2011-06-27 revert the error type code by klliu
DQRule dqrule = ((TDQBusinessRuleItem) item).getDqrule();
if (dqrule instanceof WhereRule) {
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_SQL, false, fileExtension);
} else {
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_PARSER, false, fileExtension);
}
// ~21823
DQRuleWriter createdRuleWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createdRuleWriter();
createdRuleWriter.addResourceContent(itemResource, dqrule);
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_JRXML_ITEM:
fileExtension = FileConstants.JRXML_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_JRAXML_ELEMENT, true, fileExtension);
itemResource.getContents().add(((TDQFileItem) item).getContent());
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_SOURCE_FILE_ITEM:
fileExtension = FileConstants.SQL_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT, true, fileExtension);
itemResource.getContents().add(((TDQFileItem) item).getContent());
break;
case org.talend.dataquality.properties.PropertiesPackage.TDQ_MATCH_RULE_ITEM:
fileExtension = FileConstants.RULE_EXTENSION;
itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_MATCHER, false, fileExtension);
MatchRuleDefinition matchRuleDefinition = ((TDQMatchRuleItem) item).getMatchRule();
MatchRuleDefinitionWriter matchRuleDefinitionWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createdMatchRuleWriter();
matchRuleDefinitionWriter.addResourceContent(itemResource, matchRuleDefinition);
break;
default:
}
} catch (PersistenceException e) {
log.error(e, e);
}
return itemResource;
}
use of org.talend.dataquality.rules.WhereRule in project tdq-studio-se by Talend.
the class TableAnalysisWizard method initCWMResourceBuilder.
@Override
public ModelElement initCWMResourceBuilder() {
Analysis analysis = (Analysis) super.initCWMResourceBuilder();
NamedColumnSet[] ncss = getNamedColumnSet();
Connection tdp = getTdDataProvider();
if (ncss != null && getAnalysisBuilder() != null) {
List<Indicator> indicatorList = new ArrayList<Indicator>();
WhereRule[] whereRules = getWhereRules(dqruleSelectPage.getCViewer().getCheckedElements());
for (NamedColumnSet ncs : ncss) {
// add RowCountIndicator
RowCountIndicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(rowCountIndicator);
rowCountIndicator.setAnalyzedElement(ncs);
indicatorList.add(rowCountIndicator);
// add user selected WhereRuleIndicator
if (whereRules != null) {
for (WhereRule whereRule : whereRules) {
WhereRuleIndicator[] compositeWhereRuleIndicator = DQRuleUtilities.createCompositeWhereRuleIndicator(ncs, whereRule);
indicatorList.addAll(Arrays.asList(compositeWhereRuleIndicator));
}
}
}
getAnalysisBuilder().addElementsToAnalyze(ncss, indicatorList.toArray(new Indicator[indicatorList.size()]));
getAnalysisBuilder().setAnalysisConnection(tdp);
}
return analysis;
}
use of org.talend.dataquality.rules.WhereRule in project tdq-studio-se by Talend.
the class DQRuleLabelProvider method getImage.
@Override
public Image getImage(Object element) {
if (element instanceof IFolder) {
return ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
}
if (element instanceof IFile && FactoriesUtil.DQRULE.equals(((IFile) element).getFileExtension())) {
IFile file = (IFile) element;
ModelElement me = DQRuleResourceFileHelper.getInstance().getModelElement(file);
// add support for match rule
ModelElement modelElement = DQRuleResourceFileHelper.getInstance().getModelElement(file);
ModelElement rule = DQRuleResourceFileHelper.getInstance().doSwitch(modelElement);
if (rule != null && rule instanceof MatchRuleDefinition) {
ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.MATCH_RULE_ICON);
return imageDescriptor.createImage();
}
// ~
ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.DQ_RULE);
if (rule != null && rule instanceof WhereRule) {
boolean validStatus = TaggedValueHelper.getValidStatus(rule);
if (!validStatus) {
ImageDescriptor warnImg = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK);
DecorationOverlayIcon icon = new DecorationOverlayIcon(imageDescriptor.createImage(), warnImg, IDecoration.BOTTOM_RIGHT);
imageDescriptor = icon;
}
}
return imageDescriptor.createImage();
}
return null;
}
Aggregations