use of org.mifos.framework.util.helpers.TransactionDemarcate 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.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class RolesPermissionsAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
rolesPermissionServiceFacade.updateRole(Short.parseShort(rolesPermissionsActionForm.getId()), userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
// MIFOS-3530: update all currently logged users
for (String loggedUser : getLoggedUsers(request)) {
this.authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext(loggedUser);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class RolesPermissionsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
rolesPermissionServiceFacade.createRole(userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class BirtAdminDocumentUploadAction method upload.
@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
FormFile formFile = uploadForm.getFile();
uploadFile(formFile);
AdminDocumentBO admindocBO = createOrUpdateAdminDocument(uploadForm.getAdminiDocumentTitle(), Short.valueOf("1"), formFile.getFileName());
AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountStateEntity acc : masterList) {
admindocaccstatemixBO = new AdminDocAccStateMixBO();
admindocaccstatemixBO.setAccountStateID(acc);
admindocaccstatemixBO.setAdminDocumentID(admindocBO);
legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
}
} else {
List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountActionEntity accountActionEntity : masterList) {
AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
adminDocAccActionMixBO.setAccountAction(accountActionEntity);
adminDocAccActionMixBO.setAdminDocument(admindocBO);
legacyAdminDocumentDao.createOrUpdate(adminDocAccActionMixBO);
}
}
request.setAttribute("report", admindocBO);
return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class BirtAdminDocumentUploadAction method updateSelectedStatus.
@TransactionDemarcate(joinToken = true)
private void updateSelectedStatus(HttpServletRequest request, BirtAdminDocumentUploadActionForm uploadForm) throws PageExpiredException, ServiceException {
List selectList = null;
if (uploadForm.getStatusList() != null) {
Short accountTypeId = Short.valueOf(uploadForm.getAccountTypeId());
if (accountTypeId.shortValue() <= 2) {
selectList = new ArrayList<AccountStateEntity>();
List<AccountStateEntity> masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
for (AccountStateEntity product : masterList) {
for (String productStatusId : uploadForm.getStatusList()) {
if (productStatusId != null && product.getId().intValue() == Integer.valueOf(productStatusId).intValue()) {
selectList.add(product);
}
}
}
} else {
Short currentLocaleId = (Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request);
selectList = new ArrayList<AccountActionEntity>();
List<AccountActionEntity> masterList = getAvailableLoanTransactions(currentLocaleId);
for (String accountActionId : uploadForm.getStatusList()) {
AccountActionTypes accountActionType = AccountActionTypes.fromInt(Integer.valueOf(accountActionId));
AccountActionEntity accountAction = new AccountBusinessService().getAccountAction(accountActionType.getValue(), currentLocaleId);
if (masterList.contains(accountAction)) {
selectList.add(accountAction);
}
}
}
}
SessionUtils.setCollectionAttribute("SelectedStatus", selectList, request);
}
Aggregations