Commit edb41b46 authored by michael.simon's avatar michael.simon
Browse files

Refit registration for new RegistryStatus DEPROVISIONED

parent 5acad629
......@@ -54,7 +54,7 @@ public interface RegistryDao extends BaseDao<RegistryEntity, Long> {
RegistryStatus status, Date date, int limit);
List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service,
UserEntity user, RegistryStatus status);
UserEntity user, RegistryStatus... status);
List<RegistryEntity> findByUserAndNotStatus(UserEntity user,
RegistryStatus status);
......
......@@ -10,6 +10,7 @@
******************************************************************************/
package edu.kit.scc.webreg.dao.jpa;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -195,14 +196,18 @@ public class JpaRegistryDao extends JpaBaseDao<RegistryEntity, Long> implements
}
@Override
public List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service, UserEntity user, RegistryStatus status) {
public List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service, UserEntity user, RegistryStatus... status) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<RegistryEntity> criteria = builder.createQuery(RegistryEntity.class);
Root<RegistryEntity> root = criteria.from(RegistryEntity.class);
criteria.where(builder.and(
builder.equal(root.get("service"), service),
builder.equal(root.get("user"), user),
builder.notEqual(root.get("registryStatus"), status)));
List<Predicate> predList = new ArrayList<Predicate>();
predList.add(builder.equal(root.get("service"), service));
predList.add(builder.equal(root.get("user"), user));
for (RegistryStatus s : status)
predList.add(builder.notEqual(root.get("registryStatus"), s));
criteria.where(builder.and(predList.toArray(new Predicate[]{})));
criteria.select(root);
return em.createQuery(criteria).getResultList();
......
......@@ -52,7 +52,7 @@ public interface RegistryService extends BaseService<RegistryEntity, Long> {
RegistryStatus status, Date date, int limit);
List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service,
UserEntity user, RegistryStatus status);
UserEntity user, RegistryStatus... status);
List<RegistryEntity> findByUserAndNotStatus(UserEntity user,
RegistryStatus status);
......
......@@ -83,7 +83,7 @@ public class RegistryServiceImpl extends BaseServiceImpl<RegistryEntity, Long> i
}
@Override
public List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service, UserEntity user, RegistryStatus status) {
public List<RegistryEntity> findByServiceAndUserAndNotStatus(ServiceEntity service, UserEntity user, RegistryStatus... status) {
return dao.findByServiceAndUserAndNotStatus(service, user, status);
}
......
......@@ -103,7 +103,8 @@ public class RegisterServiceBean implements Serializable {
service = serviceService.findWithPolicies(id);
List<RegistryEntity> r = registryService.findByServiceAndUserAndNotStatus(service, user, RegistryStatus.DELETED);
List<RegistryEntity> r = registryService.findByServiceAndUserAndNotStatus(service, user,
RegistryStatus.DELETED, RegistryStatus.DEPROVISIONED);
if (r.size() != 0) {
errorState = true;
messageGenerator.addResolvedErrorMessage("errorState", "error", "already_registered", true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment