final PFUserDO user = userGroupCache.getUser(sheet.getUserId());
if (user == null) {
log.error("Oups, user of time sheet is null or unknown? Ignoring entry: " + sheet);
continue;
}
final ProjektDO projekt = taskTree.getProjekt(sheet.getTaskId());
final Object targetObject = getTargetObject(filter, projekt);
if (targetObject == null) {
data.addTimesheet(sheet, user);
} else if (targetObject instanceof ProjektDO) {
data.addTimesheet(sheet, user, (ProjektDO) targetObject);
} else if (targetObject instanceof KundeDO) {
data.addTimesheet(sheet, user, (KundeDO) targetObject);
} else {
log.error("Target object of type " + targetObject + " not supported.");
data.addTimesheet(sheet, user);
}
}
}
if (filter.isShowPlanning() == true) {
final HRPlanningFilter hrFilter = new HRPlanningFilter();
final DateHolder date = new DateHolder(filter.getStartTime());
hrFilter.setStartTime(date.getSQLDate()); // Considers the user's time zone.
date.setDate(filter.getStopTime());
hrFilter.setStopTime(date.getSQLDate()); // Considers the user's time zone.
final List<HRPlanningDO> plannings = hrPlanningDao.getList(hrFilter);
for (final HRPlanningDO planning : plannings) {
if (planning.getEntries() == null) {
continue;
}
for (final HRPlanningEntryDO entry : planning.getEntries()) {
if (entry.isDeleted() == true) {
continue;
}
final PFUserDO user = userGroupCache.getUser(planning.getUserId());
final ProjektDO projekt = entry.getProjekt();
final Object targetObject = getTargetObject(filter, projekt);
if (targetObject == null) {
data.addHRPlanningEntry(entry, user);
} else if (targetObject instanceof ProjektDO) {
data.addHRPlanningEntry(entry, user, (ProjektDO) targetObject);