Merge branch 'master' of https://github.com/NoNameGuy/projectDAE
Conflicts: ProjectDAE/src/java/webpackage/AdministratorManager.java ProjectDAE/web/event_details.xhtml ProjectDAE/web/responsible_details.xhtmlmaster
commit
299940dafe
|
@ -92,6 +92,54 @@ public class EventBean {
|
|||
|
||||
}
|
||||
|
||||
public void enrollParticipant(int eventId, int participantId) throws EntityDoesNotExistsException {
|
||||
try {
|
||||
Event event = em.find(Event.class, eventId);
|
||||
Participant participant = em.find(Participant.class, participantId);
|
||||
if (event == null || participant == null) {
|
||||
throw new EntityDoesNotExistsException("There is no event or participant with that id.");
|
||||
}
|
||||
event.addParticipant(participant);
|
||||
|
||||
} catch (EntityDoesNotExistsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new EJBException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void unEnrollParticipant(int eventId, int participantId) throws EntityDoesNotExistsException {
|
||||
try {
|
||||
Event event = em.find(Event.class, eventId);
|
||||
Participant participant = em.find(Participant.class, participantId);
|
||||
if (event == null || participant == null) {
|
||||
throw new EntityDoesNotExistsException("There is no event or participant with that id.");
|
||||
}
|
||||
event.removeParticipant(participant);
|
||||
} catch (EntityDoesNotExistsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new EJBException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpenInscriptions (int eventId) throws EntityDoesNotExistsException {
|
||||
try {
|
||||
Event event = em.find(Event.class, eventId);
|
||||
if (event == null) {
|
||||
throw new EntityDoesNotExistsException("There is no event with that id.");
|
||||
}
|
||||
if( event.isOpenInscriptions() )
|
||||
return true;
|
||||
|
||||
} catch (EntityDoesNotExistsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new EJBException(e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openInscriptions (int eventId) throws EntityDoesNotExistsException {
|
||||
try {
|
||||
Event event = em.find(Event.class, eventId);
|
||||
|
|
|
@ -228,8 +228,25 @@ public class AdministratorManager {
|
|||
}
|
||||
|
||||
//////////////////////////// Event \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
||||
|
||||
public void openInscriptions() throws EntityDoesNotExistsException {
|
||||
eventBean.openInscriptions(currentEvent.getId());
|
||||
eventBean.openInscriptions(currentEvent.getId());
|
||||
}
|
||||
|
||||
|
||||
public void enrollParticipant() throws EntityDoesNotExistsException {
|
||||
if( eventBean.isOpenInscriptions(currentEvent.getId()))
|
||||
eventBean.enrollParticipant(currentEvent.getId(), currentParticipant.getId());
|
||||
}
|
||||
|
||||
public void unEnrollParticipant(int eventId, int participantId) throws EntityDoesNotExistsException {
|
||||
if( eventBean.isOpenInscriptions(eventId))
|
||||
eventBean.unEnrollParticipant(eventId, participantId);
|
||||
}
|
||||
|
||||
public void openInscriptions(int eventId) throws EntityDoesNotExistsException {
|
||||
eventBean.openInscriptions(eventId);
|
||||
|
||||
}
|
||||
|
||||
public void closeInscriptions() throws EntityDoesNotExistsException {
|
||||
|
@ -294,7 +311,7 @@ public class AdministratorManager {
|
|||
|
||||
}
|
||||
|
||||
public void enrollParticipants(ActionEvent event) throws EntityDoesNotExistsException, ParticipantEnrolledException {
|
||||
/*public void enrollParticipants(ActionEvent event) throws EntityDoesNotExistsException, ParticipantEnrolledException {
|
||||
|
||||
try{
|
||||
UIParameter param = (UIParameter) event.getComponent().findComponent("participantId");
|
||||
|
@ -306,7 +323,7 @@ public class AdministratorManager {
|
|||
logger.warning("Problem enrolling participant in method enrollParticipants().");
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
public void unrollParticipants(ActionEvent event) throws EntityDoesNotExistsException, ParticipantNotEnrolledException {
|
||||
try{
|
||||
|
|
|
@ -79,13 +79,26 @@ 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.unrollParticipants}">
|
||||
<f:param name="participantId" id="participantId" value="#{participant}"/>
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
<h:form>
|
||||
<h:commandLink value="Add participant" actionListener="#{administratorManager.unrollParticipants}">
|
||||
<f:param name="participantId" id="participantId" value="#{participant}"/>
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
</h:column>
|
||||
|
||||
<h:column>
|
||||
<f:facet name="header">
|
||||
<h:outputText value="Actions" />
|
||||
</f:facet>
|
||||
<h:form>
|
||||
<h:commandLink value="Unenroll" action="event_details?faces-redirect=true">
|
||||
<f:setPropertyActionListener target="#{administratorManager.unEnrollParticipant(administratorManager.currentEvent.id, participant.id)}" value="#{participant}" />
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
|
||||
|
@ -113,13 +126,24 @@ and open the template in the editor.
|
|||
|
||||
</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:form>
|
||||
|
||||
<h:commandLink value="Add participant" actionListener="#{administratorManager.enrollParticipants}">
|
||||
<f:param name="participantId" id="participantId" value="#{participant}"/>
|
||||
</h:commandLink>
|
||||
|
||||
</h:form>
|
||||
|
||||
<f:facet name="header">
|
||||
<h:outputText value="Actions" />
|
||||
</f:facet>
|
||||
<h:form>
|
||||
<h:commandLink value="Enroll" action="event_details?faces-redirect=true">
|
||||
<f:setPropertyActionListener target="#{administratorManager.enrollParticipant(administratorManager.currentEvent.id, participant.id)}" value="#{participant}" />
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
|
||||
|
@ -127,7 +151,7 @@ and open the template in the editor.
|
|||
<h:form>
|
||||
<h:commandLink action="AdminPage" value="Back"></h:commandLink>
|
||||
</h:form>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -79,7 +79,6 @@ and open the template in the editor.
|
|||
<f:setPropertyActionListener target="#{administratorManager.closeInscriptions}" value="#{event}" />
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
|
||||
</h:column>
|
||||
<h:column>
|
||||
<f:facet name="header">Add Participants</f:facet>
|
||||
|
|
Loading…
Reference in New Issue