in service/src/main/java/org/apache/fineract/cn/customer/internal/service/CustomerService.java [89:124]
public Optional<Customer> findCustomer(final String identifier) {
return customerRepository.findByIdentifier(identifier)
.map(customerEntity -> {
final Customer customer = CustomerMapper.map(customerEntity);
if(customerEntity !=null && customerEntity.getAddress() != null)
customer.setAddress(AddressMapper.map(customerEntity.getAddress()));
final List<ContactDetailEntity> contactDetailEntities = this.contactDetailRepository.findByCustomer(customerEntity);
if (contactDetailEntities != null) {
customer.setContactDetails(
contactDetailEntities
.stream()
.map(ContactDetailMapper::map)
.collect(Collectors.toList())
);
}
final List<FieldValueEntity> fieldValueEntities = this.fieldValueRepository.findByCustomer(customerEntity);
if (fieldValueEntities != null) {
customer.setCustomValues(
fieldValueEntities
.stream()
.map(fieldValueEntity -> {
final Value value = new Value();
value.setValue(fieldValueEntity.getValue());
final FieldEntity fieldEntity = fieldValueEntity.getField();
value.setCatalogIdentifier(fieldEntity.getCatalog().getIdentifier());
value.setFieldIdentifier(fieldEntity.getIdentifier());
return value;
}).collect(Collectors.toList())
);
}
return customer;
});
}