/kickup/trunk/src/ak/kickup/core/action/AdminParticipantAction.java |
---|
205,8 → 205,16 |
participant.setPrivateComment((String)theForm.get("privateComment")); |
ParticipantManager.getInstance().save(participant); |
if(newParticipant) |
Messages.sendRegistrationMessage(participant, null); |
if(newParticipant) { |
try { |
Messages.sendRegistrationMessage(participant, null); |
} |
catch(Exception ex) { |
request.setAttribute("event", event); |
initLists(request, event); |
throw ex; |
} |
} |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
/kickup/trunk/src/ak/kickup/core/action/ActAction.java |
---|
0,0 → 1,63 |
package ak.kickup.core.action; |
import java.util.List; |
import java.util.Collections; |
import java.util.ArrayList; |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletResponse; |
import org.apache.struts.action.Action; |
import org.apache.struts.action.ActionMapping; |
import org.apache.struts.action.ActionForm; |
import org.apache.struts.action.DynaActionForm; |
import org.apache.struts.action.ActionForward; |
import org.apache.struts.action.ActionMessages; |
import org.apache.struts.action.ActionErrors; |
import org.apache.struts.action.ActionError; |
import ak.strutsx.RequestUtilsX; |
import ak.strutsx.ErrorHandlerX; |
import ak.backpath.BackPath; |
import ak.kickup.util.StringConverter; |
import ak.kickup.util.UserException; |
import ak.kickup.util.ModelSecurityException; |
import ak.kickup.core.model.Participant; |
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.mail.Messages; |
public final class ActAction |
extends Action |
{ |
public ActionForward execute(ActionMapping mapping, ActionForm form, |
HttpServletRequest request, HttpServletResponse response) |
throws Exception |
{ |
if("list".equals(mapping.getParameter())) { |
DynaActionForm theForm = (DynaActionForm)form; |
Long eventId = StringConverter.parseLong(theForm.get("event")); |
Event event = EventManager.getInstance().get(eventId, true); |
Long actId = StringConverter.parseLong(theForm.get("act")); |
EventAct act = event.getAct(actId); |
List list; |
if(act == null) throw new UserException("ak.kickup.core.act.edit.id.wrong"); |
list = new ArrayList(ParticipantManager.getInstance().listForAct(act)); |
Collections.sort(list, ParticipantManager.ACT_NICK_COMPARATOR); |
request.setAttribute("list", list); |
request.setAttribute("event", event); |
request.setAttribute("act", act); |
return mapping.findForward("default"); |
} |
else { |
throw new Exception("unknown mapping parameter"); |
} |
} |
} |
/kickup/trunk/src/ak/kickup/core/action/TransportAction.java |
---|
33,7 → 33,7 |
Long eventId = StringConverter.parseLong(theForm.get("event")); |
Event event = EventManager.getInstance().get(eventId, true); |
List list = new ArrayList(ParticipantManager.getInstance().listFreeTransport(event)); |
Collections.sort(list, ParticipantManager.NICK_COMPARATOR); |
Collections.sort(list, ParticipantManager.FROM_ZIP_COMPARATOR); |
request.setAttribute("participants", list); |
request.setAttribute("event", event); |
return mapping.findForward("default"); |
/kickup/trunk/src/ak/kickup/core/action/ParticipantAction.java |
---|
236,7 → 236,14 |
ParticipantManager.getInstance().save(participant); |
Messages.sendRegistrationMessage(participant, request.getRemoteAddr()); |
try { |
Messages.sendRegistrationMessage(participant, request.getRemoteAddr()); |
} |
catch(Exception ex) { |
request.setAttribute("event", event); |
initLists(request, event); |
throw ex; |
} |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
/kickup/trunk/src/ak/kickup/core/CoreResources.properties |
---|
29,7 → 29,8 |
ak.kickup.core.participant.edit.nick.required=Ник обязателен |
ak.kickup.core.participant.edit.email.required=e-mail обязателен |
ak.kickup.core.participant.edit.email.wrong=Некорректный e-mail |
ak.kickup.core.participant.edit.persons.wrong=Количество должно быть целым числом |
ak.kickup.core.participant.edit.persons.required=Количество не указано |
ak.kickup.core.participant.edit.persons.wrong=Количество должно быть положительным целым числом |
ak.kickup.core.participant.edit.freetransport.wrong=Количество мест в машине должно быть целым числом |
ak.kickup.core.participant.edit.departure.wrong=Время отправления дожно быть, например, 20.10.2004 13:55 |
ak.kickup.core.participant.edit.freesleep.wrong=Количество спальных мест должно быть целым числом |
/kickup/trunk/src/ak/kickup/core/model/ParticipantManager.java |
---|
200,6 → 200,22 |
} |
} |
public Collection listForAct(EventAct act) |
throws ModelException |
{ |
try { |
return HibernateUtil.currentSession().find( |
"select pa from Participant as p, ParticipantAct as pa" |
+ " where p.event = ? and pa.participant = p and pa.act = ?", |
new Object[] { act.getEvent(), act.getAct() }, |
new Type[] { Hibernate.entity(Event.class), Hibernate.entity(Act.class) } ); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public ParticipantAct createAct() |
throws ModelException |
{ |
222,6 → 238,8 |
} |
public static final Comparator NICK_COMPARATOR = new NickComparator(); |
public static final Comparator ACT_NICK_COMPARATOR = new ActNickComparator(); |
public static final Comparator FROM_ZIP_COMPARATOR = new FromZipComparator(); |
private static class NickComparator |
implements Comparator |
249,4 → 267,58 |
return (obj instanceof NickComparator); |
} |
} |
private static class ActNickComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof ParticipantAct) || !(o2 instanceof ParticipantAct)) |
throw new ClassCastException("not a ParticipantAct"); |
ParticipantAct a1 = (ParticipantAct)o1; |
ParticipantAct a2 = (ParticipantAct)o2; |
if(a1 == null && a2 == null) |
return 0; |
else if(a1 == null && a2 != null) |
return -1; |
else if(a1 != null && a2 == null) |
return 1; |
else |
return a1.getParticipant().getNick().compareToIgnoreCase(a2.getParticipant().getNick()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof ActNickComparator); |
} |
} |
private static class FromZipComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof Participant) || !(o2 instanceof Participant)) |
throw new ClassCastException("not a Participant"); |
Participant a1 = (Participant)o1; |
Participant a2 = (Participant)o2; |
if((a1 == null || a1.getFromZip() == null) && (a2 == null || a2.getFromZip() == null)) |
return 0; |
else if((a1 == null || a1.getFromZip() == null) && (a2 != null && a2.getFromZip() != null)) |
return -1; |
else if((a1 != null && a1.getFromZip() == null) && (a2 == null || a2.getFromZip() == null)) |
return 1; |
else |
return a1.getFromZip().compareToIgnoreCase(a2.getFromZip()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof FromZipComparator); |
} |
} |
} |