Search in sources :

Example 1 with ActivityRestrictionDto

use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.

the class RolesPermissionServiceFacadeWebTier method getRoleActivitiesRestrictions.

@Override
public List<ActivityRestrictionDto> getRoleActivitiesRestrictions(Short roleId) {
    try {
        List<ActivityRestrictionDto> activityRestrictionDtoList = new ArrayList<ActivityRestrictionDto>();
        List<RoleActivityRestrictionBO> activityRestrictionBOList = legacyRolesPermissionsDao.getRoleActivitiesRestrictions(roleId);
        for (RoleActivityRestrictionBO activityRestrictionBO : activityRestrictionBOList) {
            Integer activityRestrictionId = activityRestrictionBO.getId();
            Short activityRestrictionTypeId = activityRestrictionBO.getActivityRestrictionType().getId();
            BigDecimal restrictionAmountValue = activityRestrictionBO.getRestrictionAmountValue();
            ActivityRestrictionDto activityRestrictionDto = new ActivityRestrictionDto(roleId, activityRestrictionId, activityRestrictionTypeId, restrictionAmountValue);
            activityRestrictionDtoList.add(activityRestrictionDto);
        }
        return activityRestrictionDtoList;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleActivityRestrictionBO(org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO) BigDecimal(java.math.BigDecimal) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with ActivityRestrictionDto

use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.

the class RoleTempleteBuilder method makeActivityRestrictionRow.

/**
     * This method builds row for activity restriction input (if is any defined for specified activity(permission)). 
     */
private void makeActivityRestrictionRow(Set<ActivityRestrictionTypeEntity> activityRestrictionTypes, StringBuilder buffer) {
    if (activityRestrictionTypes.size() > 0) {
        for (ActivityRestrictionTypeEntity activityRestrictionType : activityRestrictionTypes) {
            ActivityRestrictionDto activityRestrictionDto = activityRestrictionDtoMap.get(activityRestrictionType.getId());
            String activityRestrictionValue = "";
            if (activityRestrictionDto != null) {
                Money amount = new Money(Money.getDefaultCurrency(), activityRestrictionDto.getAmountValue());
                activityRestrictionValue = ConversionUtil.formatNumber(amount.toString());
            }
            String activityRestrictionTypeDescription = ApplicationContextProvider.getBean(MessageLookup.class).lookup(activityRestrictionType.getLookUpValue());
            String checked = "";
            if (!activityRestrictionValue.isEmpty()) {
                checked = " checked=\"checked\" ";
            }
            buffer.append("<tr>");
            buffer.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\">&nbsp; </td> ");
            buffer.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\">&nbsp; </td> ");
            buffer.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\">&nbsp; </td> ");
            buffer.append("<td width=\"3%\" bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\">");
            buffer.append("<input id=\"activityRestrictionCheckbox" + activityRestrictionType.getId() + "\" type=\"checkbox\" " + checked + " name=\"activityRestriction\" value=\"" + activityRestrictionType.getId() + "\" />");
            buffer.append("<td colspan=\"2\" bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\">");
            buffer.append("<span class=\"fontnormal\">");
            buffer.append(activityRestrictionTypeDescription);
            buffer.append("</span>");
            buffer.append("</td>");
            buffer.append("<td width=\"50%\" bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomLeftBorder\">");
            buffer.append("<input type=\"text\" value=\"" + activityRestrictionValue + "\" name=\"restrictionValue(" + activityRestrictionType.getId() + ")\" class=\"separatedNumber\" />");
            buffer.append("</td>");
            buffer.append("</tr>");
        }
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ActivityRestrictionTypeEntity(org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity) MessageLookup(org.mifos.application.master.MessageLookup) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto)

Example 3 with ActivityRestrictionDto

use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.

