geekblog 0.0.1-dev

geekblog
Class JDBCDataManager

java.lang.Object
  |
  +--geekblog.JDBCDataManager
All Implemented Interfaces:
DataManager
Direct Known Subclasses:
HSQLDataManager

public class JDBCDataManager
extends java.lang.Object
implements DataManager

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

conn

protected java.sql.Connection conn

statements

protected java.util.Map statements
Constructor Detail

JDBCDataManager

public JDBCDataManager()
Constructor placeholder; all real work done in init()

Method Detail

init

public void init(javax.servlet.ServletContext context)
Initializer.

Specified by:
init in interface DataManager

destroy

public void destroy(javax.servlet.ServletContext context)
Shut everything down.

Specified by:
destroy in interface DataManager

getConnection

public java.sql.Connection getConnection()
Return the JDBC Connection used by this DataManager. Intended solely for use by component-internal routines, like that of util.jsp.


getEntry

public BlogEntry getEntry(long entryID)
Retrieve an entry by ID.

Specified by:
getEntry in interface DataManager

getAllEntries

public java.util.Collection getAllEntries()
Retrieve every single last one.

Specified by:
getAllEntries in interface DataManager

getLastNEntries

public java.util.Collection getLastNEntries(int n)
Retrieve the last "n" entries.

Specified by:
getLastNEntries in interface DataManager

getEntriesForDate

public java.util.Collection getEntriesForDate(java.util.Date date)
Retrieve a list of entries for a given date.

Specified by:
getEntriesForDate in interface DataManager
Parameters:
date - Day/month/year tuple to find entries for. Ignores hour, minutes, seconds.

getEntriesForMonth

public java.util.Collection getEntriesForMonth(java.util.Date date)
Retrieve a list of entries for a given month/year.

Specified by:
getEntriesForMonth in interface DataManager
Parameters:
date - Month/year tuple to find entries for. Ignores day, hour, minutes, seconds.

getEntryCountForDate

public int getEntryCountForDate(java.util.Date date)
Retrieve a count of the entries for a given date.

Specified by:
getEntryCountForDate in interface DataManager
Parameters:
date - Day/month/year to find count of entries for. Ignores hour, minutes, seconds.

getEntryCountForMonth

public int getEntryCountForMonth(java.util.Date date)
Retrieve a count of the entries for a given month.

Specified by:
getEntryCountForMonth in interface DataManager
Parameters:
date - Month and year to find count of entries for. Ignores day, hour, minutes, seconds.

markAsArticle

public void markAsArticle(BlogEntry entry)
Mark an entry as an article.

Specified by:
markAsArticle in interface DataManager

getArticleEntries

public java.util.Collection getArticleEntries()
Retrieve a list of all the entries marked as articles.

Specified by:
getArticleEntries in interface DataManager

findEntries

public java.util.Collection findEntries(java.lang.String text)
Find all entries containing some text expression

Specified by:
findEntries in interface DataManager

postEntry

public void postEntry(BlogEntry entry)
Post an entry (either new or edited).

Specified by:
postEntry in interface DataManager
Parameters:
entry - The BlogEntry to mark as an article.

removeEntry

public void removeEntry(long entryID)
Remove an entry. Also removes all comments and articles associated with that entry.

Specified by:
removeEntry in interface DataManager
Parameters:
entryID - The ID of the entry to remove.

getCommentCountForEntry

public int getCommentCountForEntry(long entryID)
Retrieve the list of comments for a given entry.

Specified by:
getCommentCountForEntry in interface DataManager

getCommentsForEntry

public java.util.Collection getCommentsForEntry(long entryID)
Retrieve the list of comments for a given entry.

Specified by:
getCommentsForEntry in interface DataManager

postComment

public void postComment(long entryID,
                        BlogComment comment)
Post a comment to an entry.

Specified by:
postComment in interface DataManager

geekblog 0.0.1-dev

Copyright © 2003 Ted Neward. All Rights Reserved.