1

change EventDTO, add AddUserEventController, add the search function in UI and backend

This commit is contained in:
tomvahl
2020-03-14 09:17:32 +01:00
parent cd60dca352
commit fa79b3f136
11 changed files with 123 additions and 26 deletions

View File

@ -23,6 +23,12 @@ public class GroupService {
this.eventRepository = eventRepository;
}
/** Sucht in der DB alle Zeilen raus welche eine der Gruppen_ids hat.
* Wandelt die Zeilen in Events um und gibt davon eine Liste zurück.
*
* @param group_ids
* @return
*/
public List<Event> getGroupEvents(List<Long> group_ids) {
List<EventDTO> eventDTOS = new ArrayList<>();
List<Event> events = new ArrayList<>();
@ -32,8 +38,13 @@ public class GroupService {
return events = eventService.translateEventDTOs(eventDTOS);
}
/** Erzeugt eine neue Map wo Gruppen aus den Events erzeugt und den Gruppen_ids zugeordnet werden.
* Die Gruppen werden als Liste zurückgegeben
*
* @param events
* @return
* @throws EventException
*/
public List<Group> projectEventList(List<Event> events) throws EventException {
Map<Long, Group> groupMap = new HashMap<>();
@ -44,7 +55,13 @@ public class GroupService {
return new ArrayList<>(groupMap.values());
}
//
/** guckt in der Map anhand der Id nach ob die Gruppe schon in der Map vorhanden ist, wenn nicht wird eine neue
* Gruppe erzeugt
*
* @param groups
* @param group_id
* @return
*/
private Group getOrCreateGroup(Map<Long, Group> groups, long group_id) {
if (!groups.containsKey(group_id)) {
groups.put(group_id, new Group());
@ -52,4 +69,33 @@ public class GroupService {
return groups.get(group_id);
}
/**
* sucht alle Zeilen in der DB wo die Visibility gleich true ist und wandelt diese in
* eine Liste von Gruppen
* @return
* @throws EventException
*/
public List<Group> getAllGroupWithVisibilityPublic() throws EventException {
return projectEventList(eventService.translateEventDTOs(eventRepository.findEventDTOByVisibility(Boolean.FALSE)));
}
/**
* Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück.
* Groß und kleinschreibung wird beachtet.
* @param search
* @return
* @throws EventException
*/
public List<Group> findGroupWith(String search) throws EventException {
List<Group> groups = new ArrayList<>();
for (Group group: getAllGroupWithVisibilityPublic()) {
if (group.getTitle().contains(search)){
groups.add(group);
}
}
return groups;
}
}