|
geekblog 0.0.1-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--geekblog.JDBCDataManager
Expects a database looking something like the following:
CREATE TABLE entries (ID long identity, posted datetime, title varchar, text varchar) CREATE TABLE articles (entryID long) CREATE TABLE comments (entryID long, name varchar, email varchar, comment varchar) CREATE TABLE links (linkID long identity, linkText varchar, linkURL varchar)
TODO: put close() calls around any open ResultSets
Field Summary | |
protected java.sql.Connection |
conn
|
protected java.util.Map |
statements
|
Fields inherited from interface geekblog.DataManager |
KEY |
Constructor Summary | |
JDBCDataManager()
Constructor placeholder; all real work done in init() |
Method Summary | |
void |
destroy(javax.servlet.ServletContext context)
Shut everything down. |
java.util.Collection |
findEntries(java.lang.String text)
Find all entries containing some text expression |
java.util.Collection |
getAllEntries()
Retrieve every single last one. |
java.util.Collection |
getArticleEntries()
Retrieve a list of all the entries marked as articles. |
int |
getCommentCountForEntry(long entryID)
Retrieve the list of comments for a given entry. |
java.util.Collection |
getCommentsForEntry(long entryID)
Retrieve the list of comments for a given entry. |
java.sql.Connection |
getConnection()
Return the JDBC Connection used by this DataManager. |
java.util.Collection |
getEntriesForDate(java.util.Date date)
Retrieve a list of entries for a given date. |
java.util.Collection |
getEntriesForMonth(java.util.Date date)
Retrieve a list of entries for a given month/year. |
BlogEntry |
getEntry(long entryID)
Retrieve an entry by ID. |
int |
getEntryCountForDate(java.util.Date date)
Retrieve a count of the entries for a given date. |
int |
getEntryCountForMonth(java.util.Date date)
Retrieve a count of the entries for a given month. |
java.util.Collection |
getLastNEntries(int n)
Retrieve the last "n" entries. |
void |
init(javax.servlet.ServletContext context)
Initializer. |
void |
markAsArticle(BlogEntry entry)
Mark an entry as an article. |
void |
postComment(long entryID,
BlogComment comment)
Post a comment to an entry. |
void |
postEntry(BlogEntry entry)
Post an entry (either new or edited). |
void |
removeEntry(long entryID)
Remove an entry. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.sql.Connection conn
protected java.util.Map statements
Constructor Detail |
public JDBCDataManager()
Method Detail |
public void init(javax.servlet.ServletContext context)
init
in interface DataManager
public void destroy(javax.servlet.ServletContext context)
destroy
in interface DataManager
public java.sql.Connection getConnection()
public BlogEntry getEntry(long entryID)
getEntry
in interface DataManager
public java.util.Collection getAllEntries()
getAllEntries
in interface DataManager
public java.util.Collection getLastNEntries(int n)
getLastNEntries
in interface DataManager
public java.util.Collection getEntriesForDate(java.util.Date date)
getEntriesForDate
in interface DataManager
date
- Day/month/year tuple to find entries for.
Ignores hour, minutes, seconds.public java.util.Collection getEntriesForMonth(java.util.Date date)
getEntriesForMonth
in interface DataManager
date
- Month/year tuple to find entries for.
Ignores day, hour, minutes, seconds.public int getEntryCountForDate(java.util.Date date)
getEntryCountForDate
in interface DataManager
date
- Day/month/year to find count of entries for.
Ignores hour, minutes, seconds.public int getEntryCountForMonth(java.util.Date date)
getEntryCountForMonth
in interface DataManager
date
- Month and year to find count of entries for.
Ignores day, hour, minutes, seconds.public void markAsArticle(BlogEntry entry)
markAsArticle
in interface DataManager
public java.util.Collection getArticleEntries()
getArticleEntries
in interface DataManager
public java.util.Collection findEntries(java.lang.String text)
findEntries
in interface DataManager
public void postEntry(BlogEntry entry)
postEntry
in interface DataManager
entry
- The BlogEntry to mark as an article.public void removeEntry(long entryID)
removeEntry
in interface DataManager
entryID
- The ID of the entry to remove.public int getCommentCountForEntry(long entryID)
getCommentCountForEntry
in interface DataManager
public java.util.Collection getCommentsForEntry(long entryID)
getCommentsForEntry
in interface DataManager
public void postComment(long entryID, BlogComment comment)
postComment
in interface DataManager
|
geekblog 0.0.1-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |