Search in sources :

Example 1 with GenericDaoHibernate

use of org.mifos.accounts.savings.persistence.GenericDaoHibernate in project head by mifos.

the class LoanAccountAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanActionForm = (LoanAccountActionForm) form;
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    CustomerBO customer = getCustomerFromRequest(request);
    if (isGlimEnabled() || isNewGlimEnabled()) {
        populateGlimAttributes(request, loanActionForm, globalAccountNum, customer);
    }
    String recurMonth = customer.getCustomerMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString();
    handleRepaymentsIndependentOfMeetingIfConfigured(request, loanActionForm, recurMonth);
    LoanBO loanBO = new LoanDaoHibernate(new GenericDaoHibernate()).findByGlobalAccountNum(globalAccountNum);
    UserContext userContext = getUserContext(request);
    loanBO.setUserContext(userContext);
    SessionUtils.setAttribute(PROPOSED_DISBURSAL_DATE, loanBO.getDisbursementDate(), request);
    SessionUtils.removeAttribute(LOANOFFERING, request);
    LoanOfferingBO loanOffering = getLoanOffering(loanBO.getLoanOffering().getPrdOfferingId(), userContext.getLocaleId());
    loanActionForm.setInstallmentRange(loanBO.getMaxMinNoOfInstall());
    loanActionForm.setLoanAmountRange(loanBO.getMaxMinLoanAmount());
    MaxMinInterestRate interestRateRange = loanBO.getMaxMinInterestRate();
    loanActionForm.setMaxInterestRate(interestRateRange.getMaxLoanAmount());
    loanActionForm.setMinInterestRate(interestRateRange.getMinLoanAmount());
    loanActionForm.setExternalId(loanBO.getExternalId());
    if (null != loanBO.getFund()) {
        loanActionForm.setLoanOfferingFund(loanBO.getFund().getFundId().toString());
    }
    if (configService.isRepaymentIndepOfMeetingEnabled()) {
        MeetingDetailsEntity meetingDetail = loanBO.getLoanMeeting().getMeetingDetails();
        loanActionForm.setMonthDay("");
        loanActionForm.setMonthWeek("0");
        loanActionForm.setMonthRank("0");
        if (meetingDetail.getRecurrenceTypeEnum() == RecurrenceType.MONTHLY) {
            setMonthlySchedule(loanActionForm, meetingDetail);
        } else {
            setWeeklySchedule(loanActionForm, meetingDetail);
        }
    }
    setSessionAtributeForGLIM(request, loanBO);
    SessionUtils.setAttribute(LOANOFFERING, loanOffering, request);
    // Retrieve and set into the session all collateral types from the
    // lookup_value_locale table associated with the current user context
    // locale
    SessionUtils.setCollectionAttribute(MasterConstants.COLLATERAL_TYPES, legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES).getCustomValueListElements(), request);
    SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, legacyMasterDao.findValueListElements(MasterConstants.LOAN_PURPOSES), request);
    SessionUtils.setCollectionAttribute(CUSTOM_FIELDS, new ArrayList<CustomFieldDefinitionEntity>(), request);
    SessionUtils.setAttribute(RECURRENCEID, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceTypeEnum().getValue(), request);
    SessionUtils.setAttribute(RECURRENCENAME, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceName(), request);
    SessionUtils.setCollectionAttribute(LOANFUNDS, getFunds(loanOffering), request);
    setRequestAttributesForEditPage(request, loanBO);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("detailsInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateLoan"), request);
    setFormAttributes(loanBO, form, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) MaxMinInterestRate(org.mifos.accounts.loan.business.MaxMinInterestRate) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) LoanDaoHibernate(org.mifos.accounts.loan.persistance.LoanDaoHibernate) MeetingDetailsEntity(org.mifos.application.meeting.business.MeetingDetailsEntity) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) CustomerBO(org.mifos.customers.business.CustomerBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with GenericDaoHibernate

use of org.mifos.accounts.savings.persistence.GenericDaoHibernate in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingLoanSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(2));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 3 with GenericDaoHibernate

use of org.mifos.accounts.savings.persistence.GenericDaoHibernate in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingCustomerSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(3));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 4 with GenericDaoHibernate

use of org.mifos.accounts.savings.persistence.GenericDaoHibernate in project head by mifos.

the class PluginManager method loadImportPlugins.

/**
     * Returns list of import plugins. Note that {@link ServiceLoader} caches
     * loads, so multiple invocations should not incur extra overhead.
     */
