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);
}
}
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\"> </td> ");
buffer.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\"> </td> ");
buffer.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\"> </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>");
}
}
}
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());
}
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);
}
}
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;
}
Aggregations