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