use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.
the class SavingsAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsActionForm actionForm = (SavingsActionForm) form;
actionForm.setInput(null);
String globalAccountNum = actionForm.getGlobalAccountNum();
if (StringUtils.isBlank(actionForm.getGlobalAccountNum())) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
globalAccountNum = savings.getGlobalAccountNum();
}
logger.debug(" Retrieving for globalAccountNum: " + globalAccountNum);
SavingsBO savings = this.savingsDao.findBySystemId(globalAccountNum);
savings.setUserContext(uc);
SavingsAccountDetailDto savingsAccountDto;
try {
savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountDetails(savings.getAccountId().longValue());
} catch (MifosRuntimeException e) {
if (e.getCause() instanceof ApplicationException) {
throw (ApplicationException) e.getCause();
}
throw e;
}
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> savingsAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!savingsAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(Short.valueOf("2"))) {
savingsAdminDocuments.add(adminDocumentBO);
}
}
SessionUtils.setCollectionAttribute("administrativeDocumentsList", savingsAdminDocuments, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
SessionUtils.setCollectionAttribute(MasterConstants.SAVINGS_TYPE, legacyMasterDao.findMasterDataEntitiesWithLocale(SavingsTypeEntity.class), request);
SessionUtils.setCollectionAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, legacyMasterDao.findMasterDataEntitiesWithLocale(RecommendedAmntUnitEntity.class), request);
List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savings.getSavingsOffering(), request);
actionForm.setRecommendedAmount(savingsAccountDto.getRecommendedOrMandatoryAmount());
actionForm.clear();
SessionUtils.setCollectionAttribute(SavingsConstants.RECENTY_ACTIVITY_DETAIL_PAGE, savingsAccountDto.getRecentActivity(), request);
SessionUtils.setCollectionAttribute(SavingsConstants.NOTES, savings.getRecentAccountNotes(), request);
logger.info(" Savings object retrieved successfully");
setCurrentPageUrl(request, savings);
setQuestionGroupInstances(request, savings);
request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
return mapping.findForward("get_success");
}
use of org.mifos.reports.admindocuments.business.AdminDocumentBO 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.business.AdminDocumentBO 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.business.AdminDocumentBO in project head by mifos.
the class PentahoReportsServiceIntegrationTest method testGetAdminReport.
@Test
public void testGetAdminReport() throws Exception {
String adminDocumentUploadPath = viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory();
String adminDocumentPath = "IntegrationTest_Loan_template.prpt";
File adminDocumentSrc = new File(this.getClass().getResource("/Loan_template.prpt").toString().replace("file:", ""));
File adminDocumentDst = new File(adminDocumentUploadPath + "/" + adminDocumentPath);
try {
FileUtils.copyFile(adminDocumentSrc, adminDocumentDst);
AdminDocumentBO adminDocumentBO = new AdminDocumentBO();
adminDocumentBO.setAdmindocId(Short.valueOf("1"));
adminDocumentBO.setAdminDocumentName("IntegrationTest_Loan_template");
adminDocumentBO.setIsActive(Short.valueOf("1"));
adminDocumentBO.setAdminDocumentIdentifier(adminDocumentPath);
AdminDocAccStateMixBO adminDocAccStateMixBO = new AdminDocAccStateMixBO();
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
adminDocAccStateMixBO.setAccountStateID(accountStateEntity);
adminDocAccStateMixBO.setAdminDocumentID(adminDocumentBO);
legacyAdminDocumentDao.createOrUpdate(adminDocumentBO);
Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
PentahoInputParameter entityIdParameter = new PentahoInputParameter();
entityIdParameter.setParamName("entity_id");
entityIdParameter.setValue("000100000000002");
params.put("entity_id", entityIdParameter);
Integer adminDocId = Integer.parseInt(adminDocumentBO.getAdmindocId().toString());
for (PentahoOutputType outputType : PentahoOutputType.values()) {
PentahoReport report = pentahoReportsServiceImpl.getAdminReport(adminDocId, outputType.getId(), params);
Assert.assertTrue(report.getFileExtension() == outputType.getFileExtension());
Assert.assertTrue(report.getContentType() == outputType.getContentType());
Assert.assertTrue(report.getErrors().isEmpty());
}
} catch (Exception e) {
throw e;
} finally {
if (adminDocumentDst.exists()) {
adminDocumentDst.delete();
}
}
}
use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.
the class AdminDocumentPersistenceIntegrationTest method testGetAdminDocumentById.
@Test
public void testGetAdminDocumentById() throws NumberFormatException, PersistenceException {
AdminDocumentBO admindoc = legacyAdminDocumentDao.getAdminDocumentById(Short.valueOf("1"));
Assert.assertEquals(null, admindoc);
}
Aggregations