Search in sources :

Example 21 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class LegacyMasterDao method deleteValueListElement.

/**
     * This method is intended to delete a single LookUpValueEntity and all its
     * associated LookUpValueLocaleEntity objects. The primary purpose is for
     * test script cleanup, since deletion of LookUpValueEntity elements is not
     * allowed in the main app.
     *
     * It would be nicer for this to operate on objects rather than ids, but it
     * is a first step that works.
     */
public void deleteValueListElement(final Integer lookupValueEntityId) throws PersistenceException {
    LookUpValueEntity lookUpValueEntity = getPersistentObject(LookUpValueEntity.class, lookupValueEntityId);
    delete(lookUpValueEntity);
    ApplicationContextProvider.getBean(MessageLookup.class).deleteKey(lookUpValueEntity.getLookUpName());
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 22 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class ApplicationConfigurationDaoHibernate method findLookupValues.

@Override
@SuppressWarnings("unchecked")
public List<LookUpValueEntity> findLookupValues() {
    List<LookUpValueEntity> values = null;
    Session session = StaticHibernateUtil.getSessionTL();
    values = session.getNamedQuery(NamedQueryConstants.GET_LOOKUPVALUES).list();
    if (values != null) {
        for (LookUpValueEntity value : values) {
            Set<LookUpValueLocaleEntity> localeValues = value.getLookUpValueLocales();
            value.getLookUpName();
            if (localeValues != null) {
                for (LookUpValueLocaleEntity locale : localeValues) {
                    locale.getLookUpValue();
                    locale.getLocaleId();
                }
            }
        }
    }
    return values;
}
Also used : LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Session(org.hibernate.Session)

Example 23 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class OfficeDaoHibernate method findOfficeLevelsWithConfiguration.

@SuppressWarnings("unchecked")
@Override
public OfficeLevelDto findOfficeLevelsWithConfiguration() {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    List<OfficeLevelEntity> officeLevelEntities = (List<OfficeLevelEntity>) genericDao.executeNamedQuery("officeLevel.getOfficeLevelsWithConfiguration", queryParameters);
    if (officeLevelEntities == null) {
        officeLevelEntities = new ArrayList<OfficeLevelEntity>();
    }
    OfficeLevelDto officeLevels = new OfficeLevelDto();
    for (OfficeLevelEntity officeLevelEntity : officeLevelEntities) {
        LookUpValueEntity lookupValue = officeLevelEntity.getLookUpValue();
        String messageText = lookupValue.getMessageText();
        if (StringUtils.isBlank(messageText)) {
            messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
        }
        OfficeLevel level = OfficeLevel.getOfficeLevel(officeLevelEntity.getId());
        switch(level) {
            case HEADOFFICE:
                officeLevels.setHeadOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setHeadOfficeNameKey(messageText);
                break;
            case REGIONALOFFICE:
                officeLevels.setRegionalOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setRegionalOfficeNameKey(messageText);
                break;
            case SUBREGIONALOFFICE:
                officeLevels.setSubRegionalOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setSubRegionalOfficeNameKey(messageText);
                break;
            case AREAOFFICE:
                officeLevels.setAreaOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setAreaOfficeNameKey(messageText);
                break;
            case BRANCHOFFICE:
                officeLevels.setBranchOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setBranchOfficeNameKey(messageText);
                break;
            default:
                break;
        }
    }
    return officeLevels;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) OfficeLevelDto(org.mifos.dto.domain.OfficeLevelDto) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 24 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class OfficeHierarchyServiceImpl method updateApplicationLabels.

@Override
public void updateApplicationLabels(List<OfficeLevelEntity> changedOfficeLabels, List<LookUpEntity> lookupEntities, List<GracePeriodTypeEntity> gracePeriods, List<LookUpValueEntity> accountStatuses) {
    try {
        transactionHelper.startTransaction();
        for (OfficeLevelEntity entity : changedOfficeLabels) {
            officeDao.save(entity);
            LookUpValueEntity lookupValue = entity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
        }
        for (GracePeriodTypeEntity entity : gracePeriods) {
            applicationConfigurationDao.save(entity);
            LookUpValueEntity lookupValue = entity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
        }
        for (LookUpEntity entity : lookupEntities) {
            applicationConfigurationDao.save(entity);
            ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getEntityType(), entity.findLabel());
        }
        for (LookUpValueEntity entity : accountStatuses) {
            applicationConfigurationDao.save(entity);
        }
        transactionHelper.commitTransaction();
        if (!accountStatuses.isEmpty()) {
            MenuRepository.getInstance().removeMenuForAllLocale();
        }
    } catch (BusinessRuleException e) {
        transactionHelper.rollbackTransaction();
        throw e;
    } catch (Exception e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) LookUpEntity(org.mifos.application.master.business.LookUpEntity) MessageLookup(org.mifos.application.master.MessageLookup) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) BusinessRuleException(org.mifos.service.BusinessRuleException) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 25 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class FeeActionStrutsTest method testSuccessfulManage_RateFee.

@Test
public void testSuccessfulManage_RateFee() throws Exception {
    fee = TestObjectFactory.createOneTimeRateFee("One Time Fee", FeeCategory.ALLCUSTOMERS, 12.34, FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
    LookUpValueEntity lookUpValue = new LookUpValueEntity();
    fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
    fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
    ((RateFeeBO) fee).getFeeFormula().setLookUpValue(lookUpValue);
    String feeId = fee.getFeeId().toString();
    request.setAttribute("feeModel", TestObjectFactory.getRateBasedFee(feeId, "StatusID", 12.34, "1"));
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, fee, request);
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("feeId", feeId);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.manage_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    Assert.assertEquals("12.34", actionForm.getRate());
    Assert.assertEquals("1", actionForm.getFeeFormula());
    Assert.assertNull(actionForm.getAmount());
    Assert.assertEquals("The size of master data for status", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(FeeConstants.STATUSLIST, request)).size());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Test(org.junit.Test)

Aggregations

LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)38 Test (org.junit.Test)11 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)9 LookUpEntity (org.mifos.application.master.business.LookUpEntity)8 MessageLookup (org.mifos.application.master.MessageLookup)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 SystemException (org.mifos.framework.exceptions.SystemException)5 LookUpValueLocaleEntity (org.mifos.application.master.business.LookUpValueLocaleEntity)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)3 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)3 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)3 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)3 FeeActionForm (org.mifos.accounts.fees.struts.actionforms.FeeActionForm)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)3