Search in sources :

Example 1 with NotesSearchResultsDto

use of org.mifos.dto.screen.NotesSearchResultsDto in project head by mifos.

the class NotesAction method getSearchResult.

@Override
protected QueryResult getSearchResult(ActionForm form) throws Exception {
    Integer accountId = Integer.valueOf(((NotesActionForm) form).getAccountId());
    AccountBO account = new AccountBusinessService().getAccount(accountId);
    if (account.isSavingsAccount()) {
        NoteSearchDto noteSearchDto = new NoteSearchDto(accountId, Integer.valueOf(1), Integer.valueOf(10));
        NotesSearchResultsDto noteResults = this.savingsServiceFacade.retrievePagedNotesDto(noteSearchDto);
    }
    return legacyAccountDao.getAllAccountNotes(accountId);
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) NoteSearchDto(org.mifos.dto.domain.NoteSearchDto) NotesSearchResultsDto(org.mifos.dto.screen.NotesSearchResultsDto)

Example 2 with NotesSearchResultsDto

use of org.mifos.dto.screen.NotesSearchResultsDto in project head by mifos.

the class SavingsDaoHibernate method searchNotes.

@SuppressWarnings("unchecked")
@Override
public NotesSearchResultsDto searchNotes(NoteSearchDto noteSearch) {
    Session session = StaticHibernateUtil.getSessionTL();
    Criteria criteriaQuery = session.createCriteria(AccountNotesEntity.class);
    criteriaQuery.add(Restrictions.eq("account.accountId", noteSearch.getAccountId()));
    criteriaQuery.addOrder(Order.desc("commentId"));
    Integer totalNumberOfSavingsNotes = 10;
    int firstResult = (noteSearch.getPage() * noteSearch.getPageSize()) - noteSearch.getPageSize();
    criteriaQuery.setFirstResult(firstResult);
    criteriaQuery.setMaxResults(noteSearch.getPageSize());
    List<AccountNotesEntity> pagedResults = criteriaQuery.list();
    List<CustomerNoteDto> pageDtoResults = new ArrayList<CustomerNoteDto>();
    for (AccountNotesEntity note : pagedResults) {
        pageDtoResults.add(new CustomerNoteDto(note.getCommentDate(), note.getComment(), note.getPersonnelName()));
    }
    SearchDetailsDto searchDetails = new SearchDetailsDto(totalNumberOfSavingsNotes.intValue(), firstResult, noteSearch.getPage(), noteSearch.getPageSize());
    NotesSearchResultsDto resultsDto = new NotesSearchResultsDto(searchDetails, pageDtoResults);
    return resultsDto;
}
Also used : SearchDetailsDto(org.mifos.dto.screen.SearchDetailsDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) NotesSearchResultsDto(org.mifos.dto.screen.NotesSearchResultsDto) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Aggregations

NotesSearchResultsDto (org.mifos.dto.screen.NotesSearchResultsDto)2 ArrayList (java.util.ArrayList)1 Criteria (org.hibernate.Criteria)1 Session (org.hibernate.Session)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)1 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)1 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)1 NoteSearchDto (org.mifos.dto.domain.NoteSearchDto)1 SearchDetailsDto (org.mifos.dto.screen.SearchDetailsDto)1