Search in sources :

Example 31 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class AuditConfiguration method fetchMasterData.

private void fetchMasterData(String entityName, Short localeId, String classPath) throws SystemException {
    Class clazz = null;
    try {
        clazz = Thread.currentThread().getContextClassLoader().loadClass(classPath);
    } catch (ClassNotFoundException e) {
        throw new SystemException(e);
    }
    List<MasterDataEntity> masterDataList = legacyMasterDao.findMasterDataEntities(clazz);
    for (MasterDataEntity masterDataEntity : masterDataList) {
        if (masterDataEntity instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelStatusEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelLevelEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof OfficeLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((OfficeLevelEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof OfficeStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((OfficeStatusEntity) masterDataEntity).setName(name);
        }
        valueMap.put(masterDataEntity.getId().toString(), masterDataEntity.getName());
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeStatusEntity(org.mifos.customers.office.business.OfficeStatusEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity)

Example 32 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class AuditConfiguration method callMethodToCreateValueMap.

//FIXME I use reflect for invoking methods of Dao (Not type safe)
private Map<String, String> callMethodToCreateValueMap(String methodName, Short localeId) throws SystemException {
    valueMap = new HashMap<String, String>();
    Method[] methods = LegacyAuditLookupValuesDao.class.getMethods();
    for (Method method : methods) {
        if (method.getName().equalsIgnoreCase(methodName)) {
            try {
                LegacyAuditLookupValuesDao legacyAuditLookupValuesDao = ApplicationContextProvider.getBean(LegacyAuditLookupValuesDao.class);
                valueMap = (Map<String, String>) method.invoke(legacyAuditLookupValuesDao, new Object[] { localeId });
            } catch (Exception e) {
                throw new SystemException(e);
            }
        }
    }
    return valueMap;
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) Method(java.lang.reflect.Method) LegacyAuditLookupValuesDao(org.mifos.framework.components.audit.persistence.LegacyAuditLookupValuesDao) SystemException(org.mifos.framework.exceptions.SystemException)

Example 33 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class XMLParser method parser.

public ColumnPropertyMapping parser() throws SystemException {
    Document document = null;
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.parse(MifosResourceUtil.getClassPathResourceAsStream("org/mifos/framework/util/resources/audit/ColumnMapping.xml"));
        getColumnPropertyMapping(document);
    } catch (ParserConfigurationException e) {
        throw new SystemException(e);
    } catch (IOException e) {
        throw new SystemException(e);
    } catch (SAXParseException e) {
        throw new SystemException(e);
    } catch (SAXException e) {
        throw new SystemException(e);
    }
    return columnPropertyMapping;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SystemException(org.mifos.framework.exceptions.SystemException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Example 34 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class LanguageUpgrade method getLargestLanguageId.

private int getLargestLanguageId(Connection connection) throws SQLException {
    Statement statement = connection.createStatement();
    ResultSet results = statement.executeQuery("select max(lang_id) from language");
    if (!results.next()) {
        throw new SystemException(SystemException.DEFAULT_KEY, "Did not find an existing lang_id in language table");
    }
    int largestLangId = results.getInt(1);
    results.close();
    statement.close();
    return largestLangId;
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet)

Example 35 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class BulkEntryTag method doStartTag.

@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    JspWriter out = pageContext.getOut();
    StringBuilder builder = new StringBuilder();
    CollectionSheetEntryGridDto bulkEntry = null;
    try {
        bulkEntry = (CollectionSheetEntryGridDto) SessionUtils.getAttribute(CollectionSheetEntryConstants.BULKENTRY, request);
    } catch (PageExpiredException e) {
        logger.error("Page expired getting BulkEntryBO.");
    }
    if (null != bulkEntry) {
        List<ProductDto> loanProducts = bulkEntry.getLoanProducts();
        List<ProductDto> savingsProducts = bulkEntry.getSavingProducts();
        try {
            final List<CustomValueListElementDto> custAttTypes = (List<CustomValueListElementDto>) SessionUtils.getAttribute(CollectionSheetEntryConstants.CUSTOMERATTENDANCETYPES, request);
            String method = request.getParameter(CollectionSheetEntryConstants.METHOD);
            generateTagData(bulkEntry, loanProducts, savingsProducts, custAttTypes, method, builder);
        } catch (ApplicationException ae) {
            throw new JspException(ae);
        } catch (SystemException se) {
            throw new JspException(se);
        }
    }
    try {
        out.write(builder.toString());
    } catch (IOException ioe) {
        throw new JspException(ioe);
    }
    return SKIP_BODY;
}
Also used : CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SystemException(org.mifos.framework.exceptions.SystemException) List(java.util.List) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Aggregations

SystemException (org.mifos.framework.exceptions.SystemException)53 Test (org.junit.Test)21 ApplicationException (org.mifos.framework.exceptions.ApplicationException)13 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)10 HibernateException (org.hibernate.HibernateException)7 Session (org.hibernate.Session)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 HibernateProcessException (org.mifos.framework.exceptions.HibernateProcessException)7 ReportException (org.mifos.reports.exceptions.ReportException)7 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 IOException (java.io.IOException)3 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 ArrayList (java.util.ArrayList)3 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 PreparedStatement (java.sql.PreparedStatement)2