[jboss-svn-commits] JBL Code SVN: r26693 - in labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main: java/org/jboss/labs/clearspace/plugin/nfm/dao and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 22 09:31:34 EDT 2009
Author: lkrzyzanek
Date: 2009-05-22 09:31:34 -0400 (Fri, 22 May 2009)
New Revision: 26693
Modified:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
Log:
implementing migration (thread as question etc.)
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-05-22 12:56:08 UTC (rev 26692)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-05-22 13:31:34 UTC (rev 26693)
@@ -21,6 +21,8 @@
*/
package org.jboss.labs.clearspace.plugin.nfm;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -46,6 +48,7 @@
import com.jivesoftware.community.ForumManager;
import com.jivesoftware.community.ForumMessage;
import com.jivesoftware.community.ForumThread;
+import com.jivesoftware.community.QuestionManager;
import com.jivesoftware.community.RejectedException;
/**
@@ -69,10 +72,14 @@
private UserManager userManager;
+ private QuestionManager questionManager;
+
Map<Long, Long> categoryMappings = null;
Map<Long, Long> forumMappings = null;
+ private Date defaultTopicTime;
+
public int createForumMappingFromCategories() {
Set<Map.Entry<Long, Long>> entries = getCategoryMappings().entrySet();
int count = 0;
@@ -122,13 +129,16 @@
NukesForumsPostBean topicPost = nukesForumsDAO.getPostByID(topic
.getFirstPostID());
- // check topic time
- if (topic.getTime() == null) {
- if (topicPost.getTime() != null) {
- topic.setTime(topicPost.getTime());
+ // check topicPost time
+ // some posts has null value but topic time is set
+ if (topicPost.getTime() == null) {
+ if (topic.getTime() != null) {
+ topicPost.setTime(topic.getTime());
} else {
- // should not occure
- throw new RuntimeException();
+ // should not occur, but if yes then set default time
+ log.info("Topic post and topic has no creation date. "
+ + "Setting to default");
+ topicPost.setTime(defaultTopicTime);
}
}
@@ -147,17 +157,32 @@
}
ForumMessage rootMessage = forumManager.createMessage(community,
rootMessageUser);
+ // creationDate taken from first post.
+ // some topic time is not correct (in future etc.)
+ rootMessage.setCreationDate(topicPost.getTime());
+ rootMessage.setModificationDate(topicPost.getTime());
+ rootMessage.setSubject(topic.getTitle());
+
org.w3c.dom.Document topicBody = WikiContentHelper
- .unknownContentToJiveDoc(topicPost.getBody());
+ .wikiToJiveDocument(topicPost.getBody());
rootMessage.setBody(topicBody);
- rootMessage.setCreationDate(topic.getTime());
- rootMessage.setSubject(topic.getTitle());
ForumThread thread = forumManager.createThread(community, rootMessage);
- thread.setCreationDate(topic.getTime());
+ thread.setCreationDate(topicPost.getTime());
+ thread.setModificationDate(topicPost.getTime());
try {
forumManager.addThread(community, thread);
+
+ nukesForumsMappingDAO.saveTopicMapping(topic.getTopicID(), thread
+ .getID());
+
+ nukesForumsMappingDAO.savePostMapping(topicPost.getPostID(),
+ rootMessage.getID());
+ if (topicPost.getSubject().contains("?")) {
+ questionManager.createQuestion(thread);
+ }
+
postsCount++;
} catch (RejectedException e) {
throw new RuntimeException(e);
@@ -176,24 +201,28 @@
ForumMessage replyMessage = forumManager.createMessage(community,
replyUser);
org.w3c.dom.Document replyBody = WikiContentHelper
- .unknownContentToJiveDoc(reply.getBody());
+ .wikiToJiveDocument(reply.getBody());
replyMessage.setBody(replyBody);
- replyMessage.setCreationDate(reply.getTime() != null ? reply
- .getTime() : new Date(topic.getTime().getTime() + 1));
+ Date replyDate = reply.getTime();
+ if (replyDate == null) {
+ replyDate = new Date(topicPost.getTime().getTime() + 1);
+ }
+ replyMessage.setCreationDate(replyDate);
+ replyMessage.setModificationDate(replyDate);
replyMessage.setSubject(reply.getSubject());
try {
forumManager.addMessage(thread, rootMessage, replyMessage);
+
+ nukesForumsMappingDAO.savePostMapping(reply.getPostID(),
+ replyMessage.getID());
} catch (RejectedException e) {
throw new RuntimeException(e);
}
postsCount++;
}
- // nukesForumsMappingDAO.saveTopicMapping(topic.getTopicID(),
- // discussionID);
-
topicsCount++;
}
@@ -269,4 +298,24 @@
this.userManager = userManager;
}
+ public void setDefaultTopicTime(Date defaultTopicTime) {
+ this.defaultTopicTime = defaultTopicTime;
+ }
+
+ /**
+ * Set defaultTopicTime as String with this format: yyyy-MM-dd
+ *
+ * @param defaultTopicTimeStr
+ * @throws ParseException
+ */
+ public void setDefaultTopicTimeStr(String defaultTopicTimeStr)
+ throws ParseException {
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+ defaultTopicTime = df.parse(defaultTopicTimeStr);
+ }
+
+ public void setQuestionManager(QuestionManager questionManager) {
+ this.questionManager = questionManager;
+ }
+
}
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java 2009-05-22 12:56:08 UTC (rev 26692)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java 2009-05-22 13:31:34 UTC (rev 26693)
@@ -88,10 +88,10 @@
throws SQLException {
NukesForumsPostBean bean = new NukesForumsPostBean();
bean.setPostID(rs.getLong("post_id"));
- bean.setTopicID(rs.getLong("post_id"));
- bean.setForumID(rs.getLong("post_id"));
+ bean.setTopicID(rs.getLong("topic_id"));
+ bean.setForumID(rs.getLong("forum_id"));
bean.setPosterID(rs.getLong("poster_id"));
- bean.setTime(rs.getDate("post_time"));
+ bean.setTime(rs.getTimestamp("post_time"));
bean.setSubject(rs.getString("post_subject"));
bean.setBody(rs.getString("post_text"));
return bean;
@@ -145,7 +145,7 @@
bean.setTopicID(rs.getLong("topic_id"));
bean.setTitle(rs.getString("topic_title"));
bean.setPosterID(rs.getLong("topic_poster"));
- bean.setTime(rs.getDate("topic_time"));
+ bean.setTime(rs.getTimestamp("topic_time"));
bean.setStatus(rs.getInt("topic_status"));
bean.setFirstPostID(rs.getLong("topic_first_post_id"));
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml 2009-05-22 12:56:08 UTC (rev 26692)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml 2009-05-22 13:31:34 UTC (rev 26693)
@@ -12,6 +12,8 @@
<property name="communityManager" ref="communityManager" />
<property name="forumManager" ref="forumManager" />
<property name="userManager" ref="userManager" />
+ <property name="questionManager" ref="questionManager" />
+ <property name="defaultTopicTimeStr" value="2002-01-01" />
</bean>
<bean id="nukesForumsMappingDAO"
@@ -26,7 +28,8 @@
<property name="dataSource" ref="forumsDataSource" />
</bean>
- <bean id="forumsDataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+ <bean id="forumsDataSource"
+ class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/nukesprod" />
<property name="username" value="nukesprod" />
More information about the jboss-svn-commits
mailing list