Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 16 → Rev 19

/kickup/trunk/src/ak/kickup/core/model/ParticipantManager.java
63,6 → 63,25
}
}
 
public Participant findForIdent(String ident)
throws ModelException
{
try {
List list = HibernateUtil.currentSession().find(
"from Participant where ident = ?",
ident, Hibernate.STRING );
 
if(list.size() == 0)
return null;
else
return (Participant)list.get(0);
}
catch(HibernateException ex)
{
throw new ModelException(ex);
}
}
 
public String generateIdent()
throws ModelException
{
/kickup/trunk/src/ak/kickup/core/model/Event.java
20,6 → 20,8
extends GeneralModelObject
{
private String name;
private String email;
private String admins;
private String place;
private String address;
private String transportDesc;
64,6 → 66,34
*
* @hibernate.property
*/
public String getEmail()
{
return email;
}
 
public void setEmail(String email)
{
this.email = email;
}
 
/**
*
* @hibernate.property
*/
public String getAdmins()
{
return admins;
}
 
public void setAdmins(String admins)
{
this.admins = admins;
}
 
/**
*
* @hibernate.property
*/
public String getPlace()
{
return place;
/kickup/trunk/src/ak/kickup/core/action/AdminEventAction.java
72,6 → 72,8
else {
event = EventManager.getInstance().get(eventId, false);
showForm.set("name", event.getName());
showForm.set("email", event.getEmail());
showForm.set("admins", event.getAdmins());
showForm.set("place", event.getPlace());
showForm.set("address", event.getAddress());
showForm.set("transport", event.getTransportDesc());
190,6 → 192,8
event.setName(name);
 
// others
event.setEmail((String)theForm.get("email"));
event.setAdmins((String)theForm.get("admins"));
event.setPlace((String)theForm.get("place"));
event.setAddress((String)theForm.get("address"));
event.setTransportDesc((String)theForm.get("transport"));
/kickup/trunk/src/ak/kickup/core/action/ParticipantAction.java
22,6 → 22,7
 
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;
35,23 → 36,22
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
if("submit".equals(mapping.getParameter())) {
/*
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
if(participantId == null) {
participant = ParticipantManager.getInstance().create();
}
else {
participant = ParticipantManager.getInstance().get(participantId);
}
if("submit".equals(mapping.getParameter()) || "update".equals(mapping.getParameter())
|| "unregister".equals(mapping.getParameter()))
{
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = (eventId == null)
? null : EventManager.getInstance().get(eventId, true);
request.setAttribute("event", event);
request.setAttribute("participant", participant);
*/
}
 
if("update".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
String ident = (String)theForm.get("ident");
request.setAttribute("participant",
(ident == null) ? null : ParticipantManager.getInstance().findForIdent(ident));
}
}
 
public ActionForward execute(ActionMapping mapping, ActionForm form,
68,69 → 68,82
request.setAttribute("event", event);
return mapping.findForward("default");
}
/*
else if("edit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ParticipantEditForm");
else if("ident".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
request.setAttribute("event", event);
return mapping.findForward("default");
}
else if("register".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ParticipantRegisterForm");
 
if(participantId == null) {
participant = ParticipantManager.getInstance().create();
showForm.set("emailPublic", Boolean.TRUE);
 
request.setAttribute("event", event);
return mapping.findForward("default");
}
else if("login".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
String ident = (String)theForm.get("ident");
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ParticipantRegisterEditForm");
 
Participant participant = ParticipantManager.getInstance().findForIdent(ident);
if(participant == null) {
Thread.sleep(1000);
request.setAttribute("event", event);
throw new UserException("ak.kickup.core.participant.edit.ident.wrong");
}
else {
participant = ParticipantManager.getInstance().get(participantId);
showForm.set("nick", participant.getNick());
showForm.set("email", participant.getEmail());
showForm.set("emailPublic", participant.getEmailPublic());
showForm.set("name", participant.getName());
showForm.set("phone", participant.getPhone());
showForm.set("persons", StringConverter.toString(participant.getPersons()));
showForm.set("fromZip", participant.getFromZip());
showForm.set("fromCity", participant.getFromCity());
showForm.set("departure", StringConverter.toDateTime(participant.getDeparture()));
showForm.set("freeTransport", StringConverter.toString(participant.getFreeTransport()));
showForm.set("transportComment", participant.getTransportComment());
showForm.set("freeSleep", StringConverter.toString(participant.getFreeSleep()));
showForm.set("sleepComment", participant.getSleepComment());
showForm.set("payed", participant.getPayed());
showForm.set("comment", participant.getComment());
showForm.set("privateComment", participant.getPrivateComment());
}
 
request.setAttribute("event", event);
showForm.set("emailPublic", participant.getEmailPublic());
showForm.set("name", participant.getName());
showForm.set("phone", participant.getPhone());
showForm.set("persons", StringConverter.toString(participant.getPersons()));
showForm.set("fromZip", participant.getFromZip());
showForm.set("fromCity", participant.getFromCity());
showForm.set("departure", StringConverter.toDateTime(participant.getDeparture()));
showForm.set("freeTransport", StringConverter.toString(participant.getFreeTransport()));
showForm.set("transportComment", participant.getTransportComment());
showForm.set("freeSleep", StringConverter.toString(participant.getFreeSleep()));
showForm.set("sleepComment", participant.getSleepComment());
showForm.set("comment", participant.getComment());
 
request.setAttribute("participant", participant);
request.setAttribute("event", event);
return mapping.findForward("default");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant = ParticipantManager.getInstance().get(participantId);
else if("unregister".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
String ident = (String)theForm.get("ident");
Participant participant = ParticipantManager.getInstance().findForIdent(ident);
 
if(participant == null) {
Thread.sleep(1000);
throw new UserException("ak.kickup.core.participant.edit.ident.wrong");
}
 
ParticipantManager.getInstance().delete(participant);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
request.setAttribute("event", event);
return mapping.findForward("default");
}
else if("submit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
Participant participant = ParticipantManager.getInstance().create();
 
if(participantId == null) {
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
participant.setIdent(ParticipantManager.getInstance().generateIdent());
participant.setEvent(event);
 
participant = ParticipantManager.getInstance().create();
participant.setIdent(ParticipantManager.getInstance().generateIdent());
participant.setEvent(event);
}
else {
participant = ParticipantManager.getInstance().get(participantId);
}
 
participant.setNick((String)theForm.get("nick"));
participant.setEmail((String)theForm.get("email"));
participant.setEmailPublic((Boolean)theForm.get("emailPublic"));
144,15 → 157,45
participant.setTransportComment((String)theForm.get("transportComment"));
participant.setFreeSleep(StringConverter.parseInteger(theForm.get("freeSleep")));
participant.setSleepComment((String)theForm.get("sleepComment"));
participant.setPayed((Boolean)theForm.get("payed"));
participant.setComment((String)theForm.get("comment"));
participant.setPrivateComment((String)theForm.get("privateComment"));
 
ParticipantManager.getInstance().save(participant);
 
// FIXME: send email here
 
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
}
*/
else if("update".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, true);
String ident = (String)theForm.get("ident");
Participant participant = ParticipantManager.getInstance().findForIdent(ident);
 
if(participant == null) {
Thread.sleep(1000);
throw new ModelSecurityException();
}
 
participant.setEmailPublic((Boolean)theForm.get("emailPublic"));
participant.setName((String)theForm.get("name"));
participant.setPhone((String)theForm.get("phone"));
participant.setPersons(StringConverter.parseInteger(theForm.get("persons")));
participant.setFromZip((String)theForm.get("fromZip"));
participant.setFromCity((String)theForm.get("fromCity"));
participant.setDeparture(StringConverter.parseDateTime(theForm.get("departure")));
participant.setFreeTransport(StringConverter.parseInteger(theForm.get("freeTransport")));
participant.setTransportComment((String)theForm.get("transportComment"));
participant.setFreeSleep(StringConverter.parseInteger(theForm.get("freeSleep")));
participant.setSleepComment((String)theForm.get("sleepComment"));
participant.setComment((String)theForm.get("comment"));
 
ParticipantManager.getInstance().save(participant);
 
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
}
else {
throw new Exception("unknown mapping parameter");
}
/kickup/trunk/src/ak/kickup/core/CoreResources.properties
5,6 → 5,9
ak.kickup.core.access.denied=Сюда нельзя!
ak.kickup.core.event.edit.id.wrong=Неизвестная пьянка, выбирайти из списка
ak.kickup.core.event.edit.name.required=Название обязательно
ak.kickup.core.event.edit.admins.required=Имена организаторов обязательны
ak.kickup.core.event.edit.email.required=e-mail обязателен
ak.kickup.core.event.edit.email.wrong=Некорректный e-mail
ak.kickup.core.event.edit.start.wrong=Дата начала должна быть в виде ДД.ММ.ГГГГ
ak.kickup.core.event.edit.stop.wrong=Дата окончания должна быть в виде ДД.ММ.ГГГГ
ak.kickup.core.event.edit.lastreg.wrong=Дата окончания регистрации должна быть в виде ДД.ММ.ГГГГ
23,6 → 26,8
ak.kickup.core.participant.edit.email.wrong=Некорректный e-mail
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=Количество спальных мест должно быть целым числом
ak.kickup.core.participant.edit.ident.wrong=Неизвестный номер
 
org.apache.struts.taglib.bean.format.sql.timestamp=dd.MM.yyyy HH:mm:ss.SSS
/kickup/trunk/src/ak/kickup/util/Validator.java
1,6 → 1,7
package ak.kickup.util;
 
import java.math.BigDecimal;
import java.util.Date;
import java.text.NumberFormat;
import java.text.ParseException;
 
54,5 → 55,25
errors.add(field.getKey(), Resources.getActionError(request, va, field));
return null;
}
}
 
