BP-832 show empty groups in report
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/SearchController.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/SearchController.java
index ab91541..09ce65e 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/SearchController.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/SearchController.java
@@ -145,9 +145,12 @@
lsGroupIds.add(standbyScheduleBody.getStandbyGroup().getId());
}
+ Map<Long, List<UserInStandbyGroupSelectionDto>> mapUserInGroup = new HashMap<>();
Long[] groupIds = lsGroupIds.toArray(new Long[lsGroupIds.size()]);
- Map<Long, List<UserInStandbyGroupSelectionDto>> mapUserInGroup = standbyGroupController
- .getUserInGroupList(groupIds);
+
+ if (!lsGroupIds.isEmpty()) {
+ mapUserInGroup = standbyGroupController.getUserInGroupList(groupIds);
+ }
for (StandbyScheduleBody standbyScheduleBody : listFilteredBodies) {
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupNameDtoConverter.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupNameDtoConverter.java
index 37eca59..cc0df4c 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupNameDtoConverter.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupNameDtoConverter.java
@@ -80,7 +80,8 @@
List<StandbyGroupSelectionDto> groupList = plan.getPlanHeader().getListGroups();
for (StandbyGroupSelectionDto standbyGroupSelectionDto : groupList) {
Long groupId = standbyGroupSelectionDto.getId();
- if (plan.groupSize(groupId) > 0 && index < MAX_ROWS) {
+ // BP-832, empty groups are not filtered
+ if (index < MAX_ROWS) {
groupIdArray[index++] = groupId;
}
}
@@ -125,18 +126,26 @@
for (int i = 0; i < groupIdArray.length; i++) {
Long groupId = groupIdArray[i];
- if (groupId != null && plan.groupSize(groupId) > 0) {
+ if (groupId != null) {
List<StandbyScheduleBodySelectionDto> dayGroupList = row.getGroupList(groupId);
if (dayGroupList != null) {
- checkEmpty(dayGroupList, groupId);
-
try {
+ if (checkEmpty(dayGroupList, groupId)) {
- addOneUserString(i + 1, dayGroupList, reportGroupDto, reportDto, lastBodyMap);
+ StandbyScheduleBodySelectionDto tmpDto = dayGroupList.get(0);
+ // empty entry
+ reportGroupDto.setUserX(i + 1, "");
+ reportGroupDto.setGroupX(i + 1, tmpDto.getStandbyGroup());
+
+ } else {
+
+ addOneUserString(i + 1, dayGroupList, reportGroupDto, reportDto, lastBodyMap);
+
+ }
} catch (Exception e) {
LOGGER.info("Can't set Body in Group " + groupId + ". Error on User or Group!");
}
@@ -153,35 +162,52 @@
ReportGroupDto reportGroupDto, ReportDto reportDto,
Map<Long, StandbyScheduleBodySelectionDto> lastBodyMap) {
+ StandbyScheduleBodySelectionDto lastBodyToday = null;
+ boolean oneBodyPrinted = false;
+
for (StandbyScheduleBodySelectionDto standbyScheduleBodySelectionDto : dayGroupList) {
try {
- if (dayGroupList.size() == 1) {
- addUserString(i, standbyScheduleBodySelectionDto, reportGroupDto, reportDto, lastBodyMap,
- dayGroupList);
- } else {
- Date startIndex = standbyScheduleBodySelectionDto.getValidFrom();
- Date startDay = DateHelper.getStartOfDay(startIndex);
+ StandbyScheduleBodySelectionDto lastBody = lastBodyMap
+ .get(standbyScheduleBodySelectionDto.getStandbyGroup().getId());
+ Date endIndex = standbyScheduleBodySelectionDto.getValidTo();
+ Date endDay = DateHelper.getStartOfDay(endIndex);
+
+ // get first 00:00:00 ending body
+ if (lastBodyToday == null && endIndex.equals(endDay)) {
+ lastBodyToday = standbyScheduleBodySelectionDto;
+ }
+
+ Date startIndex = standbyScheduleBodySelectionDto.getValidFrom();
+ Date startDay = DateHelper.getStartOfDay(startIndex);
+
+ if (!oneBodyPrinted) {
+
+ // case 00:00:00 check duration-user
if (startIndex.equals(startDay)) {
- // nothing to do
- } else {
- StandbyScheduleBodySelectionDto lastBody = lastBodyMap
- .get(standbyScheduleBodySelectionDto.getStandbyGroup().getId());
-
- if (lastBody != null && DateHelper.getStartOfDay(lastBody.getValidFrom())
- .equals(DateHelper.getStartOfDay(startDay))) {
+ if (lastBody != null && lastBody.getUser().getId()
+ .longValue() == standbyScheduleBodySelectionDto.getUser().getId().longValue()) {
// nothing to do
} else {
+
// set first entry on this day
- addUserString(i, standbyScheduleBodySelectionDto, reportGroupDto, reportDto, lastBodyMap,
- dayGroupList);
+ oneBodyPrinted = addUserString(i, standbyScheduleBodySelectionDto, reportGroupDto,
+ reportDto, lastBodyMap, dayGroupList);
}
+ } else {
+
+ // case later then 00:00:00
+ oneBodyPrinted = addUserString(i, standbyScheduleBodySelectionDto, reportGroupDto, reportDto,
+ lastBodyMap, dayGroupList);
+
}
+
}
+
} catch (Exception e) {
LOGGER.info("Can't set ScheduleBody " + standbyScheduleBodySelectionDto.getId()
+ ". Error on User or Group!");
@@ -189,9 +215,14 @@
}
+ // remember first 00:00:00 ending body
+ lastBodyMap.put(lastBodyToday.getStandbyGroup().getId(), lastBodyToday);
+
}
- public void checkEmpty(List<StandbyScheduleBodySelectionDto> dayGroupList, Long groupId) {
+ public boolean checkEmpty(List<StandbyScheduleBodySelectionDto> dayGroupList, Long groupId) {
+ boolean isEmpty = false;
+
if (dayGroupList.isEmpty()) {
// add empty placeholder
StandbyScheduleBodySelectionDto placeHoder = new StandbyScheduleBodySelectionDto();
@@ -201,11 +232,12 @@
StandbyGroupSelectionDto dto = (StandbyGroupSelectionDto) entityConverter.convertEntityToDto(standbyGroup,
new StandbyGroupSelectionDto());
placeHoder.setStandbyGroup(dto);
-
+ isEmpty = true;
}
+ return isEmpty;
}
- public void addUserString(int i, StandbyScheduleBodySelectionDto standbyScheduleBodySelectionDto,
+ public boolean addUserString(int i, StandbyScheduleBodySelectionDto standbyScheduleBodySelectionDto,
ReportGroupDto reportGroupDto, ReportDto reportDto, Map<Long, StandbyScheduleBodySelectionDto> lastBodyMap,
List<StandbyScheduleBodySelectionDto> dayGroupList) throws SpException {
@@ -221,10 +253,7 @@
reportGroupDto.setUserX(i, str);
reportGroupDto.setGroupX(i, standbyScheduleBodySelectionDto.getStandbyGroup());
- if (standbyScheduleBodySelectionDto.getId() != null) {
- // remember last body in this group
- lastBodyMap.put(standbyScheduleBodySelectionDto.getStandbyGroup().getId(), standbyScheduleBodySelectionDto);
- }
+ return true;
}
public String userString(StandbyScheduleBodySelectionDto lastBody, StandbyScheduleBodySelectionDto body,