add participants to event

BUGGGGG and CRASH
master
ff2009 2015-11-14 21:06:35 +00:00
parent 7eca928e13
commit 17f6402710
7 changed files with 113 additions and 33 deletions

View File

@ -5,7 +5,6 @@
*/
package dtos;
import entity.Responsible;
import java.io.Serializable;
import java.util.Date;
@ -22,13 +21,13 @@ public class EventDTO implements Serializable {
private String local;
private int responsible_id;
private String responsible_name;
private boolean openInscrptions;
private boolean openInscriptions;
public EventDTO() {
}
public EventDTO(int id, Date date, String name, String type, String local, int responsible_id, String responsible_name) {
public EventDTO(int id, Date date, String name, String type, String local, int responsible_id, String responsible_name, boolean openInscriptions) {
this.id = id;
this.date = date;
this.name = name;
@ -36,6 +35,9 @@ public class EventDTO implements Serializable {
this.local = local;
this.responsible_id = responsible_id;
this.responsible_name = responsible_name;
this.openInscriptions = openInscriptions;
}
public void reset(){
@ -104,6 +106,14 @@ public class EventDTO implements Serializable {
public void setResponsible_name(String responsible_name) {
this.responsible_name = responsible_name;
}
public boolean isOpenInscriptions() {
return openInscriptions;
}
public void setOpenInscriptions(boolean openInscrptions) {
this.openInscriptions = openInscrptions;
}

View File

@ -129,8 +129,8 @@ public class EventBean {
if (event == null) {
throw new EntityDoesNotExistsException("There is no event with that id.");
}
event.setOpenInscriptions(false);
em.remove(event);
} catch (EntityDoesNotExistsException e) {
throw e;
} catch (Exception e) {
@ -179,7 +179,8 @@ public class EventBean {
event.getType(),
event.getLocal(),
event.getResponsible().getId(),
event.getResponsible().getName());
event.getResponsible().getName(),
event.isOpenInscriptions());
}
List<EventDTO> eventsToDTOs(List<Event> events) {

View File

@ -47,7 +47,7 @@ public class Event implements Serializable {
private String type;
@NotNull
private String local;
private boolean openInscriptions;
@ManyToMany
@JoinTable(name = "EVENT_PARTICIPANT",
@ -61,7 +61,7 @@ public class Event implements Serializable {
@JoinColumn(name = "RESPONSIBLE_ID")
@NotNull
private Responsible responsible;
private boolean openInscriptions;
// Add business logic below. (Right-click in editor and choose

View File

@ -16,6 +16,8 @@ import ejbs.ParticipantBean;
import ejbs.ResponsibleBean;
import ejbs.SubjectBean;
import exceptions.EntityDoesNotExistsException;
import exceptions.ParticipantEnrolledException;
import exceptions.ParticipantNotEnrolledException;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
@ -49,6 +51,7 @@ public class AdministratorManager {
private ResponsibleDTO currentResponsible;
private ParticipantDTO newParticipant;
private ParticipantDTO currentParticipant;
private List<ParticipantDTO> listParticipants;
private EventDTO newEvent;
private EventDTO currentEvent;
private UIComponent component;
@ -204,6 +207,12 @@ public class AdministratorManager {
logger.warning("Problem removing user in method removeUser().");
}
}
public void printToScreen() {
System.out.println("participant: " + listParticipants);
//System.out.println("event: " + currentEvent.getName());
}
public List<ParticipantDTO> getAllParticipants() {
return participantBean.getAllParticipants();
@ -219,12 +228,12 @@ public class AdministratorManager {
}
//////////////////////////// Event \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public void openInscriptions(int eventId) throws EntityDoesNotExistsException {
eventBean.openInscriptions(eventId);
public void openInscriptions() throws EntityDoesNotExistsException {
eventBean.openInscriptions(currentEvent.getId());
}
public void closeInscriptions(int eventId) throws EntityDoesNotExistsException {
eventBean.closeInscriptions(eventId);
public void closeInscriptions() throws EntityDoesNotExistsException {
eventBean.closeInscriptions(currentEvent.getId());
}
public String createEvent() {
@ -281,7 +290,32 @@ public class AdministratorManager {
}
public List<ParticipantDTO> getUnrolledParticipants() throws EntityDoesNotExistsException {
return participantBean.getUnrolledParticipants(currentEvent.getId());
return participantBean.getUnrolledParticipants(currentEvent.getId());
}
public void enrollParticipants(ActionEvent event) throws EntityDoesNotExistsException, ParticipantEnrolledException {
try{
UIParameter param = (UIParameter) event.getComponent().findComponent("participantId");
int id = Integer.parseInt(param.getValue().toString());
System.out.println("Participant Id: " + currentParticipant.getId() + "Event Id: " + currentEvent.getId());
participantBean.enrollParticipant(currentParticipant.getId(), currentEvent.getId());
} catch (Exception e) {
logger.warning("Problem enrolling participant in method enrollParticipants().");
}
}
public void unrollParticipants(ActionEvent event) throws EntityDoesNotExistsException, ParticipantNotEnrolledException {
try{
UIParameter param = (UIParameter) event.getComponent().findComponent("participantId");
int id = Integer.parseInt(param.getValue().toString());
participantBean.unrollParticipant(currentParticipant.getId(), currentEvent.getId());
} catch (Exception e) {
logger.warning("Problem enrolling participant in method enrollParticipants().");
}
}
public AdministratorBean getAdministratorBean() {
@ -396,4 +430,19 @@ public class AdministratorManager {
this.currentEvent = currentEvent;
}
public List<ParticipantDTO> getListParticipants() {
return listParticipants;
}
public void setListParticipants(List<ParticipantDTO> listParticipants) {
this.listParticipants = listParticipants;
}
}

View File

@ -14,15 +14,14 @@ and open the template in the editor.
</head>
<body>
<div>Lista de Utilizadores / Participantes : </div>
<br></br>
<h:form>
<h:column>
<h:selectManyMenu
<h:selectManyListbox
id="participant"
value="#{administratorManager.currentParticipant.id}"
style="height: 500px"
value="#{administratorManager.listParticipants}"
title="Add participants to Event"
>
<f:selectItems
value="#{administratorManager.allParticipants}"
@ -30,9 +29,22 @@ and open the template in the editor.
itemValue="#{participant.id}"
itemLabel="#{participant.name}"
/>
</h:selectManyMenu>
</h:selectManyListbox >
</h:column>
<br></br>
<h:commandButton value="Submit" action="result" />
<h:commandButton value="Reset" type="reset" />
<h:panelGrid>
<h:commandButton
id="submit"
value="Submit"
action="#{administratorManager.printToScreen}">
</h:commandButton>
<h:message for="submit" />
</h:panelGrid>
</h:form>
</body>

View File

@ -13,8 +13,6 @@ and open the template in the editor.
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div>Event Details</div>
<h:dataTable value="#{administratorManager.currentEvent}" var="event">
<div>Event Details:</div>
<h:dataTable value="#{administratorManager.currentEvent}"
var="event"
@ -81,15 +79,14 @@ and open the template in the editor.
<h:outputText value="#{participant.email}"/>
</h:column>
<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 value="Add participant" actionListener="#{administratorManager.unrollParticipants}">
<f:param name="participantId" id="participantId" value="#{participant}"/>
</h:commandLink>
</h:form>
</h:column>
</h:dataTable>
<br></br>
@ -115,6 +112,15 @@ and open the template in the editor.
<h:outputText value="#{participant.email}"/>
</h:column>
<h:column>
<h:form>
<h:commandLink value="Add participant" actionListener="#{administratorManager.enrollParticipants}">
<f:param name="participantId" id="participantId" value="#{participant}"/>
</h:commandLink>
</h:form>
</h:column>
</h:dataTable>
<br></br>

View File

@ -35,7 +35,7 @@ and open the template in the editor.
<h:form>
<h:commandLink action="admin_responsible_update" value="Criar Responsavel"></h:commandLink>
</h:form>
<br></br><br></br>
<div>Responsible Events</div>
<h:dataTable value="#{administratorManager.currentResponsibleEvents}"
@ -68,15 +68,17 @@ and open the template in the editor.
<f:facet name="header">
<h:outputText value="Actions" />
</f:facet>
<h:form>
<h:commandLink value="Open inscriptions" action="responsible_details?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.openInscriptions(event.id)}" value="#{responsible}" />
<f:setPropertyActionListener target="#{administratorManager.openInscriptions}" value="#{event}" />
</h:commandLink>
</h:form>
<div></div>
<h:form rendered="#{event.openInscriptions}">
<h:commandLink value="Close inscriptions" action="responsible_details?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.closeInscriptions(event.id)}" value="#{responsible}" />
<f:setPropertyActionListener target="#{administratorManager.closeInscriptions}" value="#{event}" />
</h:commandLink>
<f:facet name="header">Responsible</f:facet>
<h:outputText value="#{event.responsible_name}"/>
</h:form>
</h:column>
<h:column>
<f:facet name="header">Add Participants</f:facet>