Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 967 → Rev 968

/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);
}
}
}