use of fi.otavanopisto.muikku.plugins.timed.notifications.model.StudyTimeNotification in project muikku by otavanopisto.
the class StudyTimeNotificationDAO method create.
public StudyTimeNotification create(String studentIdentifier, Date sent) {
StudyTimeNotification studyTimeNotification = new StudyTimeNotification();
studyTimeNotification.setSent(sent);
studyTimeNotification.setStudentIdentifier(studentIdentifier);
return persist(studyTimeNotification);
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.StudyTimeNotification in project muikku by otavanopisto.
the class StudyTimeNotificationDAO method listByDateAfter.
public List<StudyTimeNotification> listByDateAfter(Date sent) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<StudyTimeNotification> criteria = criteriaBuilder.createQuery(StudyTimeNotification.class);
Root<StudyTimeNotification> root = criteria.from(StudyTimeNotification.class);
criteria.select(root);
criteria.where(criteriaBuilder.greaterThanOrEqualTo(root.get(StudyTimeNotification_.sent), sent));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.StudyTimeNotification in project muikku by otavanopisto.
the class GuiderRESTService method listUserNotifications.
@GET
@Path("/users/{IDENTIFIER}/latestNotifications")
@RESTPermit(GuiderPermissions.GUIDER_LIST_NOTIFICATIONS)
public Response listUserNotifications(@PathParam("IDENTIFIER") String identifierString) {
SchoolDataIdentifier identifier = SchoolDataIdentifier.fromId(identifierString);
UserEntity ue = userEntityController.findUserEntityByUserIdentifier(identifier);
if (ue == null) {
return Response.status(Status.NOT_FOUND).entity("User entity not found").build();
}
Map<String, Date> map = new HashMap<>();
StudyTimeNotification notification = studyTimeLeftNotificationController.findLatestByUserIdentifier(identifier);
if (notification != null)
map.put("studytime", notification.getSent());
NoPassedCoursesNotification noPassNotification = noPassedCoursesNotificationController.findLatestByUserIdentifier(identifier);
if (noPassNotification != null)
map.put("nopassedcourses", noPassNotification.getSent());
AssesmentRequestNotification assessmentRequestNotification = assessmentRequestNotificationController.findLatestByUserIdentifier(identifier);
if (assessmentRequestNotification != null)
map.put("assesmentrequest", assessmentRequestNotification.getSent());
return Response.ok().entity(map).build();
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.StudyTimeNotification in project muikku by otavanopisto.
the class StudyTimeNotificationDAO method findLatestByUserIdentifier.
public StudyTimeNotification findLatestByUserIdentifier(SchoolDataIdentifier identifier) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<StudyTimeNotification> criteria = criteriaBuilder.createQuery(StudyTimeNotification.class);
Root<StudyTimeNotification> root = criteria.from(StudyTimeNotification.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(StudyTimeNotification_.studentIdentifier), identifier.toId()));
criteria.orderBy(criteriaBuilder.desc(root.get(StudyTimeNotification_.sent)));
TypedQuery<StudyTimeNotification> query = entityManager.createQuery(criteria);
query.setMaxResults(1);
return getSingleResult(query);
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.StudyTimeNotification in project muikku by otavanopisto.
the class StudyTimeLeftNotificationController method listNotifiedSchoolDataIdentifiersAfter.
public List<SchoolDataIdentifier> listNotifiedSchoolDataIdentifiersAfter(Date date) {
List<SchoolDataIdentifier> results = new ArrayList<>();
List<StudyTimeNotification> studyTimeNotifications = studyTimeNotificationDAO.listByDateAfter(date);
for (StudyTimeNotification studyTimeNotification : studyTimeNotifications) {
results.add(SchoolDataIdentifier.fromId(studyTimeNotification.getStudentIdentifier()));
}
return results;
}
Aggregations