use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserImage in project muikku by otavanopisto.
the class LocalUserImageDAO method create.
public LocalUserImage create(LocalUser user, String contentType, byte[] content) {
LocalUserImage localUserImage = new LocalUserImage();
localUserImage.setUser(user);
localUserImage.setContentType(contentType);
localUserImage.setContent(content);
return persist(localUserImage);
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserImage in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method listUserImagesByUserIdentifier.
/**
* {@inheritDoc}
*/
@Override
public List<UserImage> listUserImagesByUserIdentifier(String userIdentifier) {
List<UserImage> result = new ArrayList<>();
List<LocalUserImage> images = localUserSchoolDataController.listUserImagesByUserIdentifier(userIdentifier);
for (LocalUserImage image : images) {
UserImage userImage = toLocalUserImageImpl(image);
if (userImage != null) {
result.add(userImage);
} else {
throw new SchoolDataBridgeInternalException("Unexpected error occured while listing LocalUserImages");
}
}
return result;
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserImage in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method removeUserImage.
/**
* {@inheritDoc}
*/
@Override
public void removeUserImage(String identifier) {
LocalUserImage localUserImage = localUserSchoolDataController.findUserImage(identifier);
if (localUserImage == null) {
throw new SchoolDataBridgeInternalException("UserImage can not be removed because it does not exist");
}
localUserSchoolDataController.removeUserImage(localUserImage);
}
use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUserImage in project muikku by otavanopisto.
the class LocalUserImageDAO method listByUser.
public List<LocalUserImage> listByUser(LocalUser user) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<LocalUserImage> criteria = criteriaBuilder.createQuery(LocalUserImage.class);
Root<LocalUserImage> root = criteria.from(LocalUserImage.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(LocalUserImage_.user), user));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations