Search in sources :

Example 1 with PentahoDateParameter

use of org.mifos.reports.pentaho.params.PentahoDateParameter in project head by mifos.

the class PentahoParamParser method parseDateParameter.

private PentahoDateParameter parseDateParameter(PlainParameter paramDefEntry) {
    PentahoDateParameter result = new PentahoDateParameter();
    Date defaultValue = (Date) paramDefEntry.getDefaultValue();
    if (defaultValue != null) {
        result.setDate(new LocalDate(defaultValue));
    }
    return result;
}
Also used : PentahoDateParameter(org.mifos.reports.pentaho.params.PentahoDateParameter) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 2 with PentahoDateParameter

use of org.mifos.reports.pentaho.params.PentahoDateParameter in project head by mifos.

the class PentahoParamParser method parseParamValue.

public Object parseParamValue(AbstractPentahoParameter param, ParameterDefinitionEntry paramDefEntry) throws ReflectionException {
    Object result = null;
    Class<?> clazz = paramDefEntry.getValueType();
    if (param instanceof PentahoDateParameter) {
        PentahoDateParameter dateParam = (PentahoDateParameter) param;
        LocalDate date = dateParam.getDate();
        Date javaDate = (date == null) ? null : date.toDateMidnight().toDate();
        result = ReflectionUtil.parseDateToClass(javaDate, clazz);
    } else if (param instanceof PentahoInputParameter) {
        PentahoInputParameter inputParam = (PentahoInputParameter) param;
        result = ReflectionUtil.parseStringToClass(inputParam.getValue(), clazz);
    } else if (param instanceof PentahoSingleSelectParameter) {
        PentahoSingleSelectParameter singleSelectParam = (PentahoSingleSelectParameter) param;
        result = ReflectionUtil.parseStringToClass(singleSelectParam.getSelectedValue(), clazz);
    } else if (param instanceof PentahoMultiSelectParameter) {
        PentahoMultiSelectParameter multiSelectParam = (PentahoMultiSelectParameter) param;
        Class<?> componentType = (clazz.isArray()) ? clazz.getComponentType() : clazz;
        result = ReflectionUtil.parseStringsToClass(multiSelectParam.getSelectedValues(), componentType);
    }
    return result;
}
Also used : PentahoDateParameter(org.mifos.reports.pentaho.params.PentahoDateParameter) PentahoSingleSelectParameter(org.mifos.reports.pentaho.params.PentahoSingleSelectParameter) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) PentahoMultiSelectParameter(org.mifos.reports.pentaho.params.PentahoMultiSelectParameter) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Aggregations

Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 PentahoDateParameter (org.mifos.reports.pentaho.params.PentahoDateParameter)2 PentahoInputParameter (org.mifos.reports.pentaho.params.PentahoInputParameter)1 PentahoMultiSelectParameter (org.mifos.reports.pentaho.params.PentahoMultiSelectParameter)1 PentahoSingleSelectParameter (org.mifos.reports.pentaho.params.PentahoSingleSelectParameter)1