Search in sources :

Example 6 with DateGrain

use of org.talend.dataquality.indicators.DateGrain in project tdq-studio-se by Talend.

the class DateParametersItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object) {
    DateGrain labelValue = ((DateParameters) object).getDateAggregationType();
    String label = labelValue == null ? null : labelValue.toString();
    return label == null || label.length() == 0 ? getString("_UI_DateParameters_type") : getString("_UI_DateParameters_type") + " " + label;
}
Also used : DateGrain(org.talend.dataquality.indicators.DateGrain) DateParameters(org.talend.dataquality.indicators.DateParameters)

Example 7 with DateGrain

use of org.talend.dataquality.indicators.DateGrain in project tdq-studio-se by Talend.

the class UserDefIndicatorImpl method storeSqlResultsFrequency.

/**
 * DOC xqliu Comment method "storeSqlResultsFrequency".
 *
 * @param objects
 * @return
 */
@SuppressWarnings("fallthrough")
private boolean storeSqlResultsFrequency(List<Object[]> objects) {
    // handle case when frequencies are computed on dates.
    int nbColumns = 2;
    if (hasDateGrainParameter()) {
        DateGrain dategrain = getParameters().getDateParameters().getDateAggregationType();
        switch(dategrain) {
            case DAY:
                nbColumns++;
            // no break
            case WEEK:
                nbColumns++;
            // no break
            case MONTH:
                nbColumns++;
            // no break
            case QUARTER:
                nbColumns++;
            // no break
            case YEAR:
                break;
            default:
                break;
        }
    }
    // handle case when no row is returned because there is no value.
    if (objects.isEmpty()) {
        if (log.isInfoEnabled()) {
            log.info("Query for frequency table did not return any result. " + "Check the options of this indicator. Bins must contains some data.");
        }
        this.setValueToFreq(new HashMap<Object, Long>());
        return true;
    }
    // else we got some values
    if (!checkResults(objects, nbColumns)) {
        return false;
    }
    HashMap<Object, Long> mapVal2Freq = new HashMap<Object, Long>();
    boolean debug = log.isDebugEnabled();
    StringBuffer matrix = debug ? new StringBuffer() : null;
    for (Object[] value2freq : objects) {
        if (value2freq.length != nbColumns) {
            log.error("Problem with result for Frequency indicator");
            return false;
        }
        Object value = getValueFields(value2freq);
        Long freq = Long.valueOf(String.valueOf(value2freq[nbColumns - 1]));
        mapVal2Freq.put(value, freq);
        if (debug) {
            matrix.append("\n").append("\"").append(value).append("\"").append(",").append(freq);
        }
    }
    if (debug) {
        log.debug(matrix);
    }
    this.setValueToFreq(mapVal2Freq);
    return true;
}
Also used : DateGrain(org.talend.dataquality.indicators.DateGrain) HashMap(java.util.HashMap)

Aggregations

DateGrain (org.talend.dataquality.indicators.DateGrain)7 DateParameters (org.talend.dataquality.indicators.DateParameters)3 HashMap (java.util.HashMap)2 TdColumn (org.talend.cwm.relational.TdColumn)2 Domain (org.talend.dataquality.domain.Domain)2 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 ArrayList (java.util.ArrayList)1 EClass (org.eclipse.emf.ecore.EClass)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Group (org.eclipse.swt.widgets.Group)1 TdExpression (org.talend.cwm.relational.TdExpression)1 RangeRestriction (org.talend.dataquality.domain.RangeRestriction)1 TextParameters (org.talend.dataquality.indicators.TextParameters)1 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)1 Expression (orgomg.cwm.objectmodel.core.Expression)1