public class BasicSQLStatementFactory extends java.lang.Object implements SQLStatementFactory
Constructor and Description |
---|
BasicSQLStatementFactory() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getItemColumn()
Get the name of the item ID column in the rating table.
|
java.lang.String |
getRatingColumn()
Get the name of the rating column in the rating table.
|
java.lang.String |
getTableName()
Get the name of the rating table.
|
java.lang.String |
getTimestampColumn()
Get the name of the timestamp column in the rating table (or
null if there is no timestamp column). |
java.lang.String |
getUserColumn()
Get the name of the user ID column in the rating table.
|
java.lang.String |
prepareEvents(SortOrder order)
Prepare a statement to satisfy
EventDAO.streamEvents(Class, SortOrder) . |
java.lang.String |
prepareItemEvents()
Prepare a statement to satisfy
ItemEventDAO.getEventsForItem(long) . |
java.lang.String |
prepareItems()
Prepare a statement to satisfy
ItemDAO.getItemIds() . |
java.lang.String |
prepareItemUsers()
Prepare a statement to satisfy
ItemEventDAO.getUsersForItem(long) . |
java.lang.String |
prepareUserEvents()
Prepare a statement to satisfy
UserEventDAO.getEventsForUser(long) . |
java.lang.String |
prepareUsers()
Prepare a statement to satisfy
UserDAO.getUserIds() . |
protected void |
rqAddOrder(java.lang.StringBuilder query,
SortOrder order)
Add an ORDER BY clause to a query.
|
protected void |
rqAddSelectFrom(java.lang.StringBuilder query)
Add the SELECT and FROM clauses to the query.
|
protected void |
rqFinish(java.lang.StringBuilder query)
Finish a query (append a semicolon).
|
void |
setItemColumn(java.lang.String col)
Set the name of the item ID column in the rating table.
|
void |
setRatingColumn(java.lang.String col)
Set the name of the rating column in the rating table.
|
void |
setTableName(java.lang.String name)
Set the name of the rating table.
|
void |
setTimestampColumn(java.lang.String col)
Set the name of the timestamp column in the rating table.
|
void |
setUserColumn(java.lang.String col)
Set the name of the user ID column in the rating table.
|
public java.lang.String getTableName()
public void setTableName(@Nonnull java.lang.String name)
name
- The name of the rating table.public java.lang.String getUserColumn()
public void setUserColumn(@Nonnull java.lang.String col)
col
- The name of the user column.public java.lang.String getItemColumn()
public void setItemColumn(@Nonnull java.lang.String col)
col
- The name of the item column.public java.lang.String getRatingColumn()
public void setRatingColumn(@Nonnull java.lang.String col)
col
- The name of the rating column.public java.lang.String getTimestampColumn()
null
if there is no timestamp column).public void setTimestampColumn(@Nullable java.lang.String col)
null
if there is no timestamp column.col
- The name of the timestamp column, or null
.public java.lang.String prepareUsers()
SQLStatementFactory
UserDAO.getUserIds()
.
Querying the statement should return one column per row containing the
numeric user ID.prepareUsers
in interface SQLStatementFactory
public java.lang.String prepareItems()
SQLStatementFactory
ItemDAO.getItemIds()
.
Querying the statement should return one column per row containing the
numeric item ID.prepareItems
in interface SQLStatementFactory
protected void rqAddSelectFrom(java.lang.StringBuilder query)
query
- The query accumulator.protected void rqAddOrder(java.lang.StringBuilder query, SortOrder order)
query
- The query accumulatororder
- The sort order.protected void rqFinish(java.lang.StringBuilder query)
query
- The query accumulatorpublic java.lang.String prepareEvents(SortOrder order)
SQLStatementFactory
EventDAO.streamEvents(Class, SortOrder)
. Each row should contain
three or four columns: the user ID, the item ID, the rating,
and (optionally) the timestamp. The timestamp column is allowed to
contain NULL values or to be omitted entirely. User, item, and rating
columns must be non-null.prepareEvents
in interface SQLStatementFactory
order
- The sort orderpublic java.lang.String prepareUserEvents()
SQLStatementFactory
UserEventDAO.getEventsForUser(long)
. The returned rows should be
as in SQLStatementFactory.prepareEvents(SortOrder)
, and the prepared
statement should take a single parameter for the user ID.prepareUserEvents
in interface SQLStatementFactory
public java.lang.String prepareItemEvents()
SQLStatementFactory
ItemEventDAO.getEventsForItem(long)
.
The returned rows should be as in SQLStatementFactory.prepareEvents(SortOrder)
, and the prepared
statement should take a single parameter for the item ID.prepareItemEvents
in interface SQLStatementFactory
public java.lang.String prepareItemUsers()
SQLStatementFactory
ItemEventDAO.getUsersForItem(long)
.
The returned rows should each contain a user ID as their only column, and the statement
should take a single parameter for the item ID.prepareItemUsers
in interface SQLStatementFactory