Search in sources :

Example 6 with BirtAdminDocumentUploadActionForm

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);
}
Also used : BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) FormFile(org.apache.struts.upload.FormFile) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with BirtAdminDocumentUploadActionForm

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());
}
Also used : AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with BirtAdminDocumentUploadActionForm

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());
}
Also used : AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

BirtAdminDocumentUploadActionForm (org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 AdminDocAccActionMixBO (org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO)3 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)3 FormFile (org.apache.struts.upload.FormFile)2 AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 Test (org.junit.Test)1 ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)1 MockFormFile (org.mifos.reports.business.MockFormFile)1 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)1 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)1