View Javadoc

1   /*
2    * Trip Tracker, a real-time position tracking system for the Internet.
3    * Copyright (C) 2006  Team Trip Tracker
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or (at your
8    * option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   * General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License along
16   * with this program; if not, write to the Free Software Foundation, Inc.,
17   * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18   */
19  
20  package triptracker.server.persistence;
21  
22  import java.util.List;
23  
24  import triptracker.core.Coordinate;
25  import triptracker.core.Route;
26  import triptracker.core.User;
27  
28  /***
29   * Interface for the data persistency layer.
30   */
31  public interface Persistence {
32  	
33  	/***	
34  	 * Returns userId of given username.
35  	 * 
36  	 * @return userId of given username
37  	 */
38  	public int getUserId(String username);
39  	
40  	/***
41  	 * Authenticate user by checking the username and password.
42  	 * 
43  	 * @param username
44  	 * @param password
45  	 * @return non-negative user ID on success or -1 on failure 
46  	 */
47  	public int authUser(String username, String password);
48  
49  	/***
50  	 * Stores coordinates from the GPS in the database.
51  	 * 
52  	 * @param routeID route identification of the coordinate
53  	 * @param coord coordinate to store
54  	 */
55  	public void storeCoordinate(int routeID, Coordinate coord);
56  
57  	
58  	/***
59  	 * Stores buffered coordinates from the GPS in the database.
60  	 * 
61  	 * @param routeID route identification of the coordinate
62  	 * @param coords List of coordinates to store
63  	 */
64  	public void storeCoordinate(int routeID, List<Coordinate> coords);
65  	
66  	/***
67  	 * Generates a new route to the user with description.
68  	 * 
69  	 * @param userID user ID of the route owner
70  	 * @param description text describing the route
71  	 * @param visibility true for public, false for private
72  	 * @return non-negative route ID on success or -1 on failure 
73  	 */
74  	public Route makeRoute(int userID, String description, boolean visibility);
75  	
76  	/***
77  	 * Returns routes from specific user.
78  	 * 
79  	 * @param username name of user to get routes from
80  	 * @return list of routes for user with name <code>username</code>
81  	 */
82  	public List<Route> getRoutes(String username);
83  	
84  	/***
85  	 * Returns spesific route with routeId
86  	 * @param routeId
87  	 * @return Route with given ID
88  	 */
89  	public Route getRoute(int routeId);
90  	
91  	/***
92  	 * Returns the coordinates of a route for a specific user and route.
93  	 * 
94  	 * @param routeID
95  	 * @return list of coordinates from route <code>routeID</code>
96  	 */
97  	public List<Coordinate> getCoordinates(int routeID);
98  
99  	/***
100 	 * Returns list of users to get routes from
101 	 * 
102 	 * @return list of users
103 	 */
104 	public List<User> getUserList();
105 	
106 	/***
107 	 * Returns user asked for
108 	 * @param userId = ID of user to get
109 	 * @return User with given ID
110 	 */
111 	public User getUser(int userId);
112 	
113 	/***
114 	 * Lock the route for further logging or unlock it to continue logging.
115 	 *
116 	 * @param routeID route to lock/unlock
117 	 * @param lock true to lock, false to unlock
118 	 */
119 	public void lockRoute(int routeID, boolean lock);
120 	
121 	/***
122 	 * Changes the visibility of a route. By changing visibility of a route you
123 	 * can make sure that it can only be seen by its owner or by all clients.
124 	 * 
125 	 * @param routeID route to change visibility
126 	 * @param visible true to show route to all clients, false to show only to
127 	 * 		owner
128 	 */
129 	public void setVisible(int routeID, boolean visible);
130 	
131 }