in service/src/main/java/org/apache/fineract/cn/deposit/service/internal/command/handler/ProductInstanceAggregate.java [170:196]
public String process(final UpdateProductInstanceCommand updateProductInstanceCommand) {
final ProductInstance productInstance = updateProductInstanceCommand.productInstance();
final Optional<ProductInstanceEntity> optionalProductInstance =
this.productInstanceRepository.findByAccountIdentifier(productInstance.getAccountIdentifier());
if (optionalProductInstance.isPresent()) {
final ProductInstanceEntity productInstanceEntity = optionalProductInstance.get();
if (this.hasChanged(productInstance, productInstanceEntity)) {
final Account account = this.accountingService.findAccount(productInstanceEntity.getAccountIdentifier());
account.setSignatureAuthorities(productInstance.getBeneficiaries());
this.accountingService.updateAccount(account);
productInstanceEntity.setBeneficiaries(
productInstance.getBeneficiaries().stream().collect(Collectors.joining(",")));
productInstanceEntity.setLastModifiedBy(UserContextHolder.checkedGetUser());
productInstanceEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC()));
this.productInstanceRepository.save(productInstanceEntity);
return productInstance.getAccountIdentifier();
} else {
this.logger.info("Skipped update for product instance {}, no data changed.", productInstance.getAccountIdentifier());
return null;
}
} else {
throw ServiceException.notFound("Product instance {0} not found.", productInstance.getAccountIdentifier());
}
}