use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserEmail in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method removeUserEmail.
/**
* {@inheritDoc}
*/
@Override
public void removeUserEmail(String identifier) {
LocalUserEmail localUserEmail = localUserSchoolDataController.findUserEmail(identifier);
if (localUserEmail == null) {
throw new SchoolDataBridgeInternalException("UserEmail can not be removed because it does not exist");
}
localUserSchoolDataController.removeUserEmail(localUserEmail);
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserEmail in project muikku by otavanopisto.
the class LocalUserEmailDAO method listByUserAndArchived.
public List<LocalUserEmail> listByUserAndArchived(LocalUser user, Boolean archived) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<LocalUserEmail> criteria = criteriaBuilder.createQuery(LocalUserEmail.class);
Root<LocalUserEmail> root = criteria.from(LocalUserEmail.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(LocalUserEmail_.user), user), criteriaBuilder.equal(root.get(LocalUserEmail_.archived), archived)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserEmail in project muikku by otavanopisto.
the class LocalUserEmailDAO method create.
public LocalUserEmail create(LocalUser user, String address, Boolean archived) {
LocalUserEmail localUserEmail = new LocalUserEmail();
localUserEmail.setUser(user);
localUserEmail.setAddress(address);
localUserEmail.setArchived(archived);
return persist(localUserEmail);
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserEmail in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method listUserEmailsByUserIdentifier.
/**
* {@inheritDoc}
*/
@Override
public List<UserEmail> listUserEmailsByUserIdentifier(String userIdentifier) {
if (!StringUtils.isNumeric(userIdentifier)) {
throw new SchoolDataBridgeInternalException("userIdentifier is invalid");
}
List<UserEmail> result = new ArrayList<>();
List<LocalUserEmail> emails = localUserSchoolDataController.listUserEmailsByUserIdentifier(userIdentifier);
for (LocalUserEmail email : emails) {
UserEmail emailImpl = toLocalUserEmailImpl(email);
if (emailImpl != null) {
result.add(emailImpl);
} else {
throw new SchoolDataBridgeInternalException("Unexpected error occured while listing LocalUserEmails");
}
}
return result;
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserEmail in project muikku by otavanopisto.
the class LocalUserEmailDAO method findByAddressAndArchived.
public LocalUserEmail findByAddressAndArchived(String address, Boolean archived) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<LocalUserEmail> criteria = criteriaBuilder.createQuery(LocalUserEmail.class);
Root<LocalUserEmail> root = criteria.from(LocalUserEmail.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(LocalUserEmail_.address), address), criteriaBuilder.equal(root.get(LocalUserEmail_.archived), archived)));
return getSingleResult(entityManager.createQuery(criteria));
}
Aggregations