use of fi.otavanopisto.muikku.plugins.material.coops.model.CoOpsSession in project muikku by otavanopisto.
the class CoOpsSessionEventsController method createSessionEvents.
public List<Object> createSessionEvents(List<CoOpsSession> sessions, String status) {
List<Object> result = new ArrayList<Object>();
String email = null;
// TODO: Localize
String displayName = "Anonymous";
for (CoOpsSession session : sessions) {
String sessionId = session.getSessionId();
Long userEntityId = session.getUserEntityId();
if (userEntityId != null) {
UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
if (userEntity != null) {
email = userEmailEntityController.getUserDefaultEmailAddress(userEntity, false);
User user = userController.findUserByDataSourceAndIdentifier(userEntity.getDefaultSchoolDataSource(), userEntity.getDefaultIdentifier());
if (user != null) {
displayName = user.getFirstName() + ' ' + user.getLastName();
}
}
}
if (StringUtils.isBlank(email)) {
email = sessionId + "@nomail.invalid";
}
result.add(new CoOpsSessionEvent(sessionId, displayName, email, status));
}
return result;
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.CoOpsSession in project muikku by otavanopisto.
the class CoOpsSessionDAO method listByClosed.
public List<CoOpsSession> listByClosed(Boolean closed) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CoOpsSession> criteria = criteriaBuilder.createQuery(CoOpsSession.class);
Root<CoOpsSession> root = criteria.from(CoOpsSession.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(CoOpsSession_.closed), closed));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.CoOpsSession in project muikku by otavanopisto.
the class CoOpsSessionDAO method listByFileAndClosed.
public List<CoOpsSession> listByFileAndClosed(HtmlMaterial htmlMaterial, Boolean closed) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CoOpsSession> criteria = criteriaBuilder.createQuery(CoOpsSession.class);
Root<CoOpsSession> root = criteria.from(CoOpsSession.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(CoOpsSession_.htmlMaterial), htmlMaterial), criteriaBuilder.equal(root.get(CoOpsSession_.closed), closed)));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations