Search in sources :

Example 31 with Domain

use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.

the class AnalysisHelper method createDomain.

private static Domain createDomain(Analysis analysis, String datafilterString, String alias) {
    // by default use same name as the analysis. This is ok as long as there is only one datafilter.
    Domain domain = DomainHelper.createDomain(analysis.getName() + alias);
    RangeRestriction rangeRestriction = DomainHelper.addRangeRestriction(domain);
    BooleanExpressionNode expressionNode = BooleanExpressionHelper.createBooleanExpressionNode(datafilterString);
    rangeRestriction.setExpressions(expressionNode);
    return domain;
}
Also used : BooleanExpressionNode(org.talend.dataquality.expressions.BooleanExpressionNode) RangeRestriction(org.talend.dataquality.domain.RangeRestriction) Domain(org.talend.dataquality.domain.Domain)

Example 32 with Domain

use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.

the class EMailValidationIndicator method initParameters.

boolean initParameters() {
    // Check prerequisite
    IndicatorParameters param = this.getParameters();
    if (param == null) {
        // $NON-NLS-1$
        log.error("No parameter set in the user defined indicator " + this.getName());
        return false;
    }
    Domain indicatorValidDomain = param.getIndicatorValidDomain();
    if (indicatorValidDomain == null) {
        // $NON-NLS-1$
        log.error("No parameter set in the user defined indicator " + this.getName());
        return false;
    }
    // else retrieve email from parameter
    EList<JavaUDIIndicatorParameter> javaUDIIndicatorParameter = indicatorValidDomain.getJavaUDIIndicatorParameter();
    for (JavaUDIIndicatorParameter p : javaUDIIndicatorParameter) {
        if (EMAIL_PARAM.equalsIgnoreCase(p.getKey())) {
            this.emailAddress = p.getValue();
        } else if (INVALID_PARAM.equalsIgnoreCase(p.getKey())) {
            this.storeInvalidData = true;
            // TODO add more checks on the file
            try {
                this.tempInvalidData = new StringBuffer();
                this.os = new FileOutputStream(new File(p.getValue()));
            } catch (FileNotFoundException e) {
                // $NON-NLS-1$
                log.error("Invalid file path in the user defined indicator: " + this.getName(), e);
                return false;
            }
        } else if (BUFFER_SIZE_PARAM.equalsIgnoreCase(p.getKey())) {
            try {
                this.buffSize = Integer.valueOf(p.getValue());
            } catch (Exception e) {
                // $NON-NLS-1$
                log.error("Invalid buffer size: " + p.getValue(), e);
                return false;
            }
        } else {
            // log warn but keep running (don't return false)
            if (!NAMING_PARAM.equalsIgnoreCase(p.getKey())) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                log.warn("Unknown parameter given to UDI: " + this.getName() + ": " + p.getKey() + " = " + p.getValue());
            }
        }
    }
    if (!this.isAddressValid(emailAddress)) {
        log.error(// $NON-NLS-1$ //$NON-NLS-2$
        "Invalid sender email set in parameters of the user defined indicator \"" + this.getName() + "\": " + emailAddress);
        return false;
    }
    return true;
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) FileOutputStream(java.io.FileOutputStream) JavaUDIIndicatorParameter(org.talend.dataquality.domain.JavaUDIIndicatorParameter) FileNotFoundException(java.io.FileNotFoundException) Domain(org.talend.dataquality.domain.Domain) File(java.io.File) NamingException(javax.naming.NamingException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 33 with Domain

use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.

the class IndicatorParametersImpl method basicSetIndicatorValidDomain.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated
 */
public NotificationChain basicSetIndicatorValidDomain(Domain newIndicatorValidDomain, NotificationChain msgs) {
    Domain oldIndicatorValidDomain = indicatorValidDomain;
    indicatorValidDomain = newIndicatorValidDomain;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IndicatorsPackage.INDICATOR_PARAMETERS__INDICATOR_VALID_DOMAIN, oldIndicatorValidDomain, newIndicatorValidDomain);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Domain(org.talend.dataquality.domain.Domain)

Example 34 with Domain

use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.

the class IndicatorParametersImpl method basicSetBins.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated
 */
public NotificationChain basicSetBins(Domain newBins, NotificationChain msgs) {
    Domain oldBins = bins;
    bins = newBins;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IndicatorsPackage.INDICATOR_PARAMETERS__BINS, oldBins, newBins);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Domain(org.talend.dataquality.domain.Domain)

Example 35 with Domain

use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.

the class BinLowFrequencyIndicatorImpl method getGroupLabel.

/*
     * (non-Javadoc)
     * 
     * if the bin parameter is set,look range name as a new name.
     */
protected String getGroupLabel(Object name) {
    if (name == null) {
        return null;
    }
    if (parameters != null) {
        Domain bins = parameters.getBins();
        if (bins != null) {
            EList<RangeRestriction> ranges = bins.getRanges();
            for (RangeRestriction range : ranges) {
                double minRealValue = DomainHelper.getRealValue(range.getLowerValue());
                double maxRealValue = DomainHelper.getRealValue(range.getUpperValue());
                double inputValue = Double.valueOf(name.toString());
                if (minRealValue <= inputValue && inputValue < maxRealValue) {
                    return range.getName();
                }
            }
            // if the data(name) is not in these ranges,return null and ignor it.
            return null;
        }
    }
    return name.toString();
}
Also used : RangeRestriction(org.talend.dataquality.domain.RangeRestriction) Domain(org.talend.dataquality.domain.Domain)

Aggregations

Domain (org.talend.dataquality.domain.Domain)68 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)27 Pattern (org.talend.dataquality.domain.pattern.Pattern)16 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)14 Expression (orgomg.cwm.objectmodel.core.Expression)14 TdColumn (org.talend.cwm.relational.TdColumn)13 TdExpression (org.talend.cwm.relational.TdExpression)13 RangeRestriction (org.talend.dataquality.domain.RangeRestriction)13 Test (org.junit.Test)12 Analysis (org.talend.dataquality.analysis.Analysis)12 ArrayList (java.util.ArrayList)10 ReturnCode (org.talend.utils.sugars.ReturnCode)9 Indicator (org.talend.dataquality.indicators.Indicator)6 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 Connection (org.talend.core.model.metadata.builder.connection.Connection)5 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)5