use of fi.otavanopisto.muikku.plugins.timed.notifications.model.NoPassedCoursesNotification in project muikku by otavanopisto.
the class NoPassedCoursesNotificationDAO method listByDateAfter.
public List<NoPassedCoursesNotification> listByDateAfter(Date sent) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<NoPassedCoursesNotification> criteria = criteriaBuilder.createQuery(NoPassedCoursesNotification.class);
Root<NoPassedCoursesNotification> root = criteria.from(NoPassedCoursesNotification.class);
criteria.select(root);
criteria.where(criteriaBuilder.greaterThanOrEqualTo(root.get(NoPassedCoursesNotification_.sent), sent));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.NoPassedCoursesNotification in project muikku by otavanopisto.
the class NoPassedCoursesNotificationDAO method findLatestByUserIdentifier.
public NoPassedCoursesNotification findLatestByUserIdentifier(SchoolDataIdentifier identifier) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<NoPassedCoursesNotification> criteria = criteriaBuilder.createQuery(NoPassedCoursesNotification.class);
Root<NoPassedCoursesNotification> root = criteria.from(NoPassedCoursesNotification.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(NoPassedCoursesNotification_.studentIdentifier), identifier.toId()));
criteria.orderBy(criteriaBuilder.desc(root.get(NoPassedCoursesNotification_.sent)));
TypedQuery<NoPassedCoursesNotification> query = entityManager.createQuery(criteria);
query.setMaxResults(1);
return getSingleResult(query);
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.NoPassedCoursesNotification 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.NoPassedCoursesNotification in project muikku by otavanopisto.
the class NoPassedCoursesNotificationController method listNotifiedSchoolDataIdentifiersAfter.
public List<SchoolDataIdentifier> listNotifiedSchoolDataIdentifiersAfter(Date date) {
List<SchoolDataIdentifier> results = new ArrayList<>();
List<NoPassedCoursesNotification> noPassedCoursesNotifications = noPassedCoursesNotificationDAO.listByDateAfter(date);
for (NoPassedCoursesNotification noPassedCoursesNotification : noPassedCoursesNotifications) {
results.add(SchoolDataIdentifier.fromId(noPassedCoursesNotification.getStudentIdentifier()));
}
return results;
}
use of fi.otavanopisto.muikku.plugins.timed.notifications.model.NoPassedCoursesNotification in project muikku by otavanopisto.
the class NoPassedCoursesNotificationDAO method create.
public NoPassedCoursesNotification create(String studentIdentifier, Date sent) {
NoPassedCoursesNotification noPassedCoursesNotification = new NoPassedCoursesNotification();
noPassedCoursesNotification.setSent(sent);
noPassedCoursesNotification.setStudentIdentifier(studentIdentifier);
return persist(noPassedCoursesNotification);
}
Aggregations