@Override public PortletLifecycleState getLifecycleState() { final Date now = new Date(); final IPortletLifecycleEntry currentEntry = lifecycleEntries .stream() .filter(entry -> entry.getDate().before(now)) // Not entries in the future .reduce( (e1, e2) -> e1.getDate().after(e2.getDate()) ? e1 : e2) // Only the latest .orElse(null); // Possible if the portlet is not yet fully created return currentEntry != null ? currentEntry.getLifecycleState() : null; }
for (IPortletLifecycleEntry ple : def.getLifecycle()) { final LifecycleEntry entry = new LifecycleEntry(); entry.setName(ple.getLifecycleState().toString()); entry.setUser(getUsernameForUserId(ple.getUserId())); entry.setValue(getCalendar(ple.getDate())); lifecycle.getEntries().add(entry);
/** * In {@link PortletDefinitionImpl}, this overload does all the work. (The other overload * forwards.) Adding <code>synchronized</code> in case two threads try to modify the collection * at the same time. */ @Override public synchronized void updateLifecycleState( PortletLifecycleState lifecycleState, IPerson user, Date timestamp) { /* * Lifecycle entries that are scheduled for an instant * on or after the new entry must be cleared. */ final Set<IPortletLifecycleEntry> canceledStateChanges = lifecycleEntries .stream() // NB: entry.getDate.equals(timestamp) does not work as expected. .filter(entry -> entry.getDate().compareTo(timestamp) >= 0) .collect(Collectors.toSet()); lifecycleEntries.removeAll(canceledStateChanges); final IPortletLifecycleEntry newEntry = new PortletLifecycleEntryImpl(user.getID(), lifecycleState, timestamp); lifecycleEntries.add(newEntry); }
@Override public int compareTo(IPortletLifecycleEntry o) { int rslt = date.compareTo(o.getDate()); if (rslt == 0) { rslt = lifecycleStateId - o.getLifecycleState().getOrder(); } return rslt; }
@Override public int compareTo(IPortletLifecycleEntry o) { int rslt = date.compareTo(o.getDate()); if (rslt == 0) { rslt = state.getOrder() - o.getLifecycleState().getOrder(); } return rslt; } },
(k, v) -> { portletDefinition.updateLifecycleState( k.getLifecycleState(), v, k.getDate()); });
: def.getLifecycle().get(def.getLifecycle().size() - 1); if (lastLifecycleEntry != null && !lastLifecycleEntry.getLifecycleState().equals(lifecycleState)) { switch (lastLifecycleEntry.getLifecycleState()) { case PUBLISHED: this.setPublishDateTime(lastLifecycleEntry.getDate()); break; case EXPIRED: this.setExpirationDateTime(lastLifecycleEntry.getDate()); break; default: