enhanced web site functionality

master
ff2009 2015-11-14 15:09:43 +00:00
parent 6a2810f7a1
commit 527feb7d1d
7 changed files with 80 additions and 51 deletions

View File

@ -97,22 +97,9 @@ public class ParticipantBean {
}
}
public void listEvents( long idParticipant) {
/* try {
Participant participant = em.find(Participant.class, idParticipant);
if( participant == null){
throw new EntityDoesNotExistsException("There is no event with that id.");
}
List<Event> events = (List<Event>) participant.getEvents();
return eventsToDTOs(events);
} catch (EntityDoesNotExistsException e) {
throw e;
} catch (Exception e) {
throw new EJBException(e.getMessage());
}*/
}
public void enrollParticipant(int id, long id_event)
public void enrollParticipant(int id, int id_event)
throws EntityDoesNotExistsException, ParticipantEnrolledException {
try {
Event event = em.find(Event.class, id_event);
@ -138,7 +125,7 @@ public class ParticipantBean {
}
}
public void unrollParticipant(int id, long id_event)
public void unrollParticipant(int id, int id_event)
throws EntityDoesNotExistsException, ParticipantNotEnrolledException {
try {
Event event = em.find(Event.class, id_event);
@ -180,15 +167,14 @@ public class ParticipantBean {
}
}
/*public List<ParticipantDTO> getUnrolledParticipants(long id_event) throws EntityDoesNotExistsException{
public List<ParticipantDTO> getUnrolledParticipants(int id_event) throws EntityDoesNotExistsException{
try {
Event event = em.find(Event.class, id_event);
if( event == null){
throw new EntityDoesNotExistsException("There is no event with that id.");
}
List<Participant> participants = (List<Participant>) em.createNamedQuery("getAllEventParticipants")
.setParameter("eventId", event.getId())
.getResultList();
List<Participant> participants = em.createNamedQuery("getAllParticipants").getResultList();
List<Participant> enrolled = em.find(Event.class, id_event).getParticipants();
participants.removeAll(enrolled);
return participantsToDTOs(participants);
@ -197,7 +183,7 @@ public class ParticipantBean {
} catch (Exception e) {
throw new EJBException(e.getMessage());
}
}*/
}
public List<ParticipantDTO> getAllParticipants() {
List<Participant> participants = (List<Participant>) em.createNamedQuery("getAllParticipants").getResultList();

View File

@ -55,12 +55,12 @@ public class Event implements Serializable {
= @JoinColumn(name = "EVENT_ID", referencedColumnName = "ID"),
inverseJoinColumns
= @JoinColumn(name = "PARTICIPANT_ID", referencedColumnName = "ID"))
protected List<Participant> participants;
private List<Participant> participants;
@ManyToOne
@JoinColumn(name = "RESPONSIBLE_ID")
@NotNull
protected Responsible responsible;
private Responsible responsible;

View File

@ -24,8 +24,8 @@ import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = "getAllParticipants",
query = "SELECT p FROM Participant p ORDER BY p.name"),
/*@NamedQuery(name = "getAllEventParticipants",
query = "SELECT p FROM Participant p WHERE p.events.id = :eventId ORDER BY p.name")*/
/*@NamedQuery(name = "getAllEventParticipants",
query = "SELECT p FROM Participant p WHERE p.events.id = :eventId ORDER BY p.name")*/
})
@ -71,11 +71,10 @@ public class Participant extends User implements Serializable {
public void setSubjects(List<Subject> subjects) {
this.subjects = subjects;
}
@Override
public String toString() {
return "Participant{" + "username=" + id + ", password=" + password + ", name=" + name + ", email=" + email + '}';
}
}

View File

