8,6 → 8,7 |
import java.util.Date; |
import java.util.Map; |
import java.util.HashMap; |
import java.util.Calendar; |
import ak.kickup.util.ModelException; |
import ak.kickup.util.ModelSecurityException; |
|
34,6 → 35,7 |
private Map actsMap = new HashMap(); // Map(Long id -> EventAct) |
private Collection apartments; // Collection(EventApartment) |
private Map apartmentsMap = new HashMap(); // Map(Long id -> EventApartment) |
private Collection participants; // Collection(EventAct) |
|
protected Event() |
{ |
311,4 → 313,87 |
apartments.remove(apartment); |
apartmentsMap.remove(apartment.getApartment().getId()); |
} |
|
public boolean isRegistrationAvailable() |
{ |
if(enabled == null || !enabled.booleanValue()) return false; |
|
Calendar cal = Calendar.getInstance(); |
cal.set(Calendar.HOUR_OF_DAY, 0); |
cal.set(Calendar.MINUTE, 0); |
cal.set(Calendar.SECOND, 0); |
cal.set(Calendar.MILLISECOND, 0); |
|
Date now = cal.getTime(); |
|
if(lastRegister == null) { |
return (start == null || !start.before(now)); |
} |
else { |
return !lastRegister.before(now); |
} |
} |
|
public boolean isUnregistrationAvailable() |
{ |
if(enabled == null || !enabled.booleanValue()) return false; |
|
Calendar cal = Calendar.getInstance(); |
cal.set(Calendar.HOUR_OF_DAY, 0); |
cal.set(Calendar.MINUTE, 0); |
cal.set(Calendar.SECOND, 0); |
cal.set(Calendar.MILLISECOND, 0); |
|
Date now = cal.getTime(); |
|
if(lastUnregister == null) { |
return (start == null || !start.before(now)); |
} |
else { |
return !lastUnregister.before(now); |
} |
} |
|
public int getParticipantCount() |
{ |
return participants.size(); |
} |
|
public int getPersonCount() |
{ |
int count = 0; |
|
for(Iterator i = participants.iterator(); i.hasNext(); ) { |
Participant p = (Participant)i.next(); |
if(p.getPersons() != null) |
count += p.getPersons().intValue(); |
} |
|
return count; |
} |
|
/** |
* @return Collection(Participant) |
* |
* @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true" |
* @hibernate.collection-key column="event" |
* @hibernate.collection-one-to-many class="ak.kickup.core.model.Participant" |
*/ |
protected Collection getParticipants() |
{ |
return participants; |
} |
|
public Collection getParticipantCollection() |
{ |
return Collections.unmodifiableCollection(participants); |
} |
|
/** |
* @param destinations Collection(Participant) |
*/ |
protected void setParticipants(Collection participants) |
{ |
this.participants = participants; |
} |
} |