the class RolesPermissionsAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
    SessionUtils.setCollectionAttribute(RolesAndPermissionConstants.ACTIVITYLIST, ((RolesPermissionsBusinessService) getService()).getActivities(), request);
    Short roleId = Short.valueOf(rolesPermissionsActionForm.getId());
    RoleBO role = ((RolesPermissionsBusinessService) getService()).getRole(roleId);
    List<ActivityRestrictionDto> activityRestrictionDtoList = rolesPermissionServiceFacade.getRoleActivitiesRestrictions(roleId);
    Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
    for (ActivityRestrictionDto activityRestrictionDto : activityRestrictionDtoList) {
        activityRestrictionDtoMap.put(activityRestrictionDto.getActivityRestrictionTypeId(), activityRestrictionDto);
    }
    rolesPermissionsActionForm.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
    rolesPermissionsActionForm.setName(role.getName());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, role, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) HashMap(java.util.HashMap) RolesPermissionsActionForm(org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with ActivityRestrictionDto

use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.

the class RolesPermissionServiceFacadeWebTier method getActivitiesRestrictionsForUpdate.

private List<RoleActivityRestrictionBO> getActivitiesRestrictionsForUpdate(UserContext userContext, List<ActivityRestrictionDto> activityRestrictionDtoList) {
    try {
        List<RoleActivityRestrictionBO> activitiesRestrictions = new ArrayList<RoleActivityRestrictionBO>();
        for (ActivityRestrictionDto activityRestrictionDto : activityRestrictionDtoList) {
            RoleActivityRestrictionBO roleActivityRestrictionBO;
            if (activityRestrictionDto.getActivityRestrictionId() != null) {
                roleActivityRestrictionBO = legacyRolesPermissionsDao.getActivityRestrictionById(activityRestrictionDto.getActivityRestrictionId());
                roleActivityRestrictionBO.update(userContext.getId(), activityRestrictionDto.getAmountValue());
            } else {
                roleActivityRestrictionBO = new RoleActivityRestrictionBO(userContext);
                ActivityRestrictionTypeEntity activityRestrictionTypeEntity = legacyRolesPermissionsDao.getActivityRestrictionTypeEntity((short) activityRestrictionDto.getActivityRestrictionTypeId());
                roleActivityRestrictionBO.setActivityRestrictionType(activityRestrictionTypeEntity);
                roleActivityRestrictionBO.setRestrictionAmountValue(activityRestrictionDto.getAmountValue());
            }
            activitiesRestrictions.add(roleActivityRestrictionBO);
        }
        return activitiesRestrictions;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ActivityRestrictionTypeEntity(org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleActivityRestrictionBO(org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with ActivityRestrictionDto

use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.

the class RolesPermissionServiceFacadeWebTier method getActivitiesRestrictionsForCreate.

private List<RoleActivityRestrictionBO> getActivitiesRestrictionsForCreate(List<ActivityRestrictionDto> activityRestrictionDtoList, UserContext userContext) throws PersistenceException {
    List<RoleActivityRestrictionBO> activitiesRestrictions = new ArrayList<RoleActivityRestrictionBO>();
    for (ActivityRestrictionDto activityRestrictionDto : activityRestrictionDtoList) {
        RoleActivityRestrictionBO roleActivityRestrictionBO = new RoleActivityRestrictionBO(userContext);
        ActivityRestrictionTypeEntity activityRestrictionTypeEntity = legacyRolesPermissionsDao.getActivityRestrictionTypeEntity((short) activityRestrictionDto.getActivityRestrictionTypeId());
        roleActivityRestrictionBO.setActivityRestrictionType(activityRestrictionTypeEntity);
        roleActivityRestrictionBO.setRestrictionAmountValue(activityRestrictionDto.getAmountValue());
        activitiesRestrictions.add(roleActivityRestrictionBO);
    }
    return activitiesRestrictions;
}
Also used : ActivityRestrictionTypeEntity(org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity) ArrayList(java.util.ArrayList) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleActivityRestrictionBO(org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO)

Aggregations

ActivityRestrictionDto (org.mifos.dto.domain.ActivityRestrictionDto)7 ArrayList (java.util.ArrayList)4 ActivityRestrictionTypeEntity (org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity)3 RoleActivityRestrictionBO (org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO)3 BigDecimal (java.math.BigDecimal)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)2 RolesPermissionsActionForm (org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspException (javax.servlet.jsp.JspException)1 MessageLookup (org.mifos.application.master.MessageLookup)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1 Money (org.mifos.framework.util.helpers.Money)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1