OracleModerationLogDAO.java
Upload User: gdxydsw
Upload Date: 2019-01-29
Package Size: 16721k
Code Size: 4k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright (c) JForum Team
  3.  * All rights reserved.
  4.  * 
  5.  * Redistribution and use in source and binary forms, 
  6.  * with or without modification, are permitted provided 
  7.  * that the following conditions are met:
  8.  * 
  9.  * 1) Redistributions of source code must retain the above 
  10.  * copyright notice, this list of conditions and the 
  11.  * following  disclaimer.
  12.  * 2)  Redistributions in binary form must reproduce the 
  13.  * above copyright notice, this list of conditions and 
  14.  * the following disclaimer in the documentation and/or 
  15.  * other materials provided with the distribution.
  16.  * 3) Neither the name of "Rafael Steil" nor 
  17.  * the names of its contributors may be used to endorse 
  18.  * or promote products derived from this software without 
  19.  * specific prior written permission.
  20.  * 
  21.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
  22.  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
  23.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
  24.  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  25.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  26.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
  27.  * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
  28.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  29.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  30.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  31.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  32.  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  33.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
  34.  * IN CONTRACT, STRICT LIABILITY, OR TORT 
  35.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  36.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  37.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  38.  * 
  39.  * Created on Aug 31, 2007 7:21:02 PM
  40.  * The JForum Project
  41.  * http://www.jforum.net
  42.  */
  43. package net.jforum.dao.oracle;
  44. import java.sql.PreparedStatement;
  45. import java.sql.ResultSet;
  46. import java.sql.SQLException;
  47. import java.sql.Timestamp;
  48. import java.util.List;
  49. import net.jforum.dao.generic.GenericModerationLogDAO;
  50. import net.jforum.entities.ModerationLog;
  51. import net.jforum.exceptions.DatabaseException;
  52. import net.jforum.util.DbUtils;
  53. import net.jforum.util.preferences.SystemGlobals;
  54. /**
  55.  * @author Rafael Steil
  56.  * @version $Id: OracleModerationLogDAO.java,v 1.2 2007/09/11 04:00:45 rafaelsteil Exp $
  57.  */
  58. public class OracleModerationLogDAO extends GenericModerationLogDAO 
  59. {
  60. /**
  61.  * @see net.jforum.dao.generic.GenericModerationLogDAO#add(net.jforum.entities.ModerationLog)
  62.  */
  63. public void add(ModerationLog log) 
  64. {
  65. PreparedStatement p = null;
  66. try {
  67. p = this.getStatementForAutoKeys("ModerationLog.addNew");
  68. p.setInt(1, log.getUser().getId());
  69. p.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
  70. p.setInt(3, log.getType());
  71. p.setInt(4, log.getPostId());
  72. p.setInt(5, log.getTopicId());
  73. p.setInt(6, log.getPosterUser().getId());
  74. if (log.getOriginalMessage() == null) {
  75. log.setOriginalMessage("");
  76. }
  77. this.setAutoGeneratedKeysQuery(SystemGlobals.getSql("ModerationLog.lastGeneratedModerationLogId"));
  78. int logId = this.executeAutoKeysQuery(p);
  79. log.setId(logId);
  80. OracleUtils.writeBlobUTF16BinaryStream(SystemGlobals.getSql("ModerationLog.setDescription"), 
  81. log.getId(), log.getDescription());
  82. OracleUtils.writeBlobUTF16BinaryStream(SystemGlobals.getSql("ModerationLog.setOriginalMessage"), 
  83. log.getId(), log.getOriginalMessage());
  84. }
  85. catch (Exception e) {
  86. throw new DatabaseException(e);
  87. }
  88. finally {
  89. DbUtils.close(p);
  90. }
  91. }
  92. /**
  93.  * @see net.jforum.dao.generic.GenericModerationLogDAO#selectAll(int, int)
  94.  */
  95. public List selectAll(int start, int count) 
  96. {
  97. return super.selectAll(start, start + count);
  98. }
  99. /**
  100.  * @see net.jforum.dao.generic.GenericModerationLogDAO#readDesriptionFromResultSet(java.sql.ResultSet)
  101.  */
  102. protected String readDesriptionFromResultSet(ResultSet rs) throws SQLException 
  103. {
  104. return OracleUtils.readBlobUTF16BinaryStream(rs, "log_description");
  105. }
  106. /**
  107.  * @see net.jforum.dao.generic.GenericModerationLogDAO#readOriginalMessageFromResultSet(java.sql.ResultSet)
  108.  */
  109. protected String readOriginalMessageFromResultSet(ResultSet rs) throws SQLException 
  110. {
  111. return OracleUtils.readBlobUTF16BinaryStream(rs, "log_original_message");
  112. }
  113. }