27,6 → 27,9 |
import ak.kickup.core.model.ParticipantManager; |
import ak.kickup.core.model.Event; |
import ak.kickup.core.model.EventManager; |
import ak.kickup.core.model.ParticipantAct; |
import ak.kickup.core.model.EventAct; |
import ak.kickup.core.form.ParticipantActBean; |
|
public final class ParticipantAction |
extends Action |
44,6 → 47,9 |
Event event = (eventId == null) |
? null : EventManager.getInstance().get(eventId, true); |
request.setAttribute("event", event); |
|
if("submit".equals(mapping.getParameter()) || "update".equals(mapping.getParameter())) |
initLists(request, event); |
} |
|
if("update".equals(mapping.getParameter())) { |
84,7 → 90,18 |
|
showForm.set("emailPublic", Boolean.TRUE); |
|
// acts |
List acts = new ArrayList(event.getActCollection()); |
ParticipantActBean[] a = new ParticipantActBean[acts.size()]; |
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR); |
for(int i = 0; i < acts.size(); i++) { |
EventAct act = (EventAct)acts.get(i); |
a[i] = new ParticipantActBean(act.getAct(), null); |
} |
showForm.set("acts", a); |
|
request.setAttribute("event", event); |
initLists(request, event); |
return mapping.findForward("default"); |
} |
else if("login".equals(mapping.getParameter())) { |
103,6 → 120,18 |
throw new UserException("ak.kickup.core.participant.edit.ident.wrong"); |
} |
|
// acts |
List acts = new ArrayList(event.getActCollection()); |
ParticipantActBean[] a = new ParticipantActBean[acts.size()]; |
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR); |
for(int i = 0; i < acts.size(); i++) { |
EventAct act = (EventAct)acts.get(i); |
a[i] = new ParticipantActBean(act.getAct(), |
participant.getAct(act.getAct().getId())); |
} |
showForm.set("acts", a); |
|
// others |
showForm.set("emailPublic", participant.getEmailPublic()); |
showForm.set("name", participant.getName()); |
showForm.set("phone", participant.getPhone()); |
117,6 → 146,7 |
showForm.set("comment", participant.getComment()); |
|
request.setAttribute("participant", participant); |
initLists(request, event); |
return mapping.findForward("default"); |
} |
else if("unregister".equals(mapping.getParameter())) { |
153,11 → 183,43 |
"ak.kickup.core.participant.edit.registration.unavailable"); |
} |
|
// acts |
ParticipantActBean[] acts = (ParticipantActBean[])theForm.get("acts"); |
for(int i = 0; i < acts.length; i++) { |
// get bean |
Long actId = StringConverter.parseLong(acts[i].getActId()); |
EventAct act = event.getAct(actId); |
ParticipantAct participantAct = participant.getAct(actId); |
|
if(acts[i].getSelected() == null || !acts[i].getSelected().booleanValue()) { |
if(participantAct != null) participant.removeAct(participantAct); |
} |
else { |
if(participantAct == null) { |
participantAct = ParticipantManager.getInstance().createAct(); |
participantAct.setParticipant(participant); |
participantAct.setAct(act.getAct()); |
participant.addAct(participantAct); |
} |
participantAct.setComment(acts[i].getComment()); |
} |
} |
|
// bind |
participant.setIdent(ParticipantManager.getInstance().generateIdent()); |
participant.setEvent(event); |
|
// email |
String email = (String)theForm.get("email"); |
if(ParticipantManager.getInstance().emailExists(participant, email)) { |
request.setAttribute("event", event); |
initLists(request, event); |
throw new UserException("ak.kickup.core.participant.email.nonunique"); |
} |
participant.setEmail(email); |
|
// others |
participant.setNick((String)theForm.get("nick")); |
participant.setEmail((String)theForm.get("email")); |
participant.setEmailPublic((Boolean)theForm.get("emailPublic")); |
participant.setName((String)theForm.get("name")); |
participant.setPhone((String)theForm.get("phone")); |
173,7 → 235,7 |
|
ParticipantManager.getInstance().save(participant); |
|
// FIXME: send email here |
Messages.sendRegistrationMessage(participant, request.getRemoteAddr()); |
|
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
191,6 → 253,29 |
throw new ModelSecurityException(); |
} |
|
// acts |
ParticipantActBean[] acts = (ParticipantActBean[])theForm.get("acts"); |
for(int i = 0; i < acts.length; i++) { |
// get bean |
Long actId = StringConverter.parseLong(acts[i].getActId()); |
EventAct act = event.getAct(actId); |
ParticipantAct participantAct = participant.getAct(actId); |
|
if(acts[i].getSelected() == null || !acts[i].getSelected().booleanValue()) { |
if(participantAct != null) participant.removeAct(participantAct); |
} |
else { |
if(participantAct == null) { |
participantAct = ParticipantManager.getInstance().createAct(); |
participantAct.setParticipant(participant); |
participantAct.setAct(act.getAct()); |
participant.addAct(participantAct); |
} |
participantAct.setComment(acts[i].getComment()); |
} |
} |
|
// others |
participant.setEmailPublic((Boolean)theForm.get("emailPublic")); |
participant.setName((String)theForm.get("name")); |
participant.setPhone((String)theForm.get("phone")); |
213,4 → 298,12 |
throw new Exception("unknown mapping parameter"); |
} |
} |
|
private void initLists(HttpServletRequest request, Event event) |
throws Exception |
{ |
List acts = new ArrayList(event.getActCollection()); |
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR); |
request.setAttribute("actList", new ObjectList(acts)); |
} |
} |