vidakovic commented on code in PR #6015:
URL: https://github.com/apache/fineract/pull/6015#discussion_r3538063167
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -574,6 +627,39 @@ public CommandProcessingResult deleteGroup(final Long
groupId) {
}
}
+ @Transactional
+ @Override
+ public GroupDeleteResponse deleteGroup(final GroupDeleteRequest request) {
+ try {
+ final Long groupId = request.getGroupId();
+ final Group groupForDelete =
this.groupRepository.findOneWithNotFoundDetection(groupId);
+
+ if (groupForDelete.isNotPending()) {
+ throw new GroupMustBePendingToBeDeletedException(groupId);
+ }
+
+ final List<Note> relatedNotes =
this.noteRepository.findByGroup(groupForDelete);
+ this.noteRepository.deleteAllInBatch(relatedNotes);
+
+ final Long officeId = groupForDelete.officeId();
+ final Long deletedGroupId = groupForDelete.getId();
+
+ this.groupRepository.delete(groupForDelete);
+ this.groupRepository.flush();
+
+ return GroupDeleteResponse.builder() //
+ .resourceId(deletedGroupId) //
+ .officeId(officeId) //
+ .groupId(deletedGroupId) //
+ .build();
+ } catch (final JpaSystemException | DataIntegrityViolationException
dve) {
+ final Throwable throwable =
ExceptionUtils.getRootCause(dve.getCause());
+ log.error("Error occured.", throwable);
+ throw ErrorHandler.getMappable(dve,
"error.msg.group.unknown.data.integrity.issue",
+ "Unknown data integrity issue with resource.");
+ }
+ }
+
@Override
public CommandProcessingResult closeGroup(final Long groupId, final
JsonCommand command) {
Review Comment:
Nope, belongs to legacy command processing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]