Commit 18c45584 authored by michael.simon's avatar michael.simon
Browse files

add first my projects page

parent a7aa6f34
......@@ -56,6 +56,13 @@ public class JpaProjectDao extends JpaBaseDao<ProjectEntity, Long> implements Pr
.setParameter("project", project).getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<ProjectMembershipEntity> findByIdentity(IdentityEntity identity) {
return em.createQuery("select r from ProjectMembershipEntity r where r.identity = :identity")
.setParameter("identity", identity).getResultList();
}
@Override
public ProjectMembershipEntity findByIdentityAndProject(IdentityEntity identity, ProjectEntity project) {
try {
......
......@@ -53,4 +53,6 @@ public interface ProjectDao extends BaseDao<ProjectEntity, Long> {
ExternalOidcProjectEntity findByExternalNameOidc(String externalName, OidcRpConfigurationEntity rpConfig);
ProjectMembershipEntity findByIdentityAndProject(IdentityEntity identity, ProjectEntity project);
List<ProjectMembershipEntity> findByIdentity(IdentityEntity identity);
}
......@@ -40,4 +40,6 @@ public interface ProjectService extends BaseService<ProjectEntity, Long> {
List<ProjectIdentityAdminEntity> findAdminsForProject(ProjectEntity project);
List<ProjectServiceEntity> findServicesForProject(ProjectEntity project);
List<ProjectMembershipEntity> findByIdentity(IdentityEntity identity);
}
......@@ -63,6 +63,11 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectEntity, Long> imp
return dao.findAdminByIdentity(identity);
}
@Override
public List<ProjectMembershipEntity> findByIdentity(IdentityEntity identity) {
return dao.findByIdentity(identity);
}
@Override
public List<ProjectIdentityAdminEntity> findAdminsForProject(ProjectEntity project) {
return dao.findAdminsForProject(project);
......
/*******************************************************************************
* 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.project;
import java.io.Serializable;
import java.util.List;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.identity.IdentityEntity;
import edu.kit.scc.webreg.entity.project.ProjectMembershipEntity;
import edu.kit.scc.webreg.service.identity.IdentityService;
import edu.kit.scc.webreg.service.project.ProjectService;
import edu.kit.scc.webreg.session.SessionManager;
@Named
@ViewScoped
public class UserProjectIndexBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private SessionManager session;
@Inject
private ProjectService projectService;
@Inject
private IdentityService identityService;
private IdentityEntity identity;
private List<ProjectMembershipEntity> projectList;
public void preRenderView(ComponentSystemEvent ev) {
}
public IdentityEntity getIdentity() {
if (identity == null) {
identity = identityService.findById(session.getIdentityId());
}
return identity;
}
public List<ProjectMembershipEntity> getProjectList() {
if (projectList == null) {
projectList = projectService.findByIdentity(getIdentity());
}
return projectList;
}
}
<!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:event type="javax.faces.event.PreRenderViewEvent"
listener="#{userProjectIndexBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form" class="full form">
<h2><h:outputText value="#{messages.my_projects}"/></h2>
<p:dataTable id="dataTable" var="p" value="#{userProjectIndexBean.projectList}" paginator="true" rows="15">
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.id}" />
</f:facet>
<h:outputText value="#{p.project.id}" />
</p:column>
<p:column sortBy="#{p.project.name}" filterBy="#{p.project.name}">
<f:facet name="header">
<h:outputText value="#{messages.name}" />
</f:facet>
<p:outputPanel rendered="#{p.project.class.simpleName == 'ExternalOidcProjectEntity'}">
<h:outputText value="#{p.project.name}" /> (<h:outputText value="#{p.project.rpConfig.displayName}" />)
<h:outputText value="#{p.project.externalName}" />
</p:outputPanel>
<p:outputPanel rendered="#{p.project.class.simpleName == 'LocalProjectEntity'}">
<h:link outcome="show-project.xhtml" value="#{p.project.name}">
<f:param name="projectId" value="#{p.project.id}"/>
</h:link>
</p:outputPanel>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
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