triptracker.server.persistence
Class PersistenceAdapter

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

public abstract class PersistenceAdapter
extends Object
implements Persistence

Works as an adapter for Persistence classes with built-in logging and all classes throwing an UnsupportedOperationException if not overridden.


Constructor Summary
PersistenceAdapter()
           
 
Method Summary
 int authUser(String username, String password)
          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.
protected  String getLogFile()
          Returns the file where log messages are written.
 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 asked for
 int getUserId()
           
 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.
protected  void log(String message)
           
 Route makeRoute(int userID, String description, boolean publicRoute)
          Generates a new route to the user with description.
protected  void setLogFile(String file)
          Set the filename where log messages should be written.
 void setUserId(int userId)
           
 void setVisible(int routeID, boolean visible)
          Changes the visibility of a route.
 void storeCoordinate(int routeID, Coordinate coord)
          Stores coordinates from the GPS in the database.
 void storeCoordinate(int routeID, List<Coordinate> coord)
          Stores buffered coordinates from the GPS in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceAdapter

public PersistenceAdapter()
Method Detail

setLogFile

protected void setLogFile(String file)
Set the filename where log messages should be written.

Parameters:
file -

getLogFile

protected String getLogFile()
Returns the file where log messages are written.

Returns:
filename of output log messages

getUserId

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

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

authUser

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

Specified by:
authUser in interface Persistence
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
Parameters:
routeID - route identification of the coordinate
coord - coordinate to store

storeCoordinate

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

Specified by:
storeCoordinate in interface Persistence
Parameters:
routeID - route identification of the coordinate
coord - List of coordinates to store

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
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
Parameters:
username - name of user to get routes from
Returns:
list of routes for user with name username

getRoute

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

Specified by:
getRoute in interface Persistence
Returns:
Route with given ID

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
Returns:
list of coordinates from route routeID

getUserList

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

Specified by:
getUserList in interface Persistence
Returns:
list of users

getUser

public User getUser(int userId)
Returns user asked for

Specified by:
getUser in interface Persistence
Parameters:
userId - = ID of user to get
Returns:
User with given ID

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
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
Parameters:
routeID - route to lock/unlock
lock - true to lock, false to unlock

setUserId

public void setUserId(int userId)

getUserId

public int getUserId()

log

protected void log(String message)


Copyright © 2006 Team Trip Tracker. All Rights Reserved.