use of org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm in project head by mifos.
the class BirtAdminDocumentUploadAction method editThenUpload.
@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward editThenUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
FormFile formFile = uploadForm.getFile();
boolean newFile = false;
if (StringUtils.isEmpty(formFile.getFileName())) {
formFile.destroy();
} else {
uploadFile(formFile);
newFile = true;
}
AdminDocumentBO admindoc = legacyAdminDocumentDao.getAdminDocumentById(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
admindoc.setAdminDocumentName(uploadForm.getAdminiDocumentTitle());
admindoc.setIsActive(Short.valueOf(uploadForm.getIsActive()));
if (newFile) {
admindoc.setAdminDocumentIdentifier(formFile.getFileName());
}
legacyAdminDocumentDao.createOrUpdate(admindoc);
if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
for (AdminDocAccStateMixBO temp : admindoclist) {
legacyAdminDocAccStateMixDao.delete(temp);
}
AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
for (AccountStateEntity acc : masterList) {
admindocaccstatemixBO = new AdminDocAccStateMixBO();
admindocaccstatemixBO.setAccountStateID(acc);
admindocaccstatemixBO.setAdminDocumentID(admindoc);
legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
}
} else {
List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
List<AdminDocAccActionMixBO> admindoclist = legacyAdminDocAccStateMixDao.getAccActionMixByAdminDocument(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
for (AdminDocAccActionMixBO temp : admindoclist) {
legacyAdminDocAccStateMixDao.delete(temp);
}
AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
for (AccountActionEntity acc : masterList) {
adminDocAccActionMixBO = new AdminDocAccActionMixBO();
adminDocAccActionMixBO.setAccountAction(acc);
adminDocAccActionMixBO.setAdminDocument(admindoc);
legacyAdminDocAccStateMixDao.createOrUpdate(adminDocAccActionMixBO);
}
}
return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
use of org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm in project head by mifos.
the class BirtAdminDocumentUploadAction method edit.
@TransactionDemarcate(saveToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm birtReportsUploadActionForm = (BirtAdminDocumentUploadActionForm) form;
List masterList = null;
List selectedlist = null;
AdminDocumentBO adminDocumentBO = this.legacyAdminDocumentDao.getAdminDocumentById(Short.valueOf(request.getParameter("admindocId")));
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(Short.valueOf(request.getParameter("admindocId")));
if (admindoclist != null && !admindoclist.isEmpty()) {
SessionUtils.setAttribute("admindocId", adminDocumentBO.getAdmindocId(), request);
birtReportsUploadActionForm.setAdminiDocumentTitle(adminDocumentBO.getAdminDocumentName());
birtReportsUploadActionForm.setAccountTypeId(admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().toString());
birtReportsUploadActionForm.setIsActive(adminDocumentBO.getIsActive().toString());
selectedlist = new ArrayList<AccountStateEntity>();
for (AdminDocAccStateMixBO admindoc : admindoclist) {
selectedlist.add(admindoc.getAccountStateID());
}
if (birtReportsUploadActionForm.getAccountTypeId() != null) {
Short accountTypeId = Short.valueOf(birtReportsUploadActionForm.getAccountTypeId());
masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
masterList.removeAll(selectedlist);
}
} else if (adminDocumentBO != null) {
List<AdminDocAccActionMixBO> adminDocAccActionMixList = legacyAdminDocAccStateMixDao.getAccActionMixByAdminDocument(Short.valueOf(request.getParameter("admindocId")));
SessionUtils.setAttribute("admindocId", adminDocumentBO.getAdmindocId(), request);
birtReportsUploadActionForm.setAdminiDocumentTitle(adminDocumentBO.getAdminDocumentName());
birtReportsUploadActionForm.setAccountTypeId("3");
birtReportsUploadActionForm.setIsActive(adminDocumentBO.getIsActive().toString());
masterList = getAvailableLoanTransactions((Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request));
if ((adminDocAccActionMixList != null) && (!adminDocAccActionMixList.isEmpty())) {
selectedlist = new ArrayList<AccountActionEntity>();
for (AdminDocAccActionMixBO admindoc : adminDocAccActionMixList) {
selectedlist.add(admindoc.getAccountAction());
}
masterList.removeAll(selectedlist);
}
}
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.AVAILABLEACCOUNTSTATUS, masterList, request);
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.SELECTEDACCOUNTSTATUS, selectedlist, request);
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTTYPELIST, getProductTypes(), request);
request.setAttribute(Constants.BUSINESS_KEY, adminDocumentBO);
birtReportsUploadActionForm.setStatusList(null);
return mapping.findForward(ActionForwards.edit_success.toString());
}
use of org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm in project head by mifos.
the class BirtAdminDocumentUploadAction method loadProductInstance.
@TransactionDemarcate(joinToken = true)
public ActionForward loadProductInstance(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
SessionUtils.removeAttribute(ProductDefinitionConstants.AVAILABLEACCOUNTSTATUS, request);
SessionUtils.removeAttribute(ProductDefinitionConstants.SELECTEDACCOUNTSTATUS, request);
SessionUtils.removeAttribute(ProductDefinitionConstants.STATUS_LIST, request);
if (StringUtils.isNotBlank(uploadForm.getAccountTypeId()) && Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.AVAILABLEACCOUNTSTATUS, new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(Short.valueOf(uploadForm.getAccountTypeId()))), request);
} else if (StringUtils.isNotBlank(uploadForm.getAccountTypeId())) {
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.AVAILABLEACCOUNTSTATUS, getAvailableLoanTransactions((Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request)), request);
}
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations