use of org.talend.dataquality.domain.pattern.RegularExpression in project tdq-studio-se by Talend.
the class FileSystemImportWriter method createPatternComponent.
private PatternComponent createPatternComponent(PatternComponent oldComponent) {
RegularExpression newComponent = PatternFactory.eINSTANCE.createRegularExpression();
newComponent.setExpression(((RegularExpression) oldComponent).getExpression());
newComponent.setExpressionType(((RegularExpression) oldComponent).getExpressionType());
return newComponent;
}
use of org.talend.dataquality.domain.pattern.RegularExpression 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.RegularExpression in project tdq-studio-se by Talend.
the class AddPatternISBN13Task method newPattern.
private Pattern newPattern(String name, String lang, String express) {
PatternBuilder patternBuilder = new PatternBuilder();
boolean patternInitialized = patternBuilder.initializePattern(name);
if (patternInitialized) {
Pattern pattern = patternBuilder.getPattern();
RegularExpression regularExpr = BooleanExpressionHelper.createRegularExpression(lang, express);
// $NON-NLS-1$
regularExpr.setExpressionType("REGEXP");
pattern.getComponents().add(regularExpr);
return pattern;
}
return null;
}
use of org.talend.dataquality.domain.pattern.RegularExpression in project tdq-studio-se by Talend.
the class DomainHelper method setDataFilterPattern.
/**
* Method "setDataFilterPattern".
*
* @param dataFilters a list of data filters
* @param type
* @param domainName
* @param filterPattern
* @return
*/
private static Domain setDataFilterPattern(final Collection<Domain> dataFilters, PatternType type, DomainType domainName, String filterPattern) {
RegularExpression filterExpr = BooleanExpressionHelper.createRegularExpression(null, filterPattern);
for (Domain domain : dataFilters) {
if (!domainName.label.equals(domain.getName())) {
continue;
}
boolean exists = false;
EList<Pattern> patterns = domain.getPatterns();
for (Pattern pattern : patterns) {
if (type.label.equals(pattern.getName())) {
exists = true;
// remove previous expressions
pattern.getComponents().clear();
pattern.getComponents().add(filterExpr);
}
}
if (!exists) {
// create pattern and set into the data filter
addPatternToDomain(domain, filterExpr, filterPattern, type);
}
return domain;
}
// no data filter has not been set yet
Domain domain = DomainFactory.eINSTANCE.createDomain();
dataFilters.add(domain);
domain.setName(domainName.label);
addPatternToDomain(domain, filterExpr, filterPattern, type);
return domain;
}
use of org.talend.dataquality.domain.pattern.RegularExpression in project tdq-studio-se by Talend.
the class DomainHelper method getExpression.
/**
* Method "getExpression".
*
* @param patternComponent
* @param language a language (see DbmsLanguage)
* @return the expression for the given language or null
*/
public static Expression getExpression(PatternComponent patternComponent, String language) {
if (patternComponent != null && patternComponent.eClass().equals(PatternPackage.eINSTANCE.getRegularExpression())) {
RegularExpression regExp = (RegularExpression) patternComponent;
Expression expr = regExp.getExpression();
if (expr != null && language != null && language.equalsIgnoreCase(regExp.getExpression().getLanguage())) {
return expr;
}
}
// not a regular expression
return null;
}
Aggregations