Search in sources :

Example 1 with ParameterValues

use of org.pentaho.reporting.engine.classic.core.parameters.ParameterValues in project head by mifos.

the class PentahoParamParser method updatePossibleValuesForParam.

private Map<String, String> updatePossibleValuesForParam(ListParameter paramDefEntry, ParameterContext paramContext, Map<String, AbstractPentahoParameter> selectedValues) throws ReportDataFactoryException {
    Map<String, String> result = new HashMap<String, String>();
    String id;
    if (parameterIsOffice(paramDefEntry.getName())) {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    } else if (parameterIsCenter(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer$)|(.*officer_id$)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderUser(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            keyValue = searchKey("(selected_office$)|(.*BRANCH_NAME.*)", selectedValues, paramDefEntry.getName());
            if (!keyValue.equals("")) {
                id = (String) selectedValues.get(keyValue).getParamValue();
                if (!id.equals("-1")) {
                    List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderBranch(new Short(id));
                    for (CustomerDetailDto office : customerList) {
                        String key = office.getCustomerId().toString();
                        String value = office.getDisplayName();
                        result.put(key, value);
                    }
                } else {
                    ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                    for (int i = 0; i < paramValues.getRowCount(); i++) {
                        String key = String.valueOf(paramValues.getKeyValue(i));
                        String value = String.valueOf(paramValues.getTextValue(i));
                        result.put(key, value);
                    }
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsGroup(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveGroupForPentahoReport(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            ParameterValues paramValues = paramDefEntry.getValues(paramContext);
            for (int i = 0; i < paramValues.getRowCount(); i++) {
                String key = String.valueOf(paramValues.getKeyValue(i));
                String value = String.valueOf(paramValues.getTextValue(i));
                result.put(key, value);
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsOfficer(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*office$)|(.*office_id$)|(.*branch_id$)|(.*office$)|(.*selectedBranch.*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                ChangeAccountStatusDto changeAccountStatusDto = ApplicationContextProvider.getBean(LoanAccountServiceFacade.class).retrieveLoanOfficerDetailsForBranch(new Short(id));
                List<PersonnelDto> officers = changeAccountStatusDto.getLoanOfficers();
                for (PersonnelDto officer : officers) {
                    String key = officer.getPersonnelId().toString();
                    String value = officer.getDisplayName();
                    result.put(key, value);
                }
            }
            String key = "-1";
            String value = "All";
            result.put(key, value);
        }
    } else {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    }
    return result;
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) HashMap(java.util.HashMap) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) ArrayList(java.util.ArrayList) List(java.util.List) ParameterValues(org.pentaho.reporting.engine.classic.core.parameters.ParameterValues) CenterServiceFacade(org.mifos.application.servicefacade.CenterServiceFacade)

Example 2 with ParameterValues

use of org.pentaho.reporting.engine.classic.core.parameters.ParameterValues in project head by mifos.

the class PentahoParamParser method getPossibleValuesForParam.

private Map<String, String> getPossibleValuesForParam(ListParameter paramDefEntry, ParameterContext paramContext) throws ReportDataFactoryException {
    ParameterValues paramValues = paramDefEntry.getValues(paramContext);
    Map<String, String> result = new HashMap<String, String>();
    for (int i = 0; i < paramValues.getRowCount(); i++) {
        String key = String.valueOf(paramValues.getKeyValue(i));
        String value = String.valueOf(paramValues.getTextValue(i));
        result.put(key, value);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ParameterValues(org.pentaho.reporting.engine.classic.core.parameters.ParameterValues)

Aggregations

HashMap (java.util.HashMap)2 ParameterValues (org.pentaho.reporting.engine.classic.core.parameters.ParameterValues)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CenterServiceFacade (org.mifos.application.servicefacade.CenterServiceFacade)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 PersonnelDto (org.mifos.dto.domain.PersonnelDto)1 ChangeAccountStatusDto (org.mifos.dto.screen.ChangeAccountStatusDto)1