public String createGroup()

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


  public String createGroup(final CreateGroupCommand createGroupCommand) {
    final Group group = createGroupCommand.group();
    final GroupDefinitionEntity groupDefinitionEntity =
        this.groupDefinitionRepository.findByIdentifier(group.getGroupDefinitionIdentifier())
            .orElseThrow(
                () -> ServiceException.notFound("Group definition {0} not found.", group.getGroupDefinitionIdentifier())
            );

    final AddressEntity savedAddress = this.addressRepository.save(AddressMapper.map(group.getAddress()));

    final GroupEntity groupEntity = new GroupEntity();
    groupEntity.setGroupDefinition(groupDefinitionEntity);
    groupEntity.setIdentifier(group.getIdentifier());
    groupEntity.setName(group.getName());
    groupEntity.setLeaders(StringUtils.collectionToCommaDelimitedString(group.getLeaders()));
    groupEntity.setMembers(StringUtils.collectionToCommaDelimitedString(group.getMembers()));
    groupEntity.setOffice(group.getOffice());
    groupEntity.setAddressEntity(savedAddress);
    groupEntity.setAssignedEmployee(group.getAssignedEmployee());
    groupEntity.setWeekday(group.getWeekday());
    groupEntity.setGroupStatus(Group.Status.PENDING.name());
    groupEntity.setCreatedBy(UserContextHolder.checkedGetUser());
    groupEntity.setCreatedOn(LocalDateTime.now(Clock.systemUTC()));
    this.groupRepository.save(groupEntity);
    return group.getIdentifier();
  }