com.planetj.taste.model
Interface DataModel

All Superinterfaces:
Refreshable
All Known Subinterfaces:
JDBCDataModel
All Known Implementing Classes:
AbstractJDBCDataModel, FileDataModel, GenericDataModel, GenericJDBCDataModel, MySQLJDBCDataModel, NetflixDataModel

public interface DataModel
extends Refreshable

Implementations represent a repository of information about Users and their associated Preferences for Items.

Author:
Sean Owen

Method Summary
 Item getItem(java.lang.Object id)
           
 java.lang.Iterable<? extends Item> getItems()
           
 int getNumItems()
           
 int getNumUsers()
           
 java.lang.Iterable<? extends Preference> getPreferencesForItem(java.lang.Object itemID)
           
 Preference[] getPreferencesForItemAsArray(java.lang.Object itemID)
           
 User getUser(java.lang.Object id)
           
 java.lang.Iterable<? extends User> getUsers()
           
 void removePreference(java.lang.Object userID, java.lang.Object itemID)
          Removes a particular preference for a user.
 void setPreference(java.lang.Object userID, java.lang.Object itemID, double value)
          Sets a particular preference (item plus rating) for a user.
 
Methods inherited from interface com.planetj.taste.common.Refreshable
refresh
 

Method Detail

getUsers

@NotNull
java.lang.Iterable<? extends User> getUsers()
                                            throws TasteException
Returns:
a List of all Users in the model, ordered by User
Throws:
TasteException - if an error occurs while accessing the data

getUser

@NotNull
User getUser(java.lang.Object id)
             throws TasteException
Parameters:
id - user ID
Returns:
User who has that ID
Throws:
TasteException - if an error occurs while accessing the data
java.util.NoSuchElementException - if there is no such User

getItems

@NotNull
java.lang.Iterable<? extends Item> getItems()
                                            throws TasteException
Returns:
a List of all Items in the model, order by Item
Throws:
TasteException - if an error occurs while accessing the data

getItem

@NotNull
Item getItem(java.lang.Object id)
             throws TasteException
Parameters:
id - item ID
Returns:
Item that has that ID
Throws:
TasteException - if an error occurs while accessing the data
java.util.NoSuchElementException - if there is no such Item

getPreferencesForItem

@NotNull
java.lang.Iterable<? extends Preference> getPreferencesForItem(java.lang.Object itemID)
                                                               throws TasteException
Parameters:
itemID - item ID
Returns:
all existing Preferences expressed for that item, ordered by User
Throws:
TasteException - if an error occurs while accessing the data

getPreferencesForItemAsArray

@NotNull
Preference[] getPreferencesForItemAsArray(java.lang.Object itemID)
                                          throws TasteException
Parameters:
itemID - item ID
Returns:
all existing Preferences expressed for that item, ordered by User, as an array
Throws:
TasteException - if an error occurs while accessing the data

getNumItems

int getNumItems()
                throws TasteException
Returns:
total number of Items known to the model. This is generally the union of all Items preferred by at least one User but could include more.
Throws:
TasteException - if an error occurs while accessing the data

getNumUsers

int getNumUsers()
                throws TasteException
Returns:
total number of Users known to the model.
Throws:
TasteException - if an error occurs while accessing the data

setPreference

void setPreference(java.lang.Object userID,
                   java.lang.Object itemID,
                   double value)
                   throws TasteException

Sets a particular preference (item plus rating) for a user.

Parameters:
userID - user to set preference for
itemID - item to set preference for
value - preference value
Throws:
TasteException - if an error occurs while accessing the data

removePreference

void removePreference(java.lang.Object userID,
                      java.lang.Object itemID)
                      throws TasteException

Removes a particular preference for a user.

Parameters:
userID - user from which to remove preference
itemID - item to remove preference for
Throws:
TasteException - if an error occurs while accessing the data
Since:
1.3