View Javadoc
1   /******************************************************************************
2    * Database.java - The API into the BuckoFIBS database. 
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.5  2011/01/01 06:11:04  dick
10   * Javadoc.
11   *
12   * Revision 1.4  2010/12/31 05:29:25  dick
13   * Add support for reading and writing GroupOfPlayers.
14   *
15   * Revision 1.3  2010/03/03 13:12:21  inim
16   * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
17   *
18   * Revision 1.2  2010/03/03 12:19:48  inim
19   * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
20   *
21   * Revision 1.1  2010/02/04 05:57:53  inim
22   * Mavenized project folder layout
23   *
24   * Revision 1.5  2010/01/29 23:07:08  dick
25   * Remove aborted RatingGraphConfig, it's a properties object.
26   *
27   * Revision 1.4  2010/01/27 02:09:37  dick
28   * Preliminary RatingGraphConfig work.
29   *
30   * Revision 1.3  2009/03/04 19:01:58  dick
31   * Add getFinishedMatches(pid).
32   *
33   * Revision 1.2  2009/02/21 18:00:01  dick
34   * Add getAllRatingsByDate()
35   *
36   * Revision 1.1  2009/02/20 10:23:04  dick
37   * The API into the BuckoFIBS database.
38   *
39   */
40  
41  /* 
42   * This program is free software: you can redistribute it and/or modify
43   * it under the terms of the GNU General Public License as published by
44   * the Free Software Foundation, either version 3 of the License, or
45   * (at your option) any later version.
46   *
47   * This program is distributed in the hope that it will be useful,
48   * but WITHOUT ANY WARRANTY; without even the implied warranty of
49   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50   * GNU General Public License for more details.
51   *
52   * You should have received a copy of the GNU General Public License
53   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
54   *
55   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
56   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
57   */
58  package com.buckosoft.fibs.BuckoFIBS.db;
59  
60  import java.util.List;
61  
62  import com.buckosoft.fibs.domain.FinishedMatch;
63  import com.buckosoft.fibs.domain.GroupOfPlayers;
64  import com.buckosoft.fibs.domain.Player;
65  
66  /** The API into the BuckoFIBS database.
67   * @author Dick Balaska
68   * @since 2009/02/18
69   * @version $Revision$ <br> $Date$
70   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/db/Database.java">cvs Database.java</a>
71   */
72  public interface Database {
73  
74  	/** Set the active Profile.  We deal with only one active profile at a time.
75  	 * @param activeProfile Which profileId the user logged in as.
76  	 */
77  	void setActiveProfile(int activeProfile);
78  
79  	/** Write this player to the database
80  	 * @param player The player to write.
81  	 */
82  	void	store(Player player);
83  
84  	/** Find this player based on his id
85  	 * @param id The player id to query
86  	 * @return The Player with this id or null if not found
87  	 */
88  	Player	getPlayer(int id);
89  
90  	/** Find this Player based on his name
91  	 * @param name The Player name to query
92  	 * @return The Player with this name or null if not found
93  	 */
94  	Player	getPlayer(String name);
95  	
96  	/** Store this FinishedMatch to the database
97  	 * @param finishedMatch the match we just finished
98  	 */
99  	void store(FinishedMatch finishedMatch);
100 	
101 	/** Return an array of your ratings ordered by date.
102 	 * @param actvieProfile which user are you currently playing as.
103 	 * @return your ratings
104 	 */
105 	double[] getAllRatingsByDate();
106 	
107 	/** Update the opponent with the data that we have.
108 	 * This includes his local id and win/loss record.
109 	 * @param p The Player to update
110 	 */
111 	void updateOpponent(Player p);
112 
113 	/** Get a List of matches that you have played against this player.
114 	 * @param pid The playerid to query.
115 	 * @return The List of FinishedMatches.  An empty List if no matches found.
116 	 */
117 	List<FinishedMatch>	getFinishedMatches(int pid);
118 	
119 	/** Get all of the GroupOfPlayers
120 	 * @return The persistent GroupOfPlayers
121 	 */
122 	List<GroupOfPlayers>	getGroupsOfPlayers();
123 	
124 	/** Store all of the GroupOfPlayers.
125 	 * Note that these objects make use of the {@link GroupOfPlayers}'s dirty flag to save disk accesses.
126 	 * @param groupList The master list
127 	 */
128 	void store(List<GroupOfPlayers> groupList);
129 	
130 }