com.planetj.taste.impl.model.jdbc
Class GenericJDBCDataModel

java.lang.Object
  extended by com.planetj.taste.impl.model.jdbc.AbstractJDBCDataModel
      extended by com.planetj.taste.impl.model.jdbc.GenericJDBCDataModel
All Implemented Interfaces:
Refreshable, DataModel, JDBCDataModel

public class GenericJDBCDataModel
extends AbstractJDBCDataModel

A generic DataModel designed for use with other JDBC data sources; one just specifies all necessary SQL queries to the constructor here. Optionally, the queries can be specified from a Properties object, File, or InputStream. This class is most appropriate when other existing implementations of AbstractJDBCDataModel are not suitable. If you are using this class to support a major database, consider contributing a specialized implementation of AbstractJDBCDataModel to the project for this database.

Author:
Sean Owen

Field Summary
static java.lang.String DATA_SOURCE_KEY
           
static java.lang.String GET_ITEM_SQL_KEY
           
static java.lang.String GET_ITEMS_SQL_KEY
           
static java.lang.String GET_NUM_ITEMS_SQL_KEY
           
static java.lang.String GET_NUM_USERS_SQL_KEY
           
static java.lang.String GET_PREFS_FOR_ITEM_SQL_KEY
           
static java.lang.String GET_USER_SQL_KEY
           
static java.lang.String GET_USERS_PREFERRING_ITEM_SQL_KEY
           
static java.lang.String GET_USERS_SQL_KEY
           
static java.lang.String REMOVE_PREFERENCE_SQL_KEY
           
static java.lang.String SET_PREFERENCE_SQL_KEY
           
 
Fields inherited from class com.planetj.taste.impl.model.jdbc.AbstractJDBCDataModel
DEFAULT_DATASOURCE_NAME, DEFAULT_ITEM_ID_COLUMN, DEFAULT_PREFERENCE_COLUMN, DEFAULT_PREFERENCE_TABLE, DEFAULT_USER_ID_COLUMN
 
Constructor Summary
GenericJDBCDataModel(java.io.File propertiesFile)
          See GenericJDBCDataModel(java.util.Properties).
GenericJDBCDataModel(java.util.Properties props)
          Specifies all SQL queries in a Properties object.
GenericJDBCDataModel(java.lang.String resourcePath)
          See GenericJDBCDataModel(Properties).
 
Method Summary
 
Methods inherited from class com.planetj.taste.impl.model.jdbc.AbstractJDBCDataModel
buildItem, buildPreference, buildUser, getDataSource, getItem, getItem, getItems, getNumItems, getNumUsers, getPreferencesForItem, getPreferencesForItemAsArray, getUser, getUsers, lookupDataSource, refresh, removePreference, setPreference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_SOURCE_KEY

public static final java.lang.String DATA_SOURCE_KEY
See Also:
Constant Field Values

GET_USER_SQL_KEY

public static final java.lang.String GET_USER_SQL_KEY
See Also:
Constant Field Values

GET_NUM_USERS_SQL_KEY

public static final java.lang.String GET_NUM_USERS_SQL_KEY
See Also:
Constant Field Values

GET_NUM_ITEMS_SQL_KEY

public static final java.lang.String GET_NUM_ITEMS_SQL_KEY
See Also:
Constant Field Values

SET_PREFERENCE_SQL_KEY

public static final java.lang.String SET_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

REMOVE_PREFERENCE_SQL_KEY

public static final java.lang.String REMOVE_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

GET_USERS_SQL_KEY

public static final java.lang.String GET_USERS_SQL_KEY
See Also:
Constant Field Values

GET_ITEMS_SQL_KEY

public static final java.lang.String GET_ITEMS_SQL_KEY
See Also:
Constant Field Values

GET_ITEM_SQL_KEY

public static final java.lang.String GET_ITEM_SQL_KEY
See Also:
Constant Field Values

GET_PREFS_FOR_ITEM_SQL_KEY

public static final java.lang.String GET_PREFS_FOR_ITEM_SQL_KEY
See Also:
Constant Field Values

GET_USERS_PREFERRING_ITEM_SQL_KEY

public static final java.lang.String GET_USERS_PREFERRING_ITEM_SQL_KEY
Since:
1.3.2
See Also:
Constant Field Values
Constructor Detail

GenericJDBCDataModel

public GenericJDBCDataModel(java.util.Properties props)
                     throws TasteException

Specifies all SQL queries in a Properties object. See the *_KEY constants in this class (e.g. GET_USER_SQL_KEY) for a list of all keys which must map to a value in this object.

Parameters:
props - Properties object containing values
Throws:
TasteException - if anything goes wrong during initialization

GenericJDBCDataModel

public GenericJDBCDataModel(java.io.File propertiesFile)
                     throws TasteException

See GenericJDBCDataModel(java.util.Properties). This constructor reads values from a file instead, as if with Properties.load(InputStream). So, the file should be in standard Java properties file format -- containing key=value pairs, one per line.

Parameters:
propertiesFile - properties file
Throws:
TasteException - if anything goes wrong during initialization

GenericJDBCDataModel

public GenericJDBCDataModel(java.lang.String resourcePath)
                     throws TasteException

See GenericJDBCDataModel(Properties). This constructor reads values from a resource available in the classpath, as if with Class.getResourceAsStream(String) and Properties.load(InputStream). This is useful if your configuration file is, for example, packaged in a JAR file that is in the classpath.

Parameters:
resourcePath - path to resource in classpath (e.g. "/com/foo/TasteSQLQueries.properties")
Throws:
TasteException - if anything goes wrong during initialization