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\"> </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.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);
}
}
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;
}
Aggregations