in service/src/main/java/org/apache/fineract/cn/office/internal/command/handler/OfficeAggregate.java [86:113]
public String updateOffice(final UpdateOfficeCommand updateOfficeCommand) throws ServiceException {
final Office office = updateOfficeCommand.office();
final Optional<OfficeEntity> optionalOfficeEntity = this.officeRepository.findByIdentifier(office.getIdentifier());
if (optionalOfficeEntity.isPresent()) {
final OfficeEntity officeEntity = optionalOfficeEntity.get();
if (office.getName() != null) {
officeEntity.setName(office.getName());
}
if (office.getDescription() != null) {
officeEntity.setDescription(office.getDescription());
}
officeEntity.setCreatedBy(UserContextHolder.checkedGetUser());
officeEntity.setCreatedOn(Utils.utcNow());
this.officeRepository.save(officeEntity);
if (office.getAddress() != null) {
this.setAddress(new SetAddressForOfficeCommand(office.getIdentifier(), office.getAddress()));
}
return office.getIdentifier();
} else {
throw ServiceException.notFound("Office {0} not found.", office.getIdentifier());
}
}