use of org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO 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.reports.admindocuments.business.AdminDocAccStateMixBO in project head by mifos.
the class EditStatusAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditStatusActionForm actionForm = (EditStatusActionForm) form;
actionForm.setSelectedItems(null);
actionForm.setNotes(null);
actionForm.setNewStatusId(null);
actionForm.setFlagId(null);
actionForm.setQuestionGroups(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setAllowBackDatedApprovals(AccountingRules.isBackDatedApprovalAllowed());
request.getSession().removeAttribute(Constants.BUSINESS_KEY);
UserContext userContext = getUserContext(request);
Integer accountId = Integer.valueOf(actionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
java.util.Date lastPaymentDate = new java.util.Date(0);
AccountPaymentEntity lastPayment = accountBO.findMostRecentNonzeroPaymentByPaymentDate();
if (lastPayment != null) {
lastPaymentDate = lastPayment.getPaymentDate();
}
actionForm.setLastPaymentDate(lastPaymentDate);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.loanAccountServiceFacade.retrieveAccountStatuses(accountId.longValue());
LoanBO loanAccount = this.loanDao.findById(accountId);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(loanAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(loanAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(loanAccount.getLoanOffering().getPrdOfferingName());
if (loanAccount.isGroupLoanAccount() && loanAccount.getParentAccount() == null) {
editStatusActionForm.setInput("grouploan");
} else {
editStatusActionForm.setInput("loan");
}
if (loanAccount.getAccountState().getId().equals(Short.valueOf("2"))) {
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> loanAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!loanAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(loanAccount.getType().getValue().shortValue())) {
for (AdminDocAccStateMixBO admindoc : admindoclist) {
if (admindoc.getAccountStateID().getId().shortValue() == loanAccount.getAccountState().getId().shortValue()) {
loanAdminDocuments.add(adminDocumentBO);
}
}
}
}
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", loanAdminDocuments, request);
} else {
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", null, request);
}
}
if (accountBO.isSavingsAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.savingsServiceFacade.retrieveAccountStatuses(accountId.longValue());
SavingsBO savingsAccount = this.savingsDao.findById(accountId.longValue());
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(savingsAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(savingsAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(savingsAccount.getSavingsOffering().getPrdOfferingName());
editStatusActionForm.setInput("savings");
}
List<AccountStateEntity> accountStatuses = new AccountBusinessService().getStatusList(accountBO.getAccountState(), accountBO.getType(), userContext.getLocaleId());
for (AccountStateEntity customerStatusEntity : accountStatuses) {
for (AccountStateFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, accountStatuses, request);
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO 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.AdminDocAccStateMixBO 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.AdminDocAccStateMixBO 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);
}
Aggregations