1

Fix Checkstyle Errors :(

Co-authored-by: Christoph <tobi@urpost.de>
This commit is contained in:
Christoph
2020-03-18 23:17:57 +01:00
parent 08717611d5
commit a05ffe9e4c
33 changed files with 260 additions and 269 deletions

View File

@ -28,13 +28,13 @@ public class GroupService {
* 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
* @param groupIds Liste an IDs
* @return Liste an Events
*/
public List<Event> getGroupEvents(List<Long> group_ids) {
public List<Event> getGroupEvents(List<Long> groupIds) {
List<EventDTO> eventDTOS = new ArrayList<>();
for (Long group_id : group_ids) {
eventDTOS.addAll(eventRepository.findEventDTOByGroup_id(group_id));
for (Long groupId : groupIds) {
eventDTOS.addAll(eventRepository.findEventDTOByGroup_id(groupId));
}
return eventService.translateEventDTOs(eventDTOS);
}
@ -43,67 +43,58 @@ public class GroupService {
* 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
* @param events Liste an Events
* @return Liste an Projizierten Gruppen
* @throws EventException Projektionsfehler
*/
public List<Group> projectEventList(List<Event> events) throws EventException {
Map<Long, Group> groupMap = new HashMap<>();
for (Event event : events) {
Group group = getOrCreateGroup(groupMap, event.getGroup_id());
Group group = getOrCreateGroup(groupMap, event.getGroupId());
event.apply(group);
}
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());
private Group getOrCreateGroup(Map<Long, Group> groups, long groupId) {
if (!groups.containsKey(groupId)) {
groups.put(groupId, new Group());
}
return groups.get(group_id);
return groups.get(groupId);
}
private List<Long> removeUserGroups(List<Long> group_ids, List<Long> user_groups) {
for (Long group_id : user_groups) {
group_ids.remove(group_id);
private List<Long> removeUserGroups(List<Long> groupIds, List<Long> userGroups) {
for (Long groupId : userGroups) {
groupIds.remove(groupId);
}
return group_ids;
return groupIds;
}
/**
* sucht alle Zeilen in der DB wo die Visibility true ist und entfernt alle Gruppen des Users.
* Erstellt eine Liste aus Gruppen.
* Sucht alle Zeilen in der DB mit visibility=true.
* Erstellt eine Liste aus öffentlichen Gruppen (ohen bereits beigetretenen Gruppen).
*
* @return
* @throws EventException
* @return Liste von projizierten Gruppen
* @throws EventException Projektionsfehler
*/
public List<Group> getAllGroupWithVisibilityPublic(String user_id) throws EventException {
List<Long> group_ids = removeUserGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE), eventRepository.findGroup_idsWhereUser_id(user_id));
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(group_ids);
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
List<Long> groupIds = removeUserGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE), eventRepository.findGroup_idsWhereUser_id(userId));
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(groupIds);
List<Event> events = eventService.translateEventDTOs(eventDTOS);
List<Group> groups = projectEventList(events);
return groups;
return projectEventList(events);
}
/**
* Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück.
* Groß und kleinschreibung wird beachtet.
* Filtert alle öffentliche Gruppen nach dem Suchbegriff und gibt diese als Liste von Gruppen zurück.
* Groß und Kleinschreibung wird nicht beachtet.
*
* @param search
* @return
* @throws EventException
* @param search Der Suchstring
* @return Liste von projizierten Gruppen
* @throws EventException Projektionsfehler
*/
public List<Group> findGroupWith(String search, Account account) throws EventException {
List<Group> groups = new ArrayList<>();