Search in sources :

Example 1 with ActivityRestrictionTypeEntity

use of org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity 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 2 with ActivityRestrictionTypeEntity

use of org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity 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 3 with ActivityRestrictionTypeEntity

use of org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity 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)3 ActivityRestrictionTypeEntity (org.mifos.security.rolesandpermission.business.ActivityRestrictionTypeEntity)3 ArrayList (java.util.ArrayList)2 RoleActivityRestrictionBO (org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO)2 MessageLookup (org.mifos.application.master.MessageLookup)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 Money (org.mifos.framework.util.helpers.Money)1