|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.module.discuss.DiscussionLib
This class provides a series of static methods which return Database information used by the Locomotive Discussion system. Each of the methods return the data in a org.locomotive.util.SortableTable format, which then may be altered by the handler and displayed using the [table ] expression in the Steam template language. All database connectivity for the Discussion system is provided in the class; if support for new databases is required, then only this class should be altered!
Note that any reference to 'deleting' topics, posts, or discussions via the handlers only changes their status to 'DEAD'. To actually remove them from the database, use the deleteDeadTopics(), deleteDeadPosts(), and deleteDeadDiscussions() methods. The main method for this class does just this.
Field Summary | |
static int |
AUTHOR
used by the getPostSummaries method specify sorting |
static int |
DATE
used by the getPostSummaries method specify sorting |
static int |
TITLE
used by the getPostSummaries method specify sorting |
Constructor Summary | |
DiscussionLib(java.sql.Connection conn)
Initializes a DiscussionLib instance, with the correct database type. |
Method Summary | |
SortableTable |
addCategory(java.sql.Connection conn,
java.lang.String title,
java.lang.String body,
java.lang.String status)
adds a new category. |
boolean |
addPost(java.sql.Connection conn,
int topicId,
java.lang.String title,
java.lang.String postBody,
java.lang.String firstname,
java.lang.String lastname,
java.lang.String email)
adds a post with the specified into to list of posts for the topic specified by the id. |
SortableTable |
addTopic(java.sql.Connection conn,
int catId,
java.lang.String title)
adds a topic for the category specified by the id whose title is the specified title. |
void |
changeCategoryStatus(java.sql.Connection conn,
int id,
java.lang.String status)
Changes a topic's status to the specified parameter. |
boolean |
changePostStatus(java.sql.Connection conn,
int postId,
java.lang.String status)
changes a post status. |
void |
changeTopicStatus(java.sql.Connection conn,
int id,
java.lang.String status)
Changes a topic's status to the specified parameter. |
SortableTable |
cleanTopics(java.sql.Connection conn)
Delete all topics which don't have any posts. |
int |
deleteDeadDiscussions(java.sql.Connection conn)
Get rid of the 'DEAD' discussions. |
int |
deleteDeadPosts(java.sql.Connection conn)
Get rid of the 'DEAD' posts. |
int |
deleteDeadTopics(java.sql.Connection conn)
Get rid of the 'DEAD' topics. |
SortableTable |
getCategoryInfo(java.sql.Connection conn,
int id)
retrieves a single category's information |
SortableTable |
getCategoryList(java.sql.Connection conn,
java.lang.String status)
returns the list of categories available for the community |
SortableTable |
getPost(java.sql.Connection conn,
int postId)
returns a post |
SortableTable |
getPostIds(java.sql.Connection conn,
int id)
returns the entire list of posts from the database for the topic specified by the id |
SortableTable |
getPostList(java.sql.Connection conn,
int topicId,
int start,
int num)
returns a list of posts for a topic specified by the id. |
SortableTable |
getPostSummaries(java.sql.Connection conn,
int id,
int order)
this method returns a summary of all the posts related to a particular topic. |
SortableTable |
getTopicInfo(java.sql.Connection conn,
int topicId)
returns the information for the topic whose id is specified |
SortableTable |
getTopicList(java.sql.Connection conn,
int catId,
java.lang.String status)
returns a list of topics for the category whose id is specified |
void |
getUserInfo(java.sql.Connection conn,
User user,
java.util.Hashtable steam_vars)
|
static void |
main(java.lang.String[] args)
This sample app will go ahead and delete all the discussions, topics and posts marked as 'DEAD'. |
void |
modifyCategory(java.sql.Connection conn,
int id,
java.lang.String title,
java.lang.String body,
java.lang.String status)
Modify the topic. |
boolean |
modifyPost(java.sql.Connection conn,
int postId,
int topicId,
java.lang.String title,
java.lang.String postBody,
java.lang.String firstname,
java.lang.String lastname,
java.lang.String email,
java.lang.String status)
modifies an existing post with the new fields passed in as parameters. |
void |
modifyTopic(java.sql.Connection conn,
int id,
java.lang.String title,
java.lang.String status)
Modify the topic. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int DATE
public static final int AUTHOR
public static final int TITLE
Constructor Detail |
public DiscussionLib(java.sql.Connection conn) throws java.sql.SQLException
Method Detail |
public void getUserInfo(java.sql.Connection conn, User user, java.util.Hashtable steam_vars) throws java.sql.SQLException
public SortableTable getCategoryList(java.sql.Connection conn, java.lang.String status)
status
- the status of the list of communities to return0 id Integer 1 name String 2 description String 3 status string 4 topic_count Integer 5 post_count Integer 6 last_post_date Integer
public SortableTable getCategoryInfo(java.sql.Connection conn, int id)
id
- the id of the category to return.0 id Integer 1 name String 2 description String 3 status string 4 topic_count Integer 5 post_count Integer 6 last_post_date Integer
public SortableTable getTopicList(java.sql.Connection conn, int catId, java.lang.String status)
catId
- the id of the category to return topics for0 topicid int 1 communityid int 2 topicname String 3 post_count Integer 4 last_post_date Integer
public SortableTable getTopicInfo(java.sql.Connection conn, int topicId)
topicId
- the id of the topic to return. If -1, all topics
are returned.0 topicid int 1 communityid int 2 topicname String 3 post_count Integer 4 last_post_date Integer 5 topicstatus String
public SortableTable getPostList(java.sql.Connection conn, int topicId, int start, int num)
start
- the post number to start counting back from. In
other words, return the first num posts whose postid is
less than or equal to this number. If the number is -1,
return the last num posts.num
- the number of posts to return0 postid int 1 posttitle String 2 postbody String 3 postauthorfn String 4 postauthorln String 5 postemail String 6 postdate Date
public SortableTable getPost(java.sql.Connection conn, int postId)
postId
- the post idnum
- the number of posts to return0 postid int 1 posttitle String 2 postbody String 3 postauthorfn String 4 postauthorln String 5 postemail String 6 postdate Date 7 topicid int
public SortableTable getPostIds(java.sql.Connection conn, int id)
0 postid int
public SortableTable getPostSummaries(java.sql.Connection conn, int id, int order)
id
- the topic's id to summarize the posts fororder
- one of either of the class constants
DiscussionLib.DATE, DiscussionLib.AUTHOR, DiscussionLib.TITLE0 postid int 1 posttitle String 2 postauthorfn String 3 postauthorln String 4 postemail String 5 postdate Date
public boolean addPost(java.sql.Connection conn, int topicId, java.lang.String title, java.lang.String postBody, java.lang.String firstname, java.lang.String lastname, java.lang.String email)
public boolean changePostStatus(java.sql.Connection conn, int postId, java.lang.String status)
public boolean modifyPost(java.sql.Connection conn, int postId, int topicId, java.lang.String title, java.lang.String postBody, java.lang.String firstname, java.lang.String lastname, java.lang.String email, java.lang.String status)
public SortableTable addTopic(java.sql.Connection conn, int catId, java.lang.String title)
0 topicid int 1 communityid int 2 topicname String
public void changeTopicStatus(java.sql.Connection conn, int id, java.lang.String status)
conn
- the Connection to useid
- the topicid of the topic to changestatus
- the status to change the topic to. Should
be either LIVE or DEAD.public void modifyTopic(java.sql.Connection conn, int id, java.lang.String title, java.lang.String status)
conn
- the Connection to useid
- the topicid of the topic to changetitle
- the new title for the topic. Set this to null
if you don't want to update the title.status
- the status to change the topic to. Should
be either 'LIVE' or 'DEAD'.public SortableTable addCategory(java.sql.Connection conn, java.lang.String title, java.lang.String body, java.lang.String status)
0 id int 1 name String 2 description StringReturn null if there was an error
public void changeCategoryStatus(java.sql.Connection conn, int id, java.lang.String status)
conn
- the Connection to useid
- the topicid of the topic to changestatus
- the status to change the topic to. Should
be either LIVE or DEAD.public void modifyCategory(java.sql.Connection conn, int id, java.lang.String title, java.lang.String body, java.lang.String status)
conn
- the Connection to useid
- the topicid of the topic to changetitle
- the new title for the topic. Set this to null
if you don't want to update the title.status
- the status to change the topic to. Should
be either 'LIVE' or 'DEAD'.public int deleteDeadPosts(java.sql.Connection conn)
public int deleteDeadTopics(java.sql.Connection conn)
public int deleteDeadDiscussions(java.sql.Connection conn)
public SortableTable cleanTopics(java.sql.Connection conn)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |