Search in sources :

Example 1 with PentahoSingleSelectParameter

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

the class PentahoParamParser method parseSingleListParameter.

private PentahoSingleSelectParameter parseSingleListParameter(ListParameter paramDefEntry, ParameterContext paramContext, Map<String, AbstractPentahoParameter> selectedValues, boolean update) throws ReportDataFactoryException {
    PentahoSingleSelectParameter result = new PentahoSingleSelectParameter();
    Map<String, String> possibleValues = null;
    if (update == false) {
        possibleValues = getPossibleValuesForParam(paramDefEntry, paramContext);
    } else {
        possibleValues = updatePossibleValuesForParam(paramDefEntry, paramContext, selectedValues);
    }
    result.setPossibleValues(possibleValues);
    Object defaultVal = paramDefEntry.getDefaultValue(paramContext);
    if (defaultVal != null && possibleValues.containsKey(String.valueOf(defaultVal))) {
        result.setSelectedValue(String.valueOf(defaultVal));
    } else if (defaultVal == null) {
        result.setSelectedValue(String.valueOf(-1));
    }
    return result;
}
Also used : PentahoSingleSelectParameter(org.mifos.reports.pentaho.params.PentahoSingleSelectParameter)

Example 2 with PentahoSingleSelectParameter

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

the class PentahoReportFormBean method setReportParameters.

public void setReportParameters(List<AbstractPentahoParameter> params) {
    Map<String, AbstractPentahoParameter> formParams = getAllParameteres();
    for (AbstractPentahoParameter param : params) {
        String paramName = param.getParamName();
        if (formParams.containsKey(paramName)) {
            if (param instanceof PentahoSingleSelectParameter) {
                PentahoSingleSelectParameter singleSelectParam = (PentahoSingleSelectParameter) param;
                PentahoSingleSelectParameter singleSelectFormParam = (PentahoSingleSelectParameter) formParams.get(paramName);
                singleSelectFormParam.setPossibleValues(singleSelectParam.getPossibleValues());
            } else if (param instanceof PentahoMultiSelectParameter) {
                PentahoMultiSelectParameter multiSelectParam = (PentahoMultiSelectParameter) param;
                PentahoMultiSelectParameter multiSelectFormParam = (PentahoMultiSelectParameter) formParams.get(paramName);
                multiSelectFormParam.setPossibleValuesOptions(multiSelectParam.getPossibleValuesOptions());
                for (String val : multiSelectFormParam.getSelectedValues()) {
                    String text = multiSelectFormParam.getPossibleValuesOptions().get(val);
                    multiSelectFormParam.getPossibleValuesOptions().remove(val);
                    multiSelectFormParam.getSelectedValuesOptions().put(val, text);
                }
            }
        } else if (!param.getParamName().equals("mifosLogoPath")) {
            addParameter(param);
        }
    }
}
Also used : AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) PentahoSingleSelectParameter(org.mifos.reports.pentaho.params.PentahoSingleSelectParameter) PentahoMultiSelectParameter(org.mifos.reports.pentaho.params.PentahoMultiSelectParameter)

Example 3 with PentahoSingleSelectParameter

use of org.mifos.reports.pentaho.params.PentahoSingleSelectParameter 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

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