|
WPI GDC CMS 0.0.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.wpi.gdc.cms.db.DBEngine
An abstract class that contains the basic interface that allows the CMS to load and save objects into the database.
The DBEngine interface is not dependent on any given implementation and should work on any given data storage method, given enough work.
Field Summary | |
static int |
INCLUDE_AFTER_TODAY
Constant for including items after the current date. |
static int |
INCLUDE_BEFORE_TODAY
Constant for including items before the current date. |
static int |
ORDER_ASCENDING
Constant for ordering in ascending order. |
static int |
ORDER_DESCENDING
Constant for ordering in descending order. |
protected Session |
session
The session object for this engine. |
Constructor Summary | |
DBEngine()
|
Method Summary | |
abstract void |
connect(java.lang.String dbURL,
java.util.Properties properties)
Connects to the database using the given db URL from the configuration options. |
abstract boolean |
isConnected()
Determines if the database is connected (ie, a call to connect succeeded). |
abstract Event |
loadEvent(int id)
Events are stored in a database via a numeric ID, this method should load the actual data based on the ID. |
abstract Event |
loadEvent(java.lang.String name)
Each events to be accessed through the website must have a unique name identifier (which will correspond with that event's URL). |
abstract int |
loadEventCount()
Counts the number of event groups available. |
abstract DBIterator |
loadEvents()
Gets an DBIterator over the event groups in the database. |
DBIterator |
loadEvents(int field,
int order)
Gets a DBIterator over the event groups in the database, ordered by the given order. |
abstract DBIterator |
loadEvents(int field,
int order,
int limit)
Gets a DBIterator over the event groups in the database, ordered by the given order, and limited to the given amount. |
abstract DBIterator |
loadEventsFromDate(int range,
int order,
int limit)
Gets a DBIterator over the event groups in the database, either before or after the current day (determined by range ), ordered
by the given order, and limited to the given amount. |
abstract Icon[] |
loadIcons()
Gets all the Icons in a database. |
abstract DBIterator |
loadNewsStories()
Gets an DBIterator over the news stories in the database. |
DBIterator |
loadNewsStories(int field,
int order)
Gets a DBIterator over the news stories in the database, ordered by the given order. |
abstract DBIterator |
loadNewsStories(int field,
int order,
int limit)
Gets a DBIterator over the news stories in the database, ordered by the given order, and limited to the given amount. |
abstract NewsStory |
loadNewsStory(int id)
News stories are stored in a database via a numeric ID, this method should load the actual data based on the ID. |
abstract int |
loadNewsStoryCount()
Counts the number of news stories available. |
abstract Topic[] |
loadTopics()
Gets all the Topics in a database. |
abstract User |
loadUser(int id)
Users are stored in a database via a numeric ID, this method should load the actual data based on the ID. |
abstract User |
loadUser(java.lang.String name)
Load a User from the DB based on the username. |
abstract void |
saveNewsStory(NewsStory newsStory)
Save a NewsStory into the database. |
void |
setSession(Session session)
Sets the Session object for this DBEngine. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ORDER_ASCENDING
For example, the set {4, 2, 3, 1} would be ordered as {1, 2, 3, 4}.
public static final int ORDER_DESCENDING
For example, the set {4, 2, 3, 1} would be ordered as {4, 3, 2, 1}.
public static final int INCLUDE_BEFORE_TODAY
public static final int INCLUDE_AFTER_TODAY
protected Session session
Constructor Detail |
public DBEngine()
Method Detail |
public void setSession(Session session)
session
- the Session objectIllegalStateException
- if the session has already been setpublic abstract void connect(java.lang.String dbURL, java.util.Properties properties) throws DatabaseException
DatabaseException
- if there is an error accessing data
from the databasepublic abstract boolean isConnected()
public abstract User loadUser(int id) throws DatabaseException
id
- the ID for the User being loadedpublic abstract User loadUser(java.lang.String name) throws DatabaseException
name
- the username of the User being loadedDatabaseException
- if there is an error accessing data
from the databasepublic abstract NewsStory loadNewsStory(int id) throws DatabaseException
id
- the ID for the news story being loadedDatabaseException
- if there is an error accessing data
from the databasepublic abstract DBIterator loadNewsStories() throws DatabaseException
The remove() method in the DBIterator may or may not function depending on the implementation.
DatabaseException
- if there is an error accessing data
from the databasepublic DBIterator loadNewsStories(int field, int order) throws DatabaseException
field
- The field to sort by, one of:
NewsStory.FIELD_ID
,
NewsStory.FIELD_AUTHOR
,
NewsStory.FIELD_TOPIC
,
NewsStory.FIELD_POSTED
,
NewsStory.FIELD_HEADLINE
,
NewsStory.FIELD_ABSTRACT
, or
NewsStory.FIELD_BODY
.order
- The order to sort the new stories, either
ORDER_ASCENDING
or ORDER_DESCENDING
.java.lang.IllegalArgumentException
- if field is not one of
NewsStory.FIELD_ID
,
NewsStory.FIELD_AUTHOR
,
NewsStory.FIELD_TOPIC
,
NewsStory.FIELD_POSTED
,
NewsStory.FIELD_HEADLINE
,
NewsStory.FIELD_ABSTRACT
, or
NewsStory.FIELD_BODY
; or if
order is not either ORDER_ASCENDING
or ORDER_DESCENDING
.DatabaseException
- if there is an error accessing data
from the databasepublic abstract DBIterator loadNewsStories(int field, int order, int limit) throws DatabaseException
If the given limit is more than the number of stories in the database, only the number available will be returned and no other error will occur.
field
- The field to sort by, one of:
NewsStory.FIELD_ID
,
NewsStory.FIELD_AUTHOR
,
NewsStory.FIELD_TOPIC
,
NewsStory.FIELD_POSTED
,
NewsStory.FIELD_HEADLINE
,
NewsStory.FIELD_ABSTRACT
, or
NewsStory.FIELD_BODY
.order
- The order to sort the new stories, either
ORDER_ASCENDING
or ORDER_DESCENDING
.limit
- The total number of stories to retrieve, or a negative
number for all of them.java.lang.IllegalArgumentException
- if field is not one of
NewsStory.FIELD_ID
,
NewsStory.FIELD_AUTHOR
,
NewsStory.FIELD_TOPIC
,
NewsStory.FIELD_POSTED
,
NewsStory.FIELD_HEADLINE
,
NewsStory.FIELD_ABSTRACT
, or
NewsStory.FIELD_BODY
; or if
order is not either ORDER_ASCENDING
or ORDER_DESCENDING
.DatabaseException
- if there is an error accessing data
from the databasepublic abstract int loadNewsStoryCount() throws DatabaseException
DatabaseException
- if there is an error accessing data
from the databasepublic abstract void saveNewsStory(NewsStory newsStory) throws DatabaseException
NewsStory
into the database. Should the
numeric ID be less than 0, the DBEngine should pick one before
saving the story into the database.newsStory
- the NewsStory object to saveDatabaseException
- if there is an error saving the
data in the databasepublic abstract Event loadEvent(int id) throws DatabaseException
id
- the ID for the event group being loadedDatabaseException
- if there is an error accessing data
from the databasepublic abstract Event loadEvent(java.lang.String name) throws DatabaseException
name
- the name for the event group being loadedDatabaseException
- if there is an error accessing data
from the database (ie, if that event does not exist)public abstract DBIterator loadEvents() throws DatabaseException
The remove() method in the DBIterator may or may not function depending on the implementation.
DatabaseException
- if there is an error accessing data
from the databasepublic DBIterator loadEvents(int field, int order) throws DatabaseException
field
- The field to sort by, one of:
Event.FIELD_ID
,
Event.FIELD_NAME
,
Event.FIELD_LOCATION
,
Event.FIELD_URL
, or
Event.FIELD_PAIRS
.order
- The order to sort the new stories, either
ORDER_ASCENDING
or ORDER_DESCENDING
.java.lang.IllegalArgumentException
- if field is not one of
Event.FIELD_ID
,
Event.FIELD_NAME
,
Event.FIELD_LOCATION
,
Event.FIELD_URL
, or
Event.FIELD_PAIRS
; or if
order is not either ORDER_ASCENDING
or ORDER_DESCENDING
.DatabaseException
- if there is an error accessing data
from the databasepublic abstract DBIterator loadEvents(int field, int order, int limit) throws DatabaseException
If the given limit is more than the number of stories in the database, only the number available will be returned and no other error will occur.
field
- The field to sort by, one of:
Event.FIELD_ID
,
Event.FIELD_NAME
,
Event.FIELD_LOCATION
,
Event.FIELD_URL
, or
Event.FIELD_PAIRS
.order
- The order to sort the new stories, either
ORDER_ASCENDING
or ORDER_DESCENDING
.limit
- The total number of stories to retrieve, or a negative
number for all of them.java.lang.IllegalArgumentException
- if field is not one of
Event.FIELD_ID
,
Event.FIELD_NAME
,
Event.FIELD_LOCATION
,
Event.FIELD_URL
, or
Event.FIELD_PAIRS
; or if
order is not either ORDER_ASCENDING
or ORDER_DESCENDING
.DatabaseException
- if there is an error accessing data
from the databasepublic abstract DBIterator loadEventsFromDate(int range, int order, int limit) throws DatabaseException
range
), ordered
by the given order, and limited to the given amount.
If the given limit is more than the number of event groups in the database, only the number available will be returned and no other error will occur.
range
- Determines if database will load events before
(INCLUDE_BEFORE_TODAY
) or after (INCLUDE_AFTER_TODAY
)
the current date.order
- The order to sort the new stories, either
ORDER_ASCENDING
or ORDER_DESCENDING
.limit
- The total number of stories to retrieve, or a negative
number for all of them.java.lang.IllegalArgumentException
- if range is not either
INCLUDE_BEFORE_TODAY
or INCLUDE_AFTER_TODAY
; or
if order is not either ORDER_ASCENDING
or
ORDER_DESCENDING
.DatabaseException
- if there is an error accessing data
from the databasepublic abstract int loadEventCount() throws DatabaseException
DatabaseException
- if there is an error accessing data
from the databasepublic abstract Icon[] loadIcons() throws DatabaseException
DatabaseException
- if there is an error accessing data
from the databasepublic abstract Topic[] loadTopics() throws DatabaseException
DatabaseException
- if there is an error accessing data
from the database
|
WPI GDC CMS 0.0.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |