Search in sources :

Example 16 with RegularExpression

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;
}
Also used : RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression)

Example 17 with RegularExpression

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
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Expression(orgomg.cwm.objectmodel.core.Expression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PatternComponent(org.talend.dataquality.domain.pattern.PatternComponent) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem)

Example 18 with RegularExpression

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;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) PatternBuilder(org.talend.dq.pattern.PatternBuilder)

Example 19 with RegularExpression

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;
}
Also used : RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Pattern(org.talend.dataquality.domain.pattern.Pattern) Domain(org.talend.dataquality.domain.Domain)

Example 20 with RegularExpression

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;
}
Also used : RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression)

Aggregations

RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)39 Pattern (org.talend.dataquality.domain.pattern.Pattern)26 TdExpression (org.talend.cwm.relational.TdExpression)18 PatternComponent (org.talend.dataquality.domain.pattern.PatternComponent)17 Test (org.junit.Test)12 Domain (org.talend.dataquality.domain.Domain)12 Expression (orgomg.cwm.objectmodel.core.Expression)10 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)9 TdColumn (org.talend.cwm.relational.TdColumn)7 ArrayList (java.util.ArrayList)6 Analysis (org.talend.dataquality.analysis.Analysis)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)5 TdTable (org.talend.cwm.relational.TdTable)5 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)5 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)5 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)5 Catalog (orgomg.cwm.resource.relational.Catalog)5 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 PatternBuilder (org.talend.dq.pattern.PatternBuilder)3