use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class RegexpMatchingIndicatorImplTest method testGetRegexFail1NotJavaRegex.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
*/
@Test
public void testGetRegexFail1NotJavaRegex() {
// RegexpMatchingIndicator
RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// ~RegexpMatchingIndicator
// IndicatorParameters
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// ~IndicatorParameters
// Domain
Domain createDomain = DomainFactory.eINSTANCE.createDomain();
EList<Pattern> patterns = createDomain.getPatterns();
// ~Domain
// Pattern
Pattern createJavaPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
patterns.add(createJavaPattern);
patterns.add(createSQLPattern);
patterns.add(createMSSQLPattern);
// ~Pattern
// init java Pattern data
RegularExpression createJavaRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createJavaTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createJavaTdExpression.setBody(JavaRegex);
createJavaTdExpression.setLanguage("Microsoft SQL Server");
createJavaRegularExpression.setExpression(createJavaTdExpression);
createJavaRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
EList<PatternComponent> components = createJavaPattern.getComponents();
components.add(createJavaRegularExpression);
// ~init java Pattern data
createIndicatorParameters.setDataValidDomain(createDomain);
createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
TdColumn column = RelationalFactory.eINSTANCE.createTdColumn();
MetadataTable mdColumn = RelationalFactory.eINSTANCE.createTdTable();
column.setTable(mdColumn);
createRegexpMatchingIndicator.setAnalyzedElement(column);
// call getRegex()
String regexResult = createRegexpMatchingIndicator.getRegex();
// ~call getRegex()
Assert.assertTrue(regexResult == null);
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class RegexpMatchingIndicatorImplTest method testGetRegexWithDefaultSQLWhenNoJava.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
*/
@Test
public void testGetRegexWithDefaultSQLWhenNoJava() {
// RegexpMatchingIndicator
RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// ~RegexpMatchingIndicator
// IndicatorParameters
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
// ~IndicatorParameters
// Domain
Domain createDomain = DomainFactory.eINSTANCE.createDomain();
EList<Pattern> patterns = createDomain.getPatterns();
// ~Domain
// Pattern
Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
patterns.add(createSQLPattern);
patterns.add(createMSSQLPattern);
// ~Pattern
// init default:SQL Pattern data
RegularExpression createDefaultExpression = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression createDefaultTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
createDefaultTdExpression.setBody("'sql body'");
createDefaultTdExpression.setLanguage("SQL");
createDefaultExpression.setExpression(createDefaultTdExpression);
createDefaultExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
EList<PatternComponent> components = createSQLPattern.getComponents();
components.add(createDefaultExpression);
// ~init default Pattern data
createIndicatorParameters.setDataValidDomain(createDomain);
createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
// call getRegex()
String regexResult = createRegexpMatchingIndicator.getRegex();
// ~call getRegex()
Assert.assertTrue("sql body".equalsIgnoreCase(regexResult));
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class AnalysisColumnNominalIntervalTreeViewer method createTreeMenu.
/**
* DOC xzhao Comment method "createTreeMenu".
*
* @param newTree
* @param containEdit
*/
private void createTreeMenu(final Tree newTree, boolean containEdit) {
Menu oldMenu = newTree.getMenu();
if (oldMenu != null && !oldMenu.isDisposed()) {
oldMenu.dispose();
}
menu = new Menu(newTree);
MenuItem deleteMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
deleteMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.removeElement"));
deleteMenuItem.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
deleteMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
removeSelectedElements(newTree);
// MOD mzhao 2005-05-05 bug 6587.
// MOD mzhao 2009-06-8, bug 5887.
// updateBindConnection(masterPage, tree);
}
});
// ADD 2009-01-07 mzhao for feature:0005664
MenuItem showMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
showMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = newTree.getSelection();
if (selection.length > 0) {
// if DqRepository view is not openning we will not do anything
DQRespositoryView dqview = CorePlugin.getDefault().findAndOpenRepositoryView();
if (dqview == null) {
return;
}
// TdColumn tdColumn = (TdColumn) selection[0].getData(COLUMN_INDICATOR_KEY);
dqview.showSelectedElements(selection[0].getData(COLUMN_INDICATOR_KEY));
}
}
});
if (containEdit) {
editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editPattern"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
TreeItem treeItem = selection[0];
IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(INDICATOR_UNIT_KEY);
PatternMatchingIndicator indicator = (PatternMatchingIndicator) indicatorUnit.getIndicator();
Pattern pattern = indicator.getParameters().getDataValidDomain().getPatterns().get(0);
// MOD mzhao 2009-03-13 Feature 6066 Move all folders
// into one project.
IFile file = ResourceFileMap.findCorrespondingFile(pattern);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
activePage.openEditor(new FileEditorInput(file), // $NON-NLS-1$
"org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor");
} catch (PartInitException e1) {
log.error(e1, e1);
}
}
}
});
}
newTree.setMenu(menu);
}
use of org.talend.dataquality.domain.pattern.Pattern 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.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class PatternMasterDetailsPage method getPatternRepNodeFromInput.
/**
* get PatternRepNode From editorInput
*
* @param editorInput
* @return
*/
private PatternRepNode getPatternRepNodeFromInput(IEditorInput editorInput) {
if (editorInput instanceof FileEditorInput) {
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
if (file != null) {
Pattern pattern = PatternResourceFileHelper.getInstance().findPattern(file);
pattern = (Pattern) EObjectHelper.resolveObject(pattern);
return RepositoryNodeHelper.recursiveFindPattern(pattern);
}
} else if (editorInput instanceof PatternItemEditorInput) {
return ((PatternItemEditorInput) editorInput).getRepNode();
}
return null;
}
Aggregations