use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method editPattern.
private void editPattern(Tree tree) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
TreeItem treeItem = selection[0];
IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
PatternMatchingIndicator indicator = (PatternMatchingIndicator) indicatorUnit.getIndicator();
Pattern pattern = indicator.getParameters().getDataValidDomain().getPatterns().get(0);
RepositoryNode patternRecursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
PatternItemEditorInput patternItemEditorInput = new PatternItemEditorInput(patternRecursiveFind);
CorePlugin.getDefault().openEditor(patternItemEditorInput, PatternEditor.class.getName());
}
}
use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.
the class PatternMouseAdapter method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = analysis.getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
// MOD gdbu 2011-8-26 bug : TDQ-2169
IRepositoryNode patternFolderNode = getPatternSelectDialogInputData();
if (patternFolderNode == null) {
return;
}
CheckedTreeSelectionDialog dialog = PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
if (null != filters) {
for (ViewerFilter filter : filters) {
dialog.addFilter(filter);
}
}
// ~TDQ-2169
Object[] selectedRepNodes = PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
dialog.setInitialSelections(selectedRepNodes);
dialog.create();
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-17 TDQ-5923,just remove some deselected indicatorUnit,just create new indicatorUnit
// for some new added pattern nodes.
List<PatternRepNode> allSelectedPatternNodes = new ArrayList<PatternRepNode>();
Set<String> allSelectedNodeNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) obj;
allSelectedPatternNodes.add(patternNode);
allSelectedNodeNames.add(patternNode.getLabel());
}
}
Set<String> oldSelectedNodeNames = new HashSet<String>();
Map<String, IndicatorUnit> oldSelectedUnits = new HashMap<String, IndicatorUnit>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof PatternMatchingIndicator) {
if (!allSelectedNodeNames.contains(indicator.getName())) {
// this method will deal dependency with same time
columnDropTree.deleteIndicatorItems(meIndicator, indicatorUnit);
if (!columnDropTree.isDirty()) {
columnDropTree.setDirty(true);
}
} else {
oldSelectedNodeNames.add(indicator.getName());
oldSelectedUnits.put(indicator.getName(), indicatorUnit);
}
}
}
// Added yyin 20121121 TDQ-6329: after remove all, should also add the old selected patterns
// because the columnset does not have pagination, can not refresh automatically
boolean addOldSelected = false;
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
addOldSelected = true;
}
if (addOldSelected) {
for (TreeItem child : treeItem.getItems()) {
masterPage.getTreeViewer().removeItemBranch(child);
}
}
// ~
treeItem.removeAll();
for (PatternRepNode patternNode : allSelectedPatternNodes) {
if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
continue;
}
TypedReturnCode<IndicatorUnit> trc = PatternUtilities.createIndicatorUnit(patternNode.getPattern(), meIndicator, analysis);
if (trc.isOk()) {
createOneUnit(trc.getObject());
// TDQ-8860 add msjian 2014-4-30:check whether show allmatchindicator in the indicators section
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
EventManager.getInstance().publish(analysis, EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
}
// TDQ-8860~
}
}
treeItem.setExpanded(true);
if (masterPage instanceof ColumnAnalysisDetailsPage) {
ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) masterPage;
page.refreshTheTree(page.getCurrentModelElementIndicators());
}
}
}
use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.
the class DbmsLanguage method getRegexPatternString.
/**
* Method "getRegexPatternString".
*
* @param indicator
* @return the regular expression or null if none was found
*/
public String getRegexPatternString(Indicator indicator) {
if (indicator instanceof PatternMatchingIndicator || (indicator instanceof UserDefIndicator && IndicatorCategoryHelper.isUserDefMatching(IndicatorCategoryHelper.getCategory(indicator.getIndicatorDefinition())))) {
IndicatorParameters parameters = indicator.getParameters();
if (parameters == null) {
return null;
}
Domain dataValidDomain = parameters.getDataValidDomain();
if (dataValidDomain == null) {
return null;
}
EList<Pattern> patterns = dataValidDomain.getPatterns();
for (Pattern pattern : patterns) {
Expression expression = this.getRegexp(pattern);
return expression == null ? null : expression.getBody();
}
}
return null;
}
use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.
the class FileSystemImportWriter method updatePatternInAnaParams.
/**
* if there is a same name pattern in current workspace,update the pattern in imported analysis IndicatorParameters.
*
* @param systemSupplyModelElement
* @param analysis
*/
private void updatePatternInAnaParams(ModelElement systemSupplyModelElement, Analysis analysis) {
if (analysis.getResults() != null) {
EList<Indicator> indicators = analysis.getResults().getIndicators();
IndicatorParameters parameters = null;
for (Indicator indicator : indicators) {
// AllMatchIndicator is in column set analysis.
if (indicator instanceof AllMatchIndicator) {
EList<RegexpMatchingIndicator> list = ((AllMatchIndicator) indicator).getCompositeRegexMatchingIndicators();
for (RegexpMatchingIndicator regMatchIndicator : list) {
parameters = regMatchIndicator.getParameters();
removOldAddSysPatternInAnaParams(parameters, (Pattern) systemSupplyModelElement, analysis);
}
} else if (indicator instanceof PatternMatchingIndicator) {
parameters = ((PatternMatchingIndicator) indicator).getParameters();
removOldAddSysPatternInAnaParams(parameters, (Pattern) systemSupplyModelElement, analysis);
}
}
}
}
use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method handleMatchingValue.
/**
* DOC xqliu Comment method "handleMatchingValue".
*
* @param indicator
* @return
*/
public static PatternMatchingExt handleMatchingValue(Indicator indicator) {
PatternMatchingExt patternExt = new PatternMatchingExt();
if (UDIHelper.isUDI(indicator)) {
UserDefIndicator udi = (UserDefIndicator) indicator;
if (udi.getMatchingValueCount() != null) {
patternExt.setMatchingValueCount(udi.getMatchingValueCount());
}
if (udi.getNotMatchingValueCount() != null) {
patternExt.setNotMatchingValueCount(udi.getNotMatchingValueCount());
}
} else {
// TDQ-12282 msjian : fix a NPE
Long matchingValueCount = ((PatternMatchingIndicator) indicator).getMatchingValueCount();
patternExt.setMatchingValueCount(matchingValueCount == null ? 0l : matchingValueCount);
Long notMatchingValueCount = ((PatternMatchingIndicator) indicator).getNotMatchingValueCount();
patternExt.setNotMatchingValueCount(notMatchingValueCount == null ? 0l : notMatchingValueCount);
}
return patternExt;
}
Aggregations