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