void fixStartEndTimeFromMeasurements(Session session) { Date start = session.getStart(); Date end = session.getEnd(); for (MeasurementStream stream : session.getMeasurementStreams()) { List<Measurement> measurements = stream.getMeasurements(); if (measurements.isEmpty()) { continue; } Measurement first = measurements.get(0); Measurement last = measurements.get(measurements.size() - 1); if (start == null) { start = first.getTime(); } else { start = start.before(first.getTime()) ? start : first.getTime(); } if (end == null) { end = last.getTime(); } else { end = end.before(last.getTime()) ? last.getTime() : end; } } if (start == null || end == null) { String message = "Session [" + session.getId() + "] has incorrect start/end date [" + start + "/" + end + "]"; throw new SessionSyncException(message); } session.setStart(new Date(start.getTime())); session.setEnd(new Date(end.getTime())); }
public void deleteSession() { Long sessionId = session.getId(); sessionRepository.markSessionForRemoval(sessionId); discardSession(sessionId); }
public void updateSession(Session from) { Preconditions.checkNotNull(from.getId(), "Unsaved session?"); setTitleTagsDescription(from.getId(), from.getTitle(), from.getTags(), from.getDescription()); }