public static Date validateDateTime(Object bean, ValidatorAction va, Field field,
ActionErrors errors, HttpServletRequest request)
{
String value = null;
if((bean == null) || (bean instanceof String))
value = (String)bean;
else
value = ValidatorUtil.getValueAsString(bean, field.getProperty());
 
if(value == null || "".equals(value)) return null;
 
try {
return StringConverter.DATE_TIME_FORMAT.parse(value);
}
catch(ParseException ex) {
errors.add(field.getKey(), Resources.getActionError(request, va, field));
return null;
}
}
}
/kickup/trunk/src/ak/kickup/util/StringConverter.java
3,6 → 3,7
import java.math.BigDecimal;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
9,6 → 10,8
 
public abstract class StringConverter
{
public static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm");
 
public static boolean isEmpty(Object o)
{
if(o == null)
98,7 → 101,7
throws NumberFormatException, ParseException
{
String s = preparse(o);
return (s == null) ? null : DateFormat.getDateTimeInstance().parse(s);
return (s == null) ? null : DATE_TIME_FORMAT.parse(s);
}
 
public static String toDateTime(Date d)
106,7 → 109,7
if(d == null)
return null;
else
return DateFormat.getDateTimeInstance().format(d);
return DATE_TIME_FORMAT.format(d);
}
 
public static String toString(Object o)