use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.
the class RolesPermissionsActionForm method setActivityRestriction.
public void setActivityRestriction(String activtiyRestrictionTypeIdString) throws RolesPermissionException {
String amountValueString = restrictionsValues.get(activtiyRestrictionTypeIdString);
if (amountValueString != null && !amountValueString.isEmpty()) {
Short activtiyRestrictionTypeId = new Short(activtiyRestrictionTypeIdString);
BigDecimal amountValue = null;
try {
amountValue = new BigDecimal(amountValueString);
if (amountValue.compareTo(BigDecimal.ZERO) > 0) {
ActivityRestrictionDto activityRestrictionDto = activityRestrictionDtoMap.get(activtiyRestrictionTypeId);
if (activityRestrictionDto != null) {
activityRestrictionDto.setAmountValue(amountValue);
activityRestrictionDtoToPersistList.add(activityRestrictionDto);
} else {
// add new restriction for role
Short roleId = 0;
if (id != null) {
roleId = new Short(id);
}
activityRestrictionDto = new ActivityRestrictionDto(roleId, activtiyRestrictionTypeId, amountValue);
activityRestrictionDtoMap.put(activtiyRestrictionTypeId, activityRestrictionDto);
}
this.activityRestrictionDtoToPersistList.add(activityRestrictionDto);
} else {
invalidActivityRestrictionsValues.add(ActivityRestrictionType.getByValue(activtiyRestrictionTypeId));
}
} catch (NumberFormatException e) {
invalidActivityRestrictionsValues.add(ActivityRestrictionType.getByValue(activtiyRestrictionTypeId));
}
}
}
use of org.mifos.dto.domain.ActivityRestrictionDto in project head by mifos.
the class ActivityTag method doEndTag.
@SuppressWarnings("unchecked")
@Override
public int doEndTag() throws JspException {
RoleTempleteBuilder builder = new RoleTempleteBuilder();
List<ActivityEntity> activities;
try {
activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, (HttpServletRequest) pageContext.getRequest());
activities = filterActivities(activities);
RoleBO role = (RoleBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) pageContext.getSession().getAttribute("rolesPermissionsActionForm");
if (rolesPermissionsActionForm != null && rolesPermissionsActionForm.getActivities().size() > 0) {
List<ActivityEntity> flitered = filterActivities(getActivities(activities, rolesPermissionsActionForm.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
} else if (role != null) {
List<ActivityEntity> flitered = filterActivities(new ArrayList<ActivityEntity>(role.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
}
Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = rolesPermissionsActionForm.getActivityRestrictionDtoMap();
if (activityRestrictionDtoMap == null) {
activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
}
builder.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
StringBuilder sb = builder.getRolesTemplete(activities);
pageContext.getOut().print(sb.toString());
} catch (IOException e) {
throw new JspException(e);
} catch (PageExpiredException e1) {
throw new JspException(e1);
}
return EVAL_PAGE;
}
Aggregations