use of fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier in project muikku by otavanopisto.
the class UserSchoolDataIdentifierDAO method create.
public UserSchoolDataIdentifier create(SchoolDataSource dataSource, String identifier, UserEntity userEntity, Boolean archived) {
UserSchoolDataIdentifier userSchoolDataIdentifier = new UserSchoolDataIdentifier();
userSchoolDataIdentifier.setIdentifier(identifier);
userSchoolDataIdentifier.setDataSource(dataSource);
userSchoolDataIdentifier.setUserEntity(userEntity);
userSchoolDataIdentifier.setArchived(archived);
return persist(userSchoolDataIdentifier);
}
use of fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier in project muikku by otavanopisto.
the class UserSchoolDataIdentifierDAO method listByDataSourceAndArchived.
public List<UserSchoolDataIdentifier> listByDataSourceAndArchived(SchoolDataSource dataSource, Boolean archived) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<UserSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(UserSchoolDataIdentifier.class);
Root<UserSchoolDataIdentifier> root = criteria.from(UserSchoolDataIdentifier.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(UserSchoolDataIdentifier_.dataSource), dataSource), criteriaBuilder.equal(root.get(UserSchoolDataIdentifier_.archived), archived)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier in project muikku by otavanopisto.
the class UserSchoolDataIdentifierDAO method listByUserEntityAndArchived.
public List<UserSchoolDataIdentifier> listByUserEntityAndArchived(UserEntity userEntity, Boolean archived) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<UserSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(UserSchoolDataIdentifier.class);
Root<UserSchoolDataIdentifier> root = criteria.from(UserSchoolDataIdentifier.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(UserSchoolDataIdentifier_.userEntity), userEntity), criteriaBuilder.equal(root.get(UserSchoolDataIdentifier_.archived), archived)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier in project muikku by otavanopisto.
the class FlagStudentDAO method listStudentIdentifiersByFlags.
public List<UserSchoolDataIdentifier> listStudentIdentifiersByFlags(List<Flag> flags) {
if ((flags == null) || flags.isEmpty()) {
return Collections.emptyList();
}
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<UserSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(UserSchoolDataIdentifier.class);
Root<FlagStudent> root = criteria.from(FlagStudent.class);
criteria.select(root.get(FlagStudent_.studentIdentifier));
criteria.where(root.get(FlagStudent_.flag).in(flags));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier in project muikku by otavanopisto.
the class InactiveUserListener method onSchoolDataUserInactiveEvent.
public void onSchoolDataUserInactiveEvent(@Observes SchoolDataUserInactiveEvent event) {
SchoolDataIdentifier schoolDataIdentifier = new SchoolDataIdentifier(event.getIdentifier(), event.getDataSource());
// Remove an inactive user from all workspaces in which they are currently active
List<WorkspaceUserEntity> workspaceUserEntities = workspaceUserEntityController.listActiveWorkspaceUserEntitiesByUserIdentifier(schoolDataIdentifier);
for (WorkspaceUserEntity workspaceUserEntity : workspaceUserEntities) {
workspaceUserEntityController.updateActive(workspaceUserEntity, Boolean.FALSE);
}
// Update Elastic search index since active workspaces have changed
UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierController.findUserSchoolDataIdentifierBySchoolDataIdentifier(schoolDataIdentifier);
if (userSchoolDataIdentifier != null) {
userIndexer.indexUser(userSchoolDataIdentifier.getUserEntity());
}
}
Aggregations