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;
}
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;
}
Aggregations