use of org.talend.dataquality.domain.pattern.PatternComponent 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.PatternComponent in project tdq-studio-se by Talend.
the class PatternMasterDetailsPage method createAddButton.
private void createAddButton(Composite parent) {
final Button addButton = new Button(parent, SWT.NONE);
addButton.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
// $NON-NLS-1$
addButton.setToolTipText(DefaultMessagesImpl.getString("PatternMasterDetailsPage.add"));
GridData labelGd = new GridData();
labelGd.horizontalAlignment = SWT.CENTER;
labelGd.widthHint = 65;
addButton.setLayoutData(labelGd);
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
remainDBTypeList.clear();
remainDBTypeList.addAll(allDBTypeList);
for (PatternComponent patternComponent : tempPatternComponents) {
String language = ((RegularExpressionImpl) patternComponent).getExpression().getLanguage();
String languageName = PatternLanguageType.findNameByLanguage(language);
remainDBTypeList.remove(languageName);
}
if (remainDBTypeList.isEmpty()) {
MessageDialog.openWarning(null, DefaultMessagesImpl.getString("PatternMasterDetailsPage.warning"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("PatternMasterDetailsPage.patternExpression"));
return;
}
String language = PatternLanguageType.findLanguageByName(remainDBTypeList.get(0));
RegularExpression newRegularExpress = BooleanExpressionHelper.createRegularExpression(language, null);
newRegularExpress.setExpressionType(expressionType);
creatNewExpressLine(newRegularExpress);
tempPatternComponents.add(newRegularExpress);
patternDefinitionSection.setExpanded(true);
setDirty(true);
}
});
}
use of org.talend.dataquality.domain.pattern.PatternComponent in project tdq-studio-se by Talend.
the class DbmsLanguage method getRegexp.
/**
* Method "getRegexp".
*
* When in SQL engine, retrieve the regex with the matching Dbms Language. If null, return the regex with default
* SQL (even if it's null)
*
* @param pattern a pattern
* @return the body of the regular expression applicable to this dbms or null
*/
public Expression getRegexp(Pattern pattern) {
// MOD by zhsne for bug 17172 2010.12.10
Expression expression = null;
Expression defaultExpression = null;
EList<PatternComponent> components = pattern.getComponents();
for (PatternComponent patternComponent : components) {
if (patternComponent != null) {
expression = this.getExpression(patternComponent);
if (expression != null && DbmsLanguageFactory.compareDbmsLanguage(this.dbmsName, expression.getLanguage())) {
// return this db's expression
return expression;
} else if (expression != null && DbmsLanguageFactory.compareDbmsLanguage(ExecutionLanguage.SQL.getName(), expression.getLanguage())) {
// remember the default expression
defaultExpression = expression;
}
}
}
// if can not find itself, return the default one.
return defaultExpression;
}
use of org.talend.dataquality.domain.pattern.PatternComponent in project tdq-studio-se by Talend.
the class PatternRepNode method getChildren.
@Override
public List<IRepositoryNode> getChildren() {
List<IRepositoryNode> languageElement = new ArrayList<IRepositoryNode>();
IRepositoryViewObject object = this.getObject();
TDQPatternItem patternItem = (TDQPatternItem) object.getProperty().getItem();
Pattern pattern = patternItem.getPattern();
EList<PatternComponent> components = pattern.getComponents();
for (PatternComponent component : components) {
RegularExpression re = (RegularExpression) component;
Expression expression = re.getExpression();
String language = expression.getLanguage();
PatternLanguageRepNode plrn = new PatternLanguageRepNode(this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
plrn.setRegularExpression(re);
plrn.setId(language);
plrn.setLabel(language);
languageElement.add(plrn);
}
// MOD gdbu 2011-7-11 bug : 22204
return filterResultsIfAny(languageElement);
// ~22204
}
use of org.talend.dataquality.domain.pattern.PatternComponent in project tdq-studio-se by Talend.
the class ComponentReferenceImpl method setReferencedComponent.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReferencedComponent(PatternComponent newReferencedComponent) {
PatternComponent oldReferencedComponent = referencedComponent;
referencedComponent = newReferencedComponent;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PatternPackage.COMPONENT_REFERENCE__REFERENCED_COMPONENT, oldReferencedComponent, referencedComponent));
}
Aggregations