@ -28,6 +28,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static mops.gruppen2.domain.Role.ADMIN;
|
import static mops.gruppen2.domain.Role.ADMIN;
|
||||||
|
|
||||||
@ -92,23 +93,16 @@ public class ControllerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createOrga(Account account, String title, String description, Boolean isVisibilityPrivate, Boolean isLecture, Boolean isMaximumInfinite, Long userMaximum, UUID parent, MultipartFile file) throws EventException, IOException {
|
public void createOrga(Account account, String title, String description, Boolean isVisibilityPrivate, Boolean isLecture, Boolean isMaximumInfinite, Long userMaximum, UUID parent, MultipartFile file) throws EventException, IOException {
|
||||||
List<User> userList = new ArrayList<>();
|
|
||||||
|
|
||||||
userMaximum = checkInfiniteUsers(isMaximumInfinite, userMaximum);
|
userMaximum = checkInfiniteUsers(isMaximumInfinite, userMaximum);
|
||||||
|
|
||||||
checkFields(description, title, userMaximum);
|
checkFields(description, title, userMaximum);
|
||||||
|
|
||||||
if (!file.isEmpty()) {
|
List<User> userList = readCsvFile(file);
|
||||||
try {
|
|
||||||
userList = CsvService.read(file.getInputStream());
|
if (userList.size() > userMaximum) {
|
||||||
if (userList.size() > userMaximum) {
|
userMaximum = (long) userList.size() + 1;
|
||||||
userMaximum = (long) userList.size() + userMaximum;
|
|
||||||
}
|
|
||||||
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
|
||||||
logger.warning("File konnte nicht gelesen werden");
|
|
||||||
throw new WrongFileException(file.getOriginalFilename());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID groupId = eventService.checkGroup();
|
UUID groupId = eventService.checkGroup();
|
||||||
Visibility groupVisibility = setGroupVisibility(isVisibilityPrivate);
|
Visibility groupVisibility = setGroupVisibility(isVisibilityPrivate);
|
||||||
GroupType groupType = setGroupType(isLecture);
|
GroupType groupType = setGroupType(isLecture);
|
||||||
@ -152,6 +146,19 @@ public class ControllerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<User> readCsvFile(MultipartFile file) throws EventException, IOException {
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
try {
|
||||||
|
List<User> userList = CsvService.read(file.getInputStream());
|
||||||
|
return userList.stream().distinct().collect(Collectors.toList()); //filters duplicates from list
|
||||||
|
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
||||||
|
logger.warning("File konnte nicht gelesen werden");
|
||||||
|
throw new WrongFileException(file.getOriginalFilename());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public void addUser(Account account, UUID groupId) {
|
public void addUser(Account account, UUID groupId) {
|
||||||
AddUserEvent addUserEvent = new AddUserEvent(groupId, account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
AddUserEvent addUserEvent = new AddUserEvent(groupId, account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||||
eventService.saveEvent(addUserEvent);
|
eventService.saveEvent(addUserEvent);
|
||||||
|
|||||||
Reference in New Issue
Block a user