private GroupEntity processCommandInternally()

in service/src/main/java/org/apache/fineract/cn/group/internal/command/handler/GroupAggregate.java [389:411]


  private GroupEntity processCommandInternally(final GroupEntity groupEntity, final GroupCommand groupCommand) {
    this.saveGroupCommand(groupEntity, groupCommand);

    final GroupCommand.Action action = GroupCommand.Action.valueOf(groupCommand.getAction());
    switch (action) {
      case ACTIVATE:
        groupEntity.setGroupStatus(Group.Status.ACTIVE.name());
        groupEntity.setCurrentCycle(groupEntity.getCurrentCycle() + 1);
        break;
      case CLOSE:
        groupEntity.setGroupStatus(Group.Status.CLOSED.name());
        break;
      case REOPEN:
        groupEntity.setGroupStatus(Group.Status.PENDING.name());
        groupEntity.setCurrentCycle(groupEntity.getCurrentCycle() + 1);
        break;
      default:
        throw ServiceException.badRequest("Unsupported command {}.", action.name());
    }
    groupEntity.setLastModifiedBy(groupCommand.getCreatedBy());
    groupEntity.setLastModifiedOn(DateConverter.fromIsoString(groupCommand.getCreatedOn()));
    return this.groupRepository.save(groupEntity);
  }