|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmodel.tournament.TournamentDataModel
model.Tournament
public class Tournament
Class Tournament is used to store all the information and entries of a particular tournament. The data structure of the tournament is based on the class model.tournament.TournamentDataModel. Editing and creating a completely new tournament is handled via the TournamentUpdater and TournamentInitializer objects. A Tournament object also controls the reading and writing of the XML data-, log- and export files of the tournament through classes that extend the File class.
Nested Class Summary | |
---|---|
static class |
Tournament.EntryComparator
EntryComparator class is used so that Entry objects can be sorted by different fields of the objects. |
Field Summary | |
---|---|
private java.util.HashMap<ID,Entry> |
confirmed_pre_entries
|
private ID |
discount_id_counter
|
private java.util.HashMap<ID,Entry> |
entries
|
private ID |
entry_id_counter
|
private LogFile |
log_file
|
private java.util.HashMap<ID,Entry> |
pre_entries
|
private ExportFile |
pre_registration_export_file
|
private ExportFile |
registration_export_file
|
static java.lang.String[] |
TOURNAMENT_HEADER_FIELDS
|
private XMLFile |
xml_file
|
Constructor Summary | |
---|---|
private |
Tournament(ID tournament_id)
Private constructor, common for the two public constructors. |
protected |
Tournament(TournamentInitializer initializer)
Constructor creates a new Tournament object from a TournamentInitializer object. |
protected |
Tournament(XMLFile existing_xml_file)
Constructor creates a Tournament object from an existing XML data file |
Method Summary | |
---|---|
protected void |
addEntry(Entry entry)
Method adds a registered entry to the tournament |
protected void |
addPreEntry(Entry... pre_entries_to_add)
Method adds pre-entries to the tournament |
protected void |
closeTournament()
Closes the tournament so that its data cannot be modified. |
protected void |
confirmPreEntry(ID entry_id)
Moves the given pre-entry to the confirmed pre-entries list. |
private java.util.HashMap<ID,Entry> |
createEntryMap(java.util.ArrayList<Entry> entry_list)
|
protected void |
delete()
Deletes a closed tournament. |
protected void |
deleteEntry(ID entry_id)
Deletes a given entry. |
protected void |
editEntry(ID entry_id,
EntryUpdater updater)
Edits the information of the entry. |
protected void |
editTournament(TournamentUpdater updater)
Edits the general information and discounts of the tournament. |
Entry[] |
getConfirmedPreEntries()
|
Entry[] |
getConfirmedPreEntries(Tournament.EntryComparator.SortBy sort_by)
|
Country[] |
getCountryList()
|
java.lang.String |
getDataFilename()
|
Entry[] |
getEntries()
|
Entry[] |
getEntries(Tournament.EntryComparator.SortBy sort_by)
|
Entry |
getEntry(ID entry_id)
Returns a given entry. |
protected EntryInitializer |
getEntryInitializer()
Returns an EntryInitializer object that can be used to create a new entry for this tournament. |
protected EntryUpdater |
getEntryUpdater(ID target_entry_id)
Returns an EntryUpdater object that can be used to modify an entry of this tournament. |
java.lang.String |
getLogFileName()
|
protected ID |
getNextDiscountId()
Used to get the next available discount ID for the tournament and update the counter by one. |
protected ID |
getNextEntryId()
Used to get the next available entry ID for the tournament and update the counter by one. |
protected ID |
getNextEntryId(int increment)
Used to get the next available entry ID for the tournament and update the counter. |
int |
getNumberOfDiscounts(ID discount_id)
Returns the no. |
int |
getNumberOfEntries()
|
int |
getNumberOfPreEntries()
|
Entry[] |
getPreEntries()
|
Entry[] |
getPreEntries(Tournament.EntryComparator.SortBy sort_by)
|
Entry |
getPreEntry(ID entry_id)
Returns a given pre-entry. |
protected EntryInitializer |
getPreEntryInitializer()
Returns an EntryInitializer object that can be used to create a new pre-entry for this tournament. |
protected EntryInitializer[] |
getPreEntryInitializer(int amount)
Returns an array EntryInitializer objects that can be used to create new pre-entries for this tournament. |
protected EntryUpdater |
getPreEntryUpdater(ID target_entry_id)
Returns an EntryUpdater object that can be used to modify a pre-entry of this tournament. |
Rank[] |
getRankList()
|
java.math.BigDecimal |
getTotalFees()
|
java.math.BigDecimal |
getTotalPaid()
|
protected TournamentUpdater |
getTournamentUpdater()
Returns a TournamentUpdater object that can be used to edit information and discounts of this tournament. |
Entry[] |
getUnpaidEntries()
|
Entry[] |
getUnpaidEntries(Tournament.EntryComparator.SortBy sort_by)
|
int |
importPreEntriesFromWiki(java.lang.String pre_entries_from_wiki)
Adds pre-entries from a string in wiki-format. |
protected void |
reopenTournament()
Opens a closed tournament so that its data can be modified. |
private void |
setHeaderData(TournamentInitializer initializer)
Method is used by the constructor that creates a completely new Tournament object to set the tournament information |
void |
setPreregistrationOpen(boolean open)
Opens/closes the tournament preregistration. |
java.lang.String |
toString()
|
java.lang.String |
writeExportFile(boolean from_pre_entries)
Writes a file that can be read by the Go player pairing program McMahon. |
private void |
writeLogMessage(java.lang.String message)
Writes a message with system date and time to the tournament log file. |
Methods inherited from class model.tournament.TournamentDataModel |
---|
addDiscount, getBaseFee, getDate, getDefaultCountry, getDiscounts, getHtml, getId, getName, hasDiscountId, isPreRegistrationOpen, isTournamentOpen, removeDiscount, setBaseFee, setBaseFee, setDate, setDate, setDefaultCountry, setDefaultCountry, setDiscounts, setHtml, setName, setTournamentOpen |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] TOURNAMENT_HEADER_FIELDS
private transient java.util.HashMap<ID,Entry> entries
private transient java.util.HashMap<ID,Entry> pre_entries
private transient java.util.HashMap<ID,Entry> confirmed_pre_entries
private transient XMLFile xml_file
private transient ExportFile registration_export_file
private transient ExportFile pre_registration_export_file
private transient LogFile log_file
private transient ID entry_id_counter
private transient ID discount_id_counter
Constructor Detail |
---|
protected Tournament(XMLFile existing_xml_file) throws GoException
existing_xml_file
-
GoException
- thrown if the XML data file cannot be read or parsed.protected Tournament(TournamentInitializer initializer) throws GoException
initializer
- contains tournament information
GoException
- throw if the initializer cannot be readprivate Tournament(ID tournament_id)
tournament_id
- the ID of the tournament to be createdMethod Detail |
---|
private void setHeaderData(TournamentInitializer initializer) throws GoException
initializer
- contains the tournament information
GoException
- thrown if the initializer cannot be readpublic java.math.BigDecimal getTotalFees()
public java.math.BigDecimal getTotalPaid()
public int getNumberOfDiscounts(ID discount_id)
discount_id
- id of the discount
public int getNumberOfEntries()
public int getNumberOfPreEntries()
public java.lang.String getLogFileName()
protected final void confirmPreEntry(ID entry_id) throws PreEntryNotFoundException, GoIOException
entry_id
- id of the pre-entry to confirm
PreEntryNotFoundException
- thrown if the pre-entry is not found
GoIOException
- thrown if the modification of the XML data file failsprotected void editTournament(TournamentUpdater updater) throws GoException
updater
- a TournamentUpdater object that contains the new tournament information
GoException
- thrown if the updater cannot be read or the XML file modification failspublic final java.lang.String writeExportFile(boolean from_pre_entries) throws GoException
from_pre_entries
- if true the export file is created from the pre-entries, else from the registered entries
GoException
public final java.lang.String getDataFilename()
public Entry getEntry(ID entry_id) throws EntryNotFoundException
entry_id
- id of the entry to return
EntryNotFoundException
- thrown if the entry cannot be foundpublic Entry getPreEntry(ID entry_id) throws PreEntryNotFoundException
entry_id
- id of the entry to return
PreEntryNotFoundException
- thrown if the entry cannot be foundprotected void deleteEntry(ID entry_id) throws EntryNotFoundException, GoIOException
entry_id
- id of the entry to be deleted
EntryNotFoundException
- throw if the entry cannot be found
GoIOException
- thrown if the modification of the XML data file fails.protected ID getNextEntryId() throws GoIOException
GoIOException
- thrown if the XML data file modification failsprotected ID getNextEntryId(int increment) throws GoIOException
increment
- the increment to be made
GoIOException
- thrown if the XML data file modification failsprotected ID getNextDiscountId() throws GoIOException
GoIOException
- thrown if the XML data file modification failsprotected void editEntry(ID entry_id, EntryUpdater updater) throws GoException
entry_id
- id of the entry to be editedupdater
- EntryUpdater object containing the new information
GoException
- thrown if the updater cannot be read or the XML data file modification failsprotected EntryInitializer getEntryInitializer() throws GoException
GoException
- thrown if the necessary XML data file modification failsprotected EntryInitializer getPreEntryInitializer() throws GoException
GoException
- thrown if the necessary XML data file modification failsprotected EntryInitializer[] getPreEntryInitializer(int amount) throws GoException
amount
- no of initializers
GoException
- thrown if the necessary XML data file modification failsprotected EntryUpdater getEntryUpdater(ID target_entry_id) throws GoException
GoException
- thrown if the necessary XML data file modification failsprotected EntryUpdater getPreEntryUpdater(ID target_entry_id) throws GoException
GoException
- thrown if the necessary XML data file modification failsprotected TournamentUpdater getTournamentUpdater() throws GoException
GoException
private java.util.HashMap<ID,Entry> createEntryMap(java.util.ArrayList<Entry> entry_list)
entry_list
- an ArrayList of Entry objects
public Entry[] getUnpaidEntries()
public Entry[] getUnpaidEntries(Tournament.EntryComparator.SortBy sort_by)
sort_by
- an enum that defines how the return array is sorted
public Entry[] getEntries()
public Entry[] getEntries(Tournament.EntryComparator.SortBy sort_by)
sort_by
- an enum that defines how the return array is sorted
public Entry[] getPreEntries()
public Entry[] getPreEntries(Tournament.EntryComparator.SortBy sort_by)
sort_by
- an enum that defines how the return array is sorted
public Entry[] getConfirmedPreEntries()
public Entry[] getConfirmedPreEntries(Tournament.EntryComparator.SortBy sort_by)
sort_by
- an enum that defines how the return array is sorted
protected void addEntry(Entry entry) throws GoIOException, TournamentClosedException, DuplicatePlayerException
entry
- the Entry object to be added
GoIOException
- thrown if the XML date file cannot be modified for some reason
TournamentClosedException
- thrown if the tournament is closed
DuplicatePlayerException
- thrown if there already is a registered entry with the same first and last name.protected void addPreEntry(Entry... pre_entries_to_add) throws GoException
pre_entries_to_add
- the Entry objects to be added
GoIOException
- thrown if the XML date file cannot be modified for some reason
TournamentClosedException
- thrown if the tournament is closed
GoException
- thrown if preregistration is not openpublic int importPreEntriesFromWiki(java.lang.String pre_entries_from_wiki) throws GoException
pre_entries_from_wiki
- wiki string
GoIOException
TournamentClosedException
GoException
public Rank[] getRankList()
public Country[] getCountryList()
private void writeLogMessage(java.lang.String message)
message
- public void setPreregistrationOpen(boolean open)
setPreregistrationOpen
in class TournamentDataModel
protected void closeTournament() throws GoIOException
GoIOException
- thrown if the XML data file cannot be modifiedprotected void reopenTournament() throws GoIOException
GoIOException
- thrown if the XML data file cannot be modifiedprotected void delete() throws TournamentOpenException
TournamentOpenException
- thrown if the tournament is not closed when trying to delete itpublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |