use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class JpaUserDevfilePermissionDao method getByInstance.
@Override
@Transactional
public Page<UserDevfilePermissionImpl> getByInstance(String instanceId, int maxItems, long skipCount) throws ServerException {
requireNonNull(instanceId, "User devfile identifier required");
checkArgument(skipCount <= Integer.MAX_VALUE, "The number of items to skip can't be greater than " + Integer.MAX_VALUE);
try {
final EntityManager entityManager = managerProvider.get();
final List<UserDevfilePermissionImpl> permissions = entityManager.createNamedQuery("UserDevfilePermission.getByUserDevfileId", UserDevfilePermissionImpl.class).setParameter("userDevfileId", instanceId).setMaxResults(maxItems).setFirstResult((int) skipCount).getResultList().stream().map(UserDevfilePermissionImpl::new).collect(toList());
final Long permissionsCount = entityManager.createNamedQuery("UserDevfilePermission.getCountByUserDevfileId", Long.class).setParameter("userDevfileId", instanceId).getSingleResult();
return new Page<>(permissions, skipCount, maxItems, permissionsCount);
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
Aggregations