Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMsSql.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMsSql.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMsSql.java (revision 0) @@ -0,0 +1,29 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + + +/** + * methods for accessing discussion data in an ms sql server database. + */ +public class DiscussionServiceSqlMsSql extends DiscussionServiceSqlDefault { + +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMsSql.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDefault.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDefault.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDefault.java (revision 0) @@ -0,0 +1,53 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.sakaiproject.discussion.api.DiscussionServiceSql; + + + +/** + * methods for accessing discussion data in a database. + */ +public class DiscussionServiceSqlDefault implements DiscussionServiceSql { + + // logger + protected final transient Log logger = LogFactory.getLog(getClass()); + + + + /** + * returns the sql statement which retrieves the fields from the discussion_message table. + */ + public String getMessagesSql(String table) { + return "select CHANNEL_ID, MESSAGE_ID, XML from " + table /* + " where OWNER is null" */; + } + + /** + * returns the sql statement which updates a message in the discussion_message table. + */ + public String getUpdateMessageSql(String table) { + return "update " + table + " set OWNER = ?, DRAFT = ?, CATEGORY = ?, REPLY = ? where CHANNEL_ID = ? and MESSAGE_ID = ?"; + } +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDefault.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DbDiscussionService.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DbDiscussionService.java (revision 22639) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DbDiscussionService.java (working copy) @@ -4,17 +4,17 @@ *********************************************************************************** * * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation. - * - * Licensed under the Educational Community License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.opensource.org/licenses/ecl1.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * **********************************************************************************/ @@ -24,12 +24,14 @@ import java.sql.Connection; import java.sql.ResultSet; import java.util.List; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.sakaiproject.db.api.SqlReader; import org.sakaiproject.db.api.SqlService; import org.sakaiproject.discussion.api.DiscussionMessage; +import org.sakaiproject.discussion.api.DiscussionServiceSql; import org.sakaiproject.message.api.Message; import org.sakaiproject.message.api.MessageChannel; import org.sakaiproject.message.api.MessageChannelEdit; @@ -74,7 +76,7 @@ /** * Dependency: SqlService. - * + * * @param service * The SqlService. */ @@ -85,7 +87,7 @@ /** * Configuration: set the table name for the container. - * + * * @param path * The table name for the container. */ @@ -96,7 +98,7 @@ /** * Configuration: set the table name for the resource. - * + * * @param path * The table name for the resource. */ @@ -107,7 +109,7 @@ /** * Configuration: set the locks-in-db - * + * * @param path * The storage path. */ @@ -121,7 +123,7 @@ /** * Configuration: run the to-draft/owner conversion - * + * * @param value * The conversion desired value. */ @@ -135,7 +137,7 @@ /** * Configuration: to run the ddl on init or not. - * + * * @param value * the auto ddl value. */ @@ -144,6 +146,26 @@ m_autoDdl = new Boolean(value).booleanValue(); } + protected Map databaseBeans; // contains a map of the database dependent beans injected by spring + protected DiscussionServiceSql discussionServiceSql; // contains database dependent code + + public void setDatabaseBeans(Map databaseBeans) { + this.databaseBeans = databaseBeans; + } + + public DiscussionServiceSql getDiscussionServiceSql() { + return discussionServiceSql; + } + + /** + * sets which bean containing database dependent code should be used depending on the database vendor. + */ + public void setDiscussionServiceSql(String vendor) { + this.discussionServiceSql = (databaseBeans.containsKey(vendor) ? databaseBeans.get(vendor) : databaseBeans.get("default")); + } + + + /********************************************************************************************************************************************************************************************************************************************************** * Init and Destroy *********************************************************************************************************************************************************************************************************************************************************/ @@ -162,6 +184,7 @@ } super.init(); + setDiscussionServiceSql(m_sqlService.getVendor()); M_log.info("init(): tables: " + m_cTableName + " " + m_rTableName + " locks-in-db: " + m_locksInDb); @@ -184,7 +207,7 @@ /** * Construct a Storage object. - * + * * @return The new storage object. */ protected Storage newStorage() @@ -201,7 +224,7 @@ { /** * Construct. - * + * * @param user * The StorageUser class to call back for creation of Resource and Edit objects. */ @@ -323,7 +346,7 @@ connection.setAutoCommit(false); // read all message records that need conversion - String sql = "select CHANNEL_ID, MESSAGE_ID, XML from " + m_rTableName /* + " where OWNER is null" */; + String sql = discussionServiceSql.getMessagesSql(m_rTableName); m_sqlService.dbRead(connection, sql, null, new SqlReader() { private int count = 0; @@ -356,8 +379,7 @@ String replyTo = m.getDiscussionHeader().getReplyTo(); // update - String update = "update " + m_rTableName - + " set OWNER = ?, DRAFT = ?, CATEGORY = ?, REPLY = ? where CHANNEL_ID = ? and MESSAGE_ID = ?"; + String update = discussionServiceSql.getUpdateMessageSql(m_rTableName); Object fields[] = new Object[6]; fields[0] = owner; fields[1] = (draft ? "1" : "0"); Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMySql.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMySql.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMySql.java (revision 0) @@ -0,0 +1,31 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + + + + +/** + * methods for accessing discussion data in a mysql database. + */ +public class DiscussionServiceSqlMySql extends DiscussionServiceSqlDefault { + +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlMySql.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlOracle.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlOracle.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlOracle.java (revision 0) @@ -0,0 +1,31 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + + + + +/** + * methods for accessing discussion data in an oracle database. + */ +public class DiscussionServiceSqlOracle extends DiscussionServiceSqlDefault { + +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlOracle.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDb2.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDb2.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDb2.java (revision 0) @@ -0,0 +1,29 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + + +/** + * methods for accessing discussion data in a db2 database. + */ +public class DiscussionServiceSqlDb2 extends DiscussionServiceSqlDefault { + +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlDb2.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlHSql.java =================================================================== --- discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlHSql.java (revision 0) +++ discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlHSql.java (revision 0) @@ -0,0 +1,29 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.impl; + + +/** + * methods for accessing discussion data in a hypersonic sql database. + */ +public class DiscussionServiceSqlHSql extends DiscussionServiceSqlDefault { + +} Property changes on: discussion-impl/impl/src/java/org/sakaiproject/discussion/impl/DiscussionServiceSqlHSql.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native Index: discussion-impl/pack/src/webapp/WEB-INF/components.xml =================================================================== --- discussion-impl/pack/src/webapp/WEB-INF/components.xml (revision 22639) +++ discussion-impl/pack/src/webapp/WEB-INF/components.xml (working copy) @@ -3,6 +3,14 @@ + + + + + + + + DISCUSSION_MESSAGE false ${auto.ddl} + + + + + + + + + + + Index: discussion-api/api/src/java/org/sakaiproject/discussion/api/DiscussionServiceSql.java =================================================================== --- discussion-api/api/src/java/org/sakaiproject/discussion/api/DiscussionServiceSql.java (revision 0) +++ discussion-api/api/src/java/org/sakaiproject/discussion/api/DiscussionServiceSql.java (revision 0) @@ -0,0 +1,40 @@ +/********************************************************************************** + * $URL$ + * $Id$ + *********************************************************************************** + * + * Copyright (c) 2004, 2005, 2006 The Sakai Foundation. + * + * Licensed under the Educational Community License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ecl1.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + **********************************************************************************/ +package org.sakaiproject.discussion.api; + + + + +/** + * database methods. + */ +public interface DiscussionServiceSql { + + /** + * returns the sql statement which retrieves the fields from the discussion_message table. + */ + public String getMessagesSql(String table); + + /** + * returns the sql statement which updates a message in the discussion_message table. + */ + public String getUpdateMessageSql(String table); +} Property changes on: discussion-api/api/src/java/org/sakaiproject/discussion/api/DiscussionServiceSql.java ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Name: svn:eol-style + native