Search in sources :

Example 91 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class PentahoParamParser method parseReportParams.

public List<AbstractPentahoParameter> parseReportParams(MasterReport report, HttpServletRequest request, Map<String, AbstractPentahoParameter> selectedValues, boolean update) {
    ParameterContext paramContext = null;
    try {
        paramContext = new DefaultParameterContext(report);
        ReportParameterDefinition paramDefinition = report.getParameterDefinition();
        List<AbstractPentahoParameter> result = new ArrayList<AbstractPentahoParameter>();
        for (ParameterDefinitionEntry paramDefEntry : paramDefinition.getParameterDefinitions()) {
            result.add(parseParam(paramDefEntry, paramContext, selectedValues, update));
        }
        return result;
    } catch (ReportDataFactoryException ex) {
        throw new JNDIException("Problem with Pentaho Reports", request);
    } catch (Exception ex) {
        throw new MifosRuntimeException(ex);
    } finally {
        if (paramContext != null) {
            try {
                paramContext.close();
            } catch (ReportDataFactoryException ex) {
                logger.error("Exception while closing parameter context", ex);
            }
        }
    }
}
Also used : ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ParameterDefinitionEntry(org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry) ArrayList(java.util.ArrayList) ReportDataFactoryException(org.pentaho.reporting.engine.classic.core.ReportDataFactoryException) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ParameterContext(org.pentaho.reporting.engine.classic.core.parameters.ParameterContext) ReportDataFactoryException(org.pentaho.reporting.engine.classic.core.ReportDataFactoryException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 92 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class ImportClientsController method parseFile.

public ParsedClientsDto parseFile(ImportClientsFormBean importClientsFormBean) {
    ParsedClientsDto result = null;
    CommonsMultipartFile file = importClientsFormBean.getFile();
    InputStream is = null;
    if (file == null) {
        throw new MifosRuntimeException("File cannot be null");
    }
    try {
        is = file.getInputStream();
        result = importClientsServiceFacade.parseImportClients(is);
    } catch (IOException ex) {
        result = importClientsServiceFacade.createDtoFromSingleError(ex.getMessage());
    } finally {
        closeStream(is);
        importClientsFormBean.setFile(null);
    }
    return result;
}
Also used : ParsedClientsDto(org.mifos.dto.domain.ParsedClientsDto) InputStream(java.io.InputStream) IOException(java.io.IOException) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 93 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class ImportLoansController method parseFile.

/**
     * Parse xls file.
     * @param importLoansFormBean
     * @return
     */
public ParsedLoansDto parseFile(ImportLoansFormBean importLoansFormBean) {
    ParsedLoansDto result = null;
    CommonsMultipartFile file = importLoansFormBean.getFile();
    InputStream is = null;
    if (file == null) {
        throw new MifosRuntimeException("File cannot be null");
    }
    try {
        is = file.getInputStream();
        result = importLSServiceFacade.parseImportLoans(is);
    } catch (IOException ex) {
        result = importLSServiceFacade.createLoansDtoFromSingleError(ex.getMessage());
    } finally {
        closeStream(is);
        importLoansFormBean.setFile(null);
    }
    return result;
}
Also used : InputStream(java.io.InputStream) ParsedLoansDto(org.mifos.dto.domain.ParsedLoansDto) IOException(java.io.IOException) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 94 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class ImportSavingsController method parseFile.

public ParsedSavingsDto parseFile(ImportSavingsFormBean importSavingsFormBean) {
    ParsedSavingsDto result = null;
    CommonsMultipartFile file = importSavingsFormBean.getFile();
    InputStream is = null;
    if (file == null) {
        throw new MifosRuntimeException("File cannot be null");
    }
    try {
        is = file.getInputStream();
        result = importLoansSavingsFacade.parseImportSavings(is);
    } catch (IOException ex) {
        result = importLoansSavingsFacade.createSavingsDtoFromSingleError(ex.getMessage());
    } finally {
        closeStream(is);
        importSavingsFormBean.setFile(null);
    }
    return result;
}
Also used : InputStream(java.io.InputStream) ParsedSavingsDto(org.mifos.dto.domain.ParsedSavingsDto) IOException(java.io.IOException) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 95 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class SaveCollectionSheetStructureValidatorIntegrationTest method testShouldGetINVALID_TOP_CUSTOMERIfTopCustomerNotFound.

@Test
public void testShouldGetINVALID_TOP_CUSTOMERIfTopCustomerNotFound() throws Exception {
    LocalDate validDate = new LocalDate();
    Short validPaymentType = PaymentTypes.CHEQUE.getValue();
    Short validUserId = Short.valueOf("1");
    Integer invalidCustomerId = 500000;
    SaveCollectionSheetDto saveCollectionSheet = null;
    try {
        List<SaveCollectionSheetCustomerDto> saveCollectionSheetCustomers = new ArrayList<SaveCollectionSheetCustomerDto>();
        SaveCollectionSheetCustomerDto saveCollectionSheetCustomer = new SaveCollectionSheetCustomerDto(invalidCustomerId, null, null, null, null, null, null);
        saveCollectionSheetCustomers.add(saveCollectionSheetCustomer);
        saveCollectionSheet = new SaveCollectionSheetDto(saveCollectionSheetCustomers, validPaymentType, validDate, null, null, validUserId);
    } catch (SaveCollectionSheetException e) {
        throw new MifosRuntimeException(e.printInvalidSaveCollectionSheetReasons());
    }
    verifyInvalidReason(saveCollectionSheet, InvalidSaveCollectionSheetReason.INVALID_TOP_CUSTOMER);
}
Also used : ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Test(org.junit.Test)

Aggregations

MifosRuntimeException (org.mifos.core.MifosRuntimeException)305 PersistenceException (org.mifos.framework.exceptions.PersistenceException)136 ArrayList (java.util.ArrayList)102 BusinessRuleException (org.mifos.service.BusinessRuleException)95 UserContext (org.mifos.security.util.UserContext)94 MifosUser (org.mifos.security.MifosUser)87 AccountException (org.mifos.accounts.exceptions.AccountException)79 ServiceException (org.mifos.framework.exceptions.ServiceException)69 ApplicationException (org.mifos.framework.exceptions.ApplicationException)48 LoanBO (org.mifos.accounts.loan.business.LoanBO)41 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)39 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)37 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)36 LocalDate (org.joda.time.LocalDate)35 CustomerBO (org.mifos.customers.business.CustomerBO)29 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)28 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)27 CustomerException (org.mifos.customers.exceptions.CustomerException)27 Money (org.mifos.framework.util.helpers.Money)27 AccountBO (org.mifos.accounts.business.AccountBO)25