triptracker.server.persistence
Class MySqlDB

java.lang.Object
  extended by triptracker.server.persistence.PersistenceAdapter
      extended by triptracker.server.persistence.MySqlDB
All Implemented Interfaces:
Persistence

public class MySqlDB
extends PersistenceAdapter

Implementation of the persistence layer in the form of a MySQL database.


Field Summary
static String database
           
static String server
           
 
Constructor Summary
MySqlDB()
           
 
Method Summary
 int authUser(String user, String pass)
          Authenticate user by checking the username and password.
 List<Coordinate> getCoordinates(int routeID)
          Returns the coordinates of a route for a specific user and route.
 Route getRoute(int routeId)
          Returns spesific route with routeId
 List<Route> getRoutes(String username)
          Returns routes from specific user.
 User getUser(int userId)
          Returns user data for the specified user.
 int getUserId(String username)
          Returns userId of given username.
 List<User> getUserList()
          Returns list of users to get routes from
 void lockRoute(int routeID, boolean lock)
          Lock the route for further logging or unlock it to continue logging.
 Route makeRoute(int userId, String description, boolean publicRoute)
          Generates a new route to the user with description.
 void setVisible(int routeID, boolean visible)
          Changes the visibility of a route. By changing visibility of a route you can make sure that it can only be seen by its owner or by all clients.
 void storeCoordinate(int routeID, Coordinate coord)
          Stores coordinates from the GPS in the database.
 void storeCoordinate(int routeID, List<Coordinate> coords)
          Stores buffered coordinates from the GPS in the database.
 
Methods inherited from class triptracker.server.persistence.PersistenceAdapter
getLogFile, getUserId, log, setLogFile, setUserId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

public static final String server

database

public static final String database
Constructor Detail

MySqlDB

public MySqlDB()
Method Detail

getUserId

public int getUserId(String username)
Returns userId of given username.

Specified by:
getUserId in interface Persistence
Overrides:
getUserId in class PersistenceAdapter
Returns:
userId of given username

authUser

public int authUser(String user,
                    String pass)
Authenticate user by checking the username and password.

Specified by:
authUser in interface Persistence
Overrides:
authUser in class PersistenceAdapter
Returns:
non-negative user ID on success or -1 on failure

storeCoordinate

public void storeCoordinate(int routeID,
                            Coordinate coord)
Stores coordinates from the GPS in the database.

Specified by:
storeCoordinate in interface Persistence
Overrides:
storeCoordinate in class PersistenceAdapter
Parameters:
routeID - route identification of the coordinate
coord - coordinate to store

storeCoordinate

public void storeCoordinate(int routeID,
                            List<Coordinate> coords)
Stores buffered coordinates from the GPS in the database.

Specified by:
storeCoordinate in interface Persistence
Overrides:
storeCoordinate in class PersistenceAdapter
Parameters:
routeID - route identification of the coordinate
coords - List of coordinates to store

getUserList

public List<User> getUserList()
Returns list of users to get routes from

Specified by:
getUserList in interface Persistence
Overrides:
getUserList in class PersistenceAdapter
Returns:
list of users

getUser

public User getUser(int userId)
Returns user data for the specified user.

Specified by:
getUser in interface Persistence
Overrides:
getUser in class PersistenceAdapter
Parameters:
userId - ID of user
Returns:
User with given ID

makeRoute

public Route makeRoute(int userId,
                       String description,
                       boolean publicRoute)
Generates a new route to the user with description.

Specified by:
makeRoute in interface Persistence
Overrides:
makeRoute in class PersistenceAdapter
Parameters:
userId - user ID of the route owner
description - text describing the route
publicRoute - true for public, false for private
Returns:
non-negative route ID on success or -1 on failure

getRoutes

public List<Route> getRoutes(String username)
Returns routes from specific user.

Specified by:
getRoutes in interface Persistence
Overrides:
getRoutes in class PersistenceAdapter
Parameters:
username - name of user to get routes from
Returns:
list of routes for user with name username

getCoordinates

public List<Coordinate> getCoordinates(int routeID)
Returns the coordinates of a route for a specific user and route.

Specified by:
getCoordinates in interface Persistence
Overrides:
getCoordinates in class PersistenceAdapter
Returns:
list of coordinates from route routeID

setVisible

public void setVisible(int routeID,
                       boolean visible)
Changes the visibility of a route. By changing visibility of a route you can make sure that it can only be seen by its owner or by all clients.

Specified by:
setVisible in interface Persistence
Overrides:
setVisible in class PersistenceAdapter
Parameters:
routeID - route to change visibility
visible - true to show route to all clients, false to show only to owner

lockRoute

public void lockRoute(int routeID,
                      boolean lock)
Lock the route for further logging or unlock it to continue logging.

Specified by:
lockRoute in interface Persistence
Overrides:
lockRoute in class PersistenceAdapter
Parameters:
routeID - route to lock/unlock
lock - true to lock, false to unlock

getRoute

public Route getRoute(int routeId)
Returns spesific route with routeId

Specified by:
getRoute in interface Persistence
Overrides:
getRoute in class PersistenceAdapter
Parameters:
routeId -
Returns:
Route with given Id


Copyright © 2006 Team Trip Tracker. All Rights Reserved.