Commit 7dd6da5c authored by michael.simon's avatar michael.simon
Browse files

Query to find possible deprovisionable registries

parent 9080428e
......@@ -58,4 +58,6 @@ public interface RegistryDao extends BaseDao<RegistryEntity, Long> {
List<RegistryEntity> findByUserAndNotStatus(UserEntity user,
RegistryStatus status);
List<RegistryEntity> findRegistriesForDepro(String serviceShortName);
}
......@@ -86,7 +86,18 @@ public class JpaRegistryDao extends JpaBaseDao<RegistryEntity, Long> implements
.setParameter("ssn", serviceShortName).setParameter("status", status).setParameter("is", date)
.setMaxResults(limit).getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<RegistryEntity> findRegistriesForDepro(String serviceShortName) {
return em.createQuery("select r from RegistryEntity r where r.service.shortName = :ssn and r.registryStatus = :status and "
+ "r.agreedTime = (select max(r1.agreedTime) from RegistryEntity r1 where r1.user = r.user) and not exists "
+ "(select r2 from RegistryEntity r2 where r2.user = r.user and r2.agreedTime > r.agreedTime)")
.setParameter("ssn", serviceShortName).setParameter("status", RegistryStatus.DELETED)
.getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<UserEntity> findUserListByServiceAndStatus(ServiceEntity service, RegistryStatus status) {
......
......@@ -56,5 +56,7 @@ public interface RegistryService extends BaseService<RegistryEntity, Long> {
List<RegistryEntity> findByUserAndNotStatus(UserEntity user,
RegistryStatus status);
List<RegistryEntity> findRegistriesForDepro(String serviceShortName);
}
......@@ -49,6 +49,11 @@ public class RegistryServiceImpl extends BaseServiceImpl<RegistryEntity, Long> i
return dao.findByServiceAndStatus(serviceShortName, status, date, limit);
}
@Override
public List<RegistryEntity> findRegistriesForDepro(String serviceShortName) {
return dao.findRegistriesForDepro(serviceShortName);
}
@Override
public List<RegistryEntity> findByServiceAndStatus(ServiceEntity service, RegistryStatus status) {
return dao.findByServiceAndStatus(service, status);
......
......@@ -121,6 +121,7 @@ public class ApprovalServiceImpl implements ApprovalService {
RegisterUserWorkflow workflow = getRegisterWorkflowInstance(registry.getRegisterBean());
try {
registry = registryDao.persist(registry);
ServiceEntity serviceEntity = serviceDao.findByIdWithServiceProps(registry.getService().getId());
UserEntity userEntity = userDao.findByIdWithAll(registry.getUser().getId());
......@@ -136,7 +137,6 @@ public class ApprovalServiceImpl implements ApprovalService {
registry.setRegistryStatus(RegistryStatus.ACTIVE);
registry.setLastStatusChange(new Date());
registry.setLastReconcile(new Date());
registryDao.persist(registry);
HashSet<GroupEntity> userGroups = new HashSet<GroupEntity>(userEntity.getGroups().size());
......
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.RegistryStatus;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.exc.NotAuthorizedException;
import edu.kit.scc.webreg.model.GenericLazyDataModel;
import edu.kit.scc.webreg.model.GenericLazyDataModelImpl;
import edu.kit.scc.webreg.sec.AuthorizationBean;
import edu.kit.scc.webreg.service.RegistryService;
import edu.kit.scc.webreg.service.ServiceService;
@ManagedBean
@ViewScoped
public class ServiceAdminUserListDeproBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private RegistryService service;
@Inject
private ServiceService serviceService;
@Inject
private AuthorizationBean authBean;
private ServiceEntity serviceEntity;
private Long serviceId;
private List<RegistryEntity> deproList;
public void preRenderView(ComponentSystemEvent ev) {
if (serviceEntity == null) {
if (authBean.isUserServiceAdmin(serviceId)) {
serviceEntity = serviceService.findById(serviceId);
deproList = service.findRegistriesForDepro(serviceEntity.getShortName());
}
else
throw new NotAuthorizedException("Nicht autorisiert");
}
}
public ServiceEntity getServiceEntity() {
return serviceEntity;
}
public void setServiceEntity(ServiceEntity serviceEntity) {
this.serviceEntity = serviceEntity;
}
public Long getServiceId() {
return serviceId;
}
public void setServiceId(Long serviceId) {
this.serviceId = serviceId;
}
public List<RegistryEntity> getDeproList() {
return deproList;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui"
xmlns:of="http://omnifaces.org/functions">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="serviceId" value="#{serviceAdminUserListDeproBean.serviceId}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{serviceAdminUserListDeproBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<div id="panelInline">
<p:dataTable id="registeredTable1" var="registry" value="#{serviceAdminUserListDeproBean.deproList}" paginator="true"
rows="15">
<p:column sortBy="#{registry.id}">
<f:facet name="header">
<h:outputText value="#{messages.id}" />
</f:facet>
<h:outputText value="#{registry.id}" />
</p:column>
<p:column sortBy="#{registry.user.eppn}" filterBy="#{registry.user.eppn}">
<f:facet name="header">
<h:outputText value="#{messages.eppn}" />
</f:facet>
<h:link outcome="show-service-registry.xhtml" value="#{registry.user.eppn}">
<f:param name="id" value="#{registry.id}"/>
</h:link>
</p:column>
<p:column sortBy="#{registry.user.surName}" filterBy="#{registry.user.surName}">
<f:facet name="header">
<h:outputText value="#{messages.sur_name}" />
</f:facet>
<h:outputText value="#{registry.user.surName}" />
</p:column>
<p:column sortBy="#{registry.user.givenName}" filterBy="#{registry.user.givenName}">
<f:facet name="header">
<h:outputText value="#{messages.given_name}" />
</f:facet>
<h:outputText value="#{registry.user.givenName}" />
</p:column>
<p:column sortBy="#{registry.agreedTime}">
<f:facet name="header">
<h:outputText value="#{messages.registered_time}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.agreedTime, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.lastStatusChange}">
<f:facet name="header">
<h:outputText value="#{messages.last_status_change}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.lastStatusChange, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.registryStatus}">
<f:facet name="header">
<h:outputText value="#{messages.status}" />
</f:facet>
<h:outputText value="#{registry.registryStatus}" />
</p:column>
</p:dataTable>
<p:commandButton value="CSV Export" ajax="false">
<p:dataExporter target="registeredTable1" type="csv" fileName="users_active" />
</p:commandButton>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
......@@ -29,7 +29,8 @@
<p:tab id="tab1" title="#{messages.active}">
<p:dataTable id="registeredTable1" var="registry" value="#{serviceAdminUserListBean.list}" paginator="true"
lazy="true" rows="15">
lazy="true" rows="15">
<p:column sortBy="#{registry.id}">
<f:facet name="header">
<h:outputText value="#{messages.id}" />
......@@ -62,6 +63,12 @@
</f:facet>
<h:outputText value="#{of:formatDate(registry.agreedTime, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.lastStatusChange}">
<f:facet name="header">
<h:outputText value="#{messages.last_status_change}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.lastStatusChange, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.registryStatus}">
<f:facet name="header">
<h:outputText value="#{messages.status}" />
......@@ -69,6 +76,10 @@
<h:outputText value="#{registry.registryStatus}" />
</p:column>
</p:dataTable>
<p:commandButton value="CSV Export" ajax="false">
<p:dataExporter target="registeredTable1" type="csv" fileName="users_active" />
</p:commandButton>
</p:tab>
<p:tab id="tab2" title="#{messages.lost_access}">
......@@ -106,6 +117,12 @@
</f:facet>
<h:outputText value="#{of:formatDate(registry.agreedTime, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.lastStatusChange}">
<f:facet name="header">
<h:outputText value="#{messages.last_status_change}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.lastStatusChange, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.registryStatus}">
<f:facet name="header">
<h:outputText value="#{messages.status}" />
......@@ -150,6 +167,12 @@
</f:facet>
<h:outputText value="#{of:formatDate(registry.agreedTime, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.lastStatusChange}">
<f:facet name="header">
<h:outputText value="#{messages.last_status_change}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.lastStatusChange, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.registryStatus}">
<f:facet name="header">
<h:outputText value="#{messages.status}" />
......@@ -194,6 +217,12 @@
</f:facet>
<h:outputText value="#{of:formatDate(registry.agreedTime, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.lastStatusChange}">
<f:facet name="header">
<h:outputText value="#{messages.last_status_change}" />
</f:facet>
<h:outputText value="#{of:formatDate(registry.lastStatusChange, 'dd.MM.yyyy HH:mm')}" />
</p:column>
<p:column sortBy="#{registry.registryStatus}">
<f:facet name="header">
<h:outputText value="#{messages.status}" />
......
......@@ -91,6 +91,11 @@
<li><span class="ui-icon ui-icon-carat-1-e" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/service-admin/list-service-users.xhtml" value="#{messages.service_users}">
<f:param name="serviceId" value="#{service.id}" />
</h:link>
</li>
<li><span class="ui-icon ui-icon-carat-1-e" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/service-admin/list-service-users-for-depro.xhtml" value="#{messages.service_users_depro}">
<f:param name="serviceId" value="#{service.id}" />
</h:link>
</li>
<li><span class="ui-icon ui-icon-signal" style="display:inline-block; vertical-align: bottom;" />
......
......@@ -91,6 +91,11 @@
<li><span class="ui-icon ui-icon-carat-1-e" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/service-admin/list-service-users.xhtml" value="#{messages.service_users}">
<f:param name="serviceId" value="#{service.id}" />
</h:link>
</li>
<li><span class="ui-icon ui-icon-carat-1-e" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/service-admin/list-service-users-for-depro.xhtml" value="#{messages.service_users_depro}">
<f:param name="serviceId" value="#{service.id}" />
</h:link>
</li>
<li><span class="ui-icon ui-icon-signal" style="display:inline-block; vertical-align: bottom;" />
......
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