@ -271,6 +271,10 @@ public class AdministratorManager {
public List<ParticipantDTO> getEnrolledParticipants() throws EntityDoesNotExistsException {
return participantBean.getEnrolledParticipants(currentEvent.getId());
}
public List<ParticipantDTO> getUnrolledParticipants() throws EntityDoesNotExistsException {
return participantBean.getUnrolledParticipants(currentEvent.getId());
}
public AdministratorBean getAdministratorBean() {
return administratorBean;

View File

@ -13,9 +13,13 @@ and open the template in the editor.
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div>Participants:</div>
<h:dataTable value="#{administratorManager.allParticipants}" var="participant">
<h:dataTable value="#{administratorManager.allParticipants}"
var="participant"
summary="List of all Participant"
rules="all"
cellpadding="5">
<h:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{participant.name}"/>
@ -26,7 +30,7 @@ and open the template in the editor.
<h:outputText value="#{participant.email}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Actions" />
@ -35,24 +39,15 @@ and open the template in the editor.
<h:commandLink value="Details" action="responsible_details?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.currentResponsible}" value="#{responsible}" />
</h:commandLink>
<h:commandLink value="Update" action="admin_update_user?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.currentParticipant}" value="#{user}" />
</h:commandLink>
<h:commandLink value="Remove" actionListener="#{administratorManager.removeUser}">
<f:param name="deleteUserId" id="deleteUser" value="#{user.id}" />
</h:commandLink>
</h:form>
</h:column>
</h:dataTable>
<h:form>
<h:commandLink action="admin_user_create" value="New Participant"></h:commandLink>
<br></br>
<h:commandLink action="index" value="Back"></h:commandLink>
</h:form>
<br></br>
<h:commandLink action="index" value="Back"></h:commandLink>
</h:form>
</body>
</html>

View File

@ -13,7 +13,7 @@ and open the template in the editor.
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div>Event Details</div>
<div>Event Details:</div>
<h:dataTable value="#{administratorManager.currentEvent}"
var="event"
summary="List of all Event"
@ -50,15 +50,54 @@ and open the template in the editor.
<h:commandLink action="create_event" value="Alterar Responsavel"></h:commandLink>
<h:commandLink action="create_event" value="Open Attendance"></h:commandLink>
<br></br>
<h:commandLink action="AdminPage" value="Back"></h:commandLink>
</h:form>
</h:column>
</h:dataTable>
<br></br>
<div>Participants:</div>
<h:dataTable value="#{administratorManager.enrolledParticipants}" var="participant">
<div>Enrolled Participants:</div>
<h:dataTable value="#{administratorManager.enrolledParticipants}"
var="participant"
summary="List of Enrolled Participants"
rules="all"
cellpadding="5">
<h:column>
<f:facet name="header">ID</f:facet>
<h:outputText value="#{participant.id}"/>
</h:column>
<h:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{participant.name}"/>
</h:column>
<h:column>
<f:facet name="header">Email</f:facet>
<h:outputText value="#{participant.email}"/>
</h:column>
<h:form>
<h:commandLink value="Add participant" action="event_detais?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.currentParticipant}" value="#{participant}" />
</h:commandLink>
<h:commandLink value="Add participant" actionListener="#{administratorManager.enrollParticipant}">
<f:param name="administratorID" id="administratorID" value="#{administrator.id}"/>
</h:commandLink>
</h:form>
</h:dataTable>
<br></br>
<div>Unrolled Participants:</div>
<h:dataTable value="#{administratorManager.unrolledParticipants}"
var="participant"
summary="List of Unrolled Participants"
rules="all"
cellpadding="5">
<h:column>
<f:facet name="header">ID</f:facet>
<h:outputText value="#{participant.id}"/>
@ -76,5 +115,11 @@ and open the template in the editor.
</h:column>
</h:dataTable>
<br></br>
<h:form>
<h:commandLink action="AdminPage" value="Back"></h:commandLink>
</h:form>
</body>
</html>

View File

@ -19,10 +19,10 @@ and open the template in the editor.
<h:form>
<h:commandLink action="AdminPage" value="Administrator"></h:commandLink>
<br></br>
<h:commandLink action="ParticipantPage" value="Participant"></h:commandLink>
<br></br>
<h:commandLink action="ResponsiblePage" value="Responsible"></h:commandLink>
<br></br>
<h:commandLink action="ParticipantPage" value="Participant"></h:commandLink>
<br></br>
<h:commandLink action="EventPage" value="Event"></h:commandLink>
</h:form>