public CustomerPage fetchCustomer()

in service/src/main/java/org/apache/fineract/cn/customer/internal/service/CustomerService.java [126:155]


  public CustomerPage fetchCustomer(final String term, final Boolean includeClosed, final Pageable pageable) {
    final Page<CustomerEntity> customerEntities;
    if (includeClosed) {
      if (term != null) {
        customerEntities =
            this.customerRepository.findByIdentifierContainingOrGivenNameContainingOrSurnameContaining(term, term, term, pageable);
      } else {
        customerEntities = this.customerRepository.findAll(pageable);
      }
    } else {
      if (term != null) {
        customerEntities =
            this.customerRepository.findByCurrentStateNotAndIdentifierContainingOrGivenNameContainingOrSurnameContaining(
                Customer.State.CLOSED.name(), term, term, term, pageable);
      } else {
        customerEntities = this.customerRepository.findByCurrentStateNot(Customer.State.CLOSED.name(), pageable);
      }
    }

    final CustomerPage customerPage = new CustomerPage();
    customerPage.setTotalPages(customerEntities.getTotalPages());
    customerPage.setTotalElements(customerEntities.getTotalElements());
    if (customerEntities.getSize() > 0) {
      final ArrayList<Customer> customers = new ArrayList<>(customerEntities.getSize());
      customerPage.setCustomers(customers);
      customerEntities.forEach(customerEntity -> customers.add(CustomerMapper.map(customerEntity)));
    }

    return customerPage;
  }