private VisitorbookTimedDO getNewestEntry(final VisitorbookDO visitor) { List<VisitorbookTimedDO> timeableAttributes = timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit"); if (timeableAttributes != null && timeableAttributes.size() > 0) { List<VisitorbookTimedDO> sortedList = timeableService.sortTimeableAttrRowsByDateDescending(timeableAttributes); return sortedList.get(0); } return null; }
final List<VisitorbookDO> resultList = getList(queryFilter); final Predicate<VisitorbookDO> afterStartTimeOrSameDay = visitor -> timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit").stream() .anyMatch(timeAttr -> timeAttr.getStartTime().before(myFilter.getStartTime()) == false); // before() == false -> after or same day final Predicate<VisitorbookDO> beforeStopTimeOrSameDay = visitor -> timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit").stream() .anyMatch(timeAttr -> timeAttr.getStartTime().after(myFilter.getStopTime()) == false); // after() == false -> before or same day
/** * @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item, * java.lang.String, org.apache.wicket.model.IModel) */ @Override public void populateItem(final Item<ICellPopulator<VisitorbookDO>> item, final String componentId, final IModel<VisitorbookDO> rowModel) { final VisitorbookDO visitor = rowModel.getObject(); String value = ""; List<VisitorbookTimedDO> timeableAttributes = timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit"); if (timeableAttributes != null && timeableAttributes.size() > 0) { List<VisitorbookTimedDO> sortedList = timeableService.sortTimeableAttrRowsByDateDescending(timeableAttributes); VisitorbookTimedDO newestEntry = sortedList.get(0); SimpleDateFormat sdfParser = new SimpleDateFormat("dd.MM.yyyy"); String date = sdfParser.format(newestEntry.getStartTime()); String time = newestEntry.getAttribute("depart") != null ? newestEntry.getAttribute("depart", String.class) : ""; value = date + " " + time; } item.add(new TextPanel(componentId, value)); cellItemListener.populateItem(item, componentId, rowModel); } });
/** * @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item, * java.lang.String, org.apache.wicket.model.IModel) */ @Override public void populateItem(final Item<ICellPopulator<VisitorbookDO>> item, final String componentId, final IModel<VisitorbookDO> rowModel) { final VisitorbookDO visitor = rowModel.getObject(); String value = ""; List<VisitorbookTimedDO> timeableAttributes = timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit"); if (timeableAttributes != null && timeableAttributes.size() > 0) { List<VisitorbookTimedDO> sortedList = timeableService.sortTimeableAttrRowsByDateDescending(timeableAttributes); VisitorbookTimedDO newestEntry = sortedList.get(0); SimpleDateFormat sdfParser = new SimpleDateFormat("dd.MM.yyyy"); String date = sdfParser.format(newestEntry.getStartTime()); String time = newestEntry.getAttribute("arrive") != null ? newestEntry.getAttribute("arrive", String.class) : ""; value = date + " " + time; } item.add(new TextPanel(componentId, value)); cellItemListener.populateItem(item, componentId, rowModel); } });