001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on Aug 31, 2007 7:21:02 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.dao.oracle;
044:
045: import java.sql.PreparedStatement;
046: import java.sql.ResultSet;
047: import java.sql.SQLException;
048: import java.sql.Timestamp;
049: import java.util.List;
050:
051: import net.jforum.dao.generic.GenericModerationLogDAO;
052: import net.jforum.entities.ModerationLog;
053: import net.jforum.exceptions.DatabaseException;
054: import net.jforum.util.DbUtils;
055: import net.jforum.util.preferences.SystemGlobals;
056:
057: /**
058: * @author Rafael Steil
059: * @version $Id: OracleModerationLogDAO.java,v 1.2 2007/09/11 04:00:45 rafaelsteil Exp $
060: */
061: public class OracleModerationLogDAO extends GenericModerationLogDAO {
062: /**
063: * @see net.jforum.dao.generic.GenericModerationLogDAO#add(net.jforum.entities.ModerationLog)
064: */
065: public void add(ModerationLog log) {
066: PreparedStatement p = null;
067:
068: try {
069: p = this .getStatementForAutoKeys("ModerationLog.addNew");
070:
071: p.setInt(1, log.getUser().getId());
072: p
073: .setTimestamp(2, new Timestamp(System
074: .currentTimeMillis()));
075: p.setInt(3, log.getType());
076: p.setInt(4, log.getPostId());
077: p.setInt(5, log.getTopicId());
078: p.setInt(6, log.getPosterUser().getId());
079:
080: if (log.getOriginalMessage() == null) {
081: log.setOriginalMessage("");
082: }
083:
084: this
085: .setAutoGeneratedKeysQuery(SystemGlobals
086: .getSql("ModerationLog.lastGeneratedModerationLogId"));
087:
088: int logId = this .executeAutoKeysQuery(p);
089:
090: log.setId(logId);
091:
092: OracleUtils.writeBlobUTF16BinaryStream(SystemGlobals
093: .getSql("ModerationLog.setDescription"), log
094: .getId(), log.getDescription());
095:
096: OracleUtils.writeBlobUTF16BinaryStream(SystemGlobals
097: .getSql("ModerationLog.setOriginalMessage"), log
098: .getId(), log.getOriginalMessage());
099: } catch (Exception e) {
100: throw new DatabaseException(e);
101: } finally {
102: DbUtils.close(p);
103: }
104: }
105:
106: /**
107: * @see net.jforum.dao.generic.GenericModerationLogDAO#selectAll(int, int)
108: */
109: public List selectAll(int start, int count) {
110: return super .selectAll(start, start + count);
111: }
112:
113: /**
114: * @see net.jforum.dao.generic.GenericModerationLogDAO#readDesriptionFromResultSet(java.sql.ResultSet)
115: */
116: protected String readDesriptionFromResultSet(ResultSet rs)
117: throws SQLException {
118: return OracleUtils.readBlobUTF16BinaryStream(rs,
119: "log_description");
120: }
121:
122: /**
123: * @see net.jforum.dao.generic.GenericModerationLogDAO#readOriginalMessageFromResultSet(java.sql.ResultSet)
124: */
125: protected String readOriginalMessageFromResultSet(ResultSet rs)
126: throws SQLException {
127: return OracleUtils.readBlobUTF16BinaryStream(rs,
128: "log_original_message");
129: }
130: }
|