Search in sources :

Example 6 with RangeRestriction

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

the class DomainHelper method createContiguousClosedBinsIntoDomain.

/**
 * Method "createContiguousClosedBinsIntoDomain".
 *
 * @param domainName the domain name (can be null)
 * @param bins the "closed" bins (the first value of array is the beginning of the bins and the last value of the
 * array is the end of bins)
 * @return the new Domain
 */
public static Domain createContiguousClosedBinsIntoDomain(String domainName, double[] bins) {
    Domain domain = createDomain(domainName);
    for (int i = 0; i < bins.length - 1; i++) {
        double min = bins[i];
        double max = bins[i + 1];
        RangeRestriction rangeRestriction = createRealRangeRestriction(min, max);
        domain.getRanges().add(rangeRestriction);
    }
    return domain;
}
Also used : RangeRestriction(org.talend.dataquality.domain.RangeRestriction) Domain(org.talend.dataquality.domain.Domain)

Example 7 with RangeRestriction

use of org.talend.dataquality.domain.RangeRestriction 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 8 with RangeRestriction

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

the class BinFrequencyIndicatorImpl method reset.

/**
 * if it has bin parameters and the range name is null,set it by concating min/max values.
 */
@Override
public boolean reset() {
    if (parameters == null || parameters.getBins() == null) {
        return super.reset();
    }
    EList<RangeRestriction> ranges = parameters.getBins().getRanges();
    for (RangeRestriction range : ranges) {
        if (range.getName() == null) {
            double minRealValue = DomainHelper.getRealValue(range.getLowerValue());
            double maxRealValue = DomainHelper.getRealValue(range.getUpperValue());
            String rangeName = analyzedElement.getName() + PluginConstant.SPACE_STRING + SqlPredicate.GREATER_EQUAL.getLiteral() + PluginConstant.SPACE_STRING + minRealValue + " AND " + analyzedElement.getName() + PluginConstant.SPACE_STRING + SqlPredicate.LESS.getLiteral() + PluginConstant.SPACE_STRING + maxRealValue;
            range.setName(rangeName);
        }
    }
    return super.reset();
}
Also used : RangeRestriction(org.talend.dataquality.domain.RangeRestriction)

Example 9 with RangeRestriction

use of org.talend.dataquality.domain.RangeRestriction 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)

Example 10 with RangeRestriction

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

the class BinLowFrequencyIndicatorImpl method reset.

/**
 * if it has bin parameters and the range name is null,set it by concating min/max values.
 */
@Override
public boolean reset() {
    if (parameters == null || parameters.getBins() == null) {
        return super.reset();
    }
    EList<RangeRestriction> ranges = parameters.getBins().getRanges();
    for (RangeRestriction range : ranges) {
        if (range.getName() == null) {
            double minRealValue = DomainHelper.getRealValue(range.getLowerValue());
            double maxRealValue = DomainHelper.getRealValue(range.getUpperValue());
            String rangeName = analyzedElement.getName() + PluginConstant.SPACE_STRING + SqlPredicate.GREATER_EQUAL.getLiteral() + PluginConstant.SPACE_STRING + minRealValue + " AND " + analyzedElement.getName() + PluginConstant.SPACE_STRING + SqlPredicate.LESS.getLiteral() + PluginConstant.SPACE_STRING + maxRealValue;
            range.setName(rangeName);
        }
    }
    return super.reset();
}
Also used : RangeRestriction(org.talend.dataquality.domain.RangeRestriction)

Aggregations

RangeRestriction (org.talend.dataquality.domain.RangeRestriction)22 Domain (org.talend.dataquality.domain.Domain)13 BooleanExpressionNode (org.talend.dataquality.expressions.BooleanExpressionNode)4 Expression (orgomg.cwm.objectmodel.core.Expression)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 TdColumn (org.talend.cwm.relational.TdColumn)1 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)1 DateGrain (org.talend.dataquality.indicators.DateGrain)1 DateParameters (org.talend.dataquality.indicators.DateParameters)1 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)1 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)1