public List<TransactionImport> loadImportPlugins() {
    List<TransactionImport> plugins = new ArrayList<TransactionImport>();
    ClassLoader pluginClassLoader = initializePluginClassLoader();
    ServiceLoader<TransactionImport> loader = ServiceLoader.load(TransactionImport.class, pluginClassLoader);
    for (TransactionImport ti : loader) {
        ti.setAccountService(new StandardAccountService(ApplicationContextProvider.getBean(LegacyAccountDao.class), ApplicationContextProvider.getBean(LegacyLoanDao.class), ApplicationContextProvider.getBean(LegacyAcceptedPaymentTypeDao.class), new PersonnelDaoHibernate(new GenericDaoHibernate()), new CustomerDaoHibernate(new GenericDaoHibernate()), ApplicationContextProvider.getBean(LoanBusinessService.class), new HibernateTransactionHelperForStaticHibernateUtil(), ApplicationContextProvider.getBean(LegacyMasterDao.class), ApplicationContextProvider.getBean(MonthClosingServiceFacade.class), ApplicationContextProvider.getBean(SavingsServiceFacade.class), ApplicationContextProvider.getBean(GroupLoanAccountServiceFacade.class)));
        ti.setCustomerSearchService(new CustomerSearchServiceImpl(new CustomerDaoHibernate(new GenericDaoHibernate())));
        plugins.add(ti);
    }
    return plugins;
}
Also used : PersonnelDaoHibernate(org.mifos.customers.personnel.persistence.PersonnelDaoHibernate) GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) HibernateTransactionHelperForStaticHibernateUtil(org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil) ArrayList(java.util.ArrayList) URLClassLoader(java.net.URLClassLoader) StandardAccountService(org.mifos.accounts.api.StandardAccountService) CustomerSearchServiceImpl(org.mifos.customers.business.service.CustomerSearchServiceImpl) TransactionImport(org.mifos.accounts.api.TransactionImport) CustomerDaoHibernate(org.mifos.customers.persistence.CustomerDaoHibernate)

Example 5 with GenericDaoHibernate

use of org.mifos.accounts.savings.persistence.GenericDaoHibernate in project head by mifos.

the class CustomerPersistence method phoneNumberSearch.

private QueryResult phoneNumberSearch(final String searchString, final Short officeId, final Short userId) throws HibernateSearchException, SystemException, PersistenceException {
    String phoneNumberWithStrippedNonnumerics = MifosStringUtils.removeNondigits(searchString);
    if (phoneNumberWithStrippedNonnumerics.isEmpty()) {
        return null;
    }
    List<CustomerDto> customersWithThisPhoneNumber = new CustomerDaoHibernate((new GenericDaoHibernate())).findCustomersWithGivenPhoneNumber(phoneNumberWithStrippedNonnumerics);
    if (customersWithThisPhoneNumber == null || customersWithThisPhoneNumber.isEmpty()) {
        return null;
    }
    SearchTemplate template = new SearchTemplate(phoneNumberWithStrippedNonnumerics, officeId, userId);
    template.queryNoOfficeCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NOOFFICEID_COUNT;
    template.queryNoOffice = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NOOFFICEID;
    template.queryNormalCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_COUNT;
    template.queryNormal = NamedQueryConstants.CUSTOMER_PHONE_SEARCH;
    template.queryNonOfficerCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_COUNT_NONLO;
    template.queryNonOfficer = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NONLO;
    return template.doSearch();
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) CustomerDto(org.mifos.dto.domain.CustomerDto) CollectionSheetCustomerDto(org.mifos.application.servicefacade.CollectionSheetCustomerDto)

Aggregations

GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)5 DateMidnight (org.joda.time.DateMidnight)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2 GenericDao (org.mifos.accounts.savings.persistence.GenericDao)2 HolidayBO (org.mifos.application.holiday.business.HolidayBO)2 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)2 HolidayDaoHibernate (org.mifos.application.holiday.persistence.HolidayDaoHibernate)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 OfficeDao (org.mifos.customers.office.persistence.OfficeDao)2 OfficeDaoHibernate (org.mifos.customers.office.persistence.OfficeDaoHibernate)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)2 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 StandardAccountService (org.mifos.accounts.api.StandardAccountService)1 TransactionImport (org.mifos.accounts.api.TransactionImport)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 MaxMinInterestRate (org.mifos.accounts.loan.business.MaxMinInterestRate)1 LoanDaoHibernate (org.mifos.accounts.loan.persistance.LoanDaoHibernate)1