001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.messageboards.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.DateUtil;
025: import com.liferay.portal.kernel.util.GetterUtil;
026: import com.liferay.portal.model.impl.BaseModelImpl;
027: import com.liferay.portal.util.PropsUtil;
028:
029: import com.liferay.portlet.messageboards.model.MBMessage;
030:
031: import com.liferay.util.Html;
032:
033: import java.io.Serializable;
034:
035: import java.lang.reflect.Proxy;
036:
037: import java.sql.Types;
038:
039: import java.util.Date;
040:
041: /**
042: * <a href="MBMessageModelImpl.java.html"><b><i>View Source</i></b></a>
043: *
044: * <p>
045: * ServiceBuilder generated this class. Modifications in this class will be
046: * overwritten the next time is generated.
047: * </p>
048: *
049: * <p>
050: * This class is a model that represents the <code>MBMessage</code> table
051: * in the database.
052: * </p>
053: *
054: * @author Brian Wing Shun Chan
055: *
056: * @see com.liferay.portlet.messageboards.service.model.MBMessage
057: * @see com.liferay.portlet.messageboards.service.model.MBMessageModel
058: * @see com.liferay.portlet.messageboards.service.model.impl.MBMessageImpl
059: *
060: */
061: public class MBMessageModelImpl extends BaseModelImpl {
062: public static final String TABLE_NAME = "MBMessage";
063: public static final Object[][] TABLE_COLUMNS = {
064: { "uuid_", new Integer(Types.VARCHAR) },
065:
066: { "messageId", new Integer(Types.BIGINT) },
067:
068: { "companyId", new Integer(Types.BIGINT) },
069:
070: { "userId", new Integer(Types.BIGINT) },
071:
072: { "userName", new Integer(Types.VARCHAR) },
073:
074: { "createDate", new Integer(Types.TIMESTAMP) },
075:
076: { "modifiedDate", new Integer(Types.TIMESTAMP) },
077:
078: { "categoryId", new Integer(Types.BIGINT) },
079:
080: { "threadId", new Integer(Types.BIGINT) },
081:
082: { "parentMessageId", new Integer(Types.BIGINT) },
083:
084: { "subject", new Integer(Types.VARCHAR) },
085:
086: { "body", new Integer(Types.CLOB) },
087:
088: { "attachments", new Integer(Types.BOOLEAN) },
089:
090: { "anonymous", new Integer(Types.BOOLEAN) } };
091: public static final String TABLE_SQL_CREATE = "create table MBMessage (uuid_ VARCHAR(75) null,messageId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,threadId LONG,parentMessageId LONG,subject VARCHAR(75) null,body TEXT null,attachments BOOLEAN,anonymous BOOLEAN)";
092: public static final String TABLE_SQL_DROP = "drop table MBMessage";
093: public static final boolean CACHE_ENABLED = GetterUtil
094: .getBoolean(
095: PropsUtil
096: .get("value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessage"),
097: true);
098: public static final long LOCK_EXPIRATION_TIME = GetterUtil
099: .getLong(PropsUtil
100: .get("lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessage"));
101:
102: public MBMessageModelImpl() {
103: }
104:
105: public long getPrimaryKey() {
106: return _messageId;
107: }
108:
109: public void setPrimaryKey(long pk) {
110: setMessageId(pk);
111: }
112:
113: public Serializable getPrimaryKeyObj() {
114: return new Long(_messageId);
115: }
116:
117: public String getUuid() {
118: return GetterUtil.getString(_uuid);
119: }
120:
121: public void setUuid(String uuid) {
122: if ((uuid != null) && (uuid != _uuid)) {
123: _uuid = uuid;
124: }
125: }
126:
127: public long getMessageId() {
128: return _messageId;
129: }
130:
131: public void setMessageId(long messageId) {
132: if (messageId != _messageId) {
133: _messageId = messageId;
134: }
135: }
136:
137: public long getCompanyId() {
138: return _companyId;
139: }
140:
141: public void setCompanyId(long companyId) {
142: if (companyId != _companyId) {
143: _companyId = companyId;
144: }
145: }
146:
147: public long getUserId() {
148: return _userId;
149: }
150:
151: public void setUserId(long userId) {
152: if (userId != _userId) {
153: _userId = userId;
154: }
155: }
156:
157: public String getUserName() {
158: return GetterUtil.getString(_userName);
159: }
160:
161: public void setUserName(String userName) {
162: if (((userName == null) && (_userName != null))
163: || ((userName != null) && (_userName == null))
164: || ((userName != null) && (_userName != null) && !userName
165: .equals(_userName))) {
166: _userName = userName;
167: }
168: }
169:
170: public Date getCreateDate() {
171: return _createDate;
172: }
173:
174: public void setCreateDate(Date createDate) {
175: if (((createDate == null) && (_createDate != null))
176: || ((createDate != null) && (_createDate == null))
177: || ((createDate != null) && (_createDate != null) && !createDate
178: .equals(_createDate))) {
179: _createDate = createDate;
180: }
181: }
182:
183: public Date getModifiedDate() {
184: return _modifiedDate;
185: }
186:
187: public void setModifiedDate(Date modifiedDate) {
188: if (((modifiedDate == null) && (_modifiedDate != null))
189: || ((modifiedDate != null) && (_modifiedDate == null))
190: || ((modifiedDate != null) && (_modifiedDate != null) && !modifiedDate
191: .equals(_modifiedDate))) {
192: _modifiedDate = modifiedDate;
193: }
194: }
195:
196: public long getCategoryId() {
197: return _categoryId;
198: }
199:
200: public void setCategoryId(long categoryId) {
201: if (categoryId != _categoryId) {
202: _categoryId = categoryId;
203: }
204: }
205:
206: public long getThreadId() {
207: return _threadId;
208: }
209:
210: public void setThreadId(long threadId) {
211: if (threadId != _threadId) {
212: _threadId = threadId;
213: }
214: }
215:
216: public long getParentMessageId() {
217: return _parentMessageId;
218: }
219:
220: public void setParentMessageId(long parentMessageId) {
221: if (parentMessageId != _parentMessageId) {
222: _parentMessageId = parentMessageId;
223: }
224: }
225:
226: public String getSubject() {
227: return GetterUtil.getString(_subject);
228: }
229:
230: public void setSubject(String subject) {
231: if (((subject == null) && (_subject != null))
232: || ((subject != null) && (_subject == null))
233: || ((subject != null) && (_subject != null) && !subject
234: .equals(_subject))) {
235: _subject = subject;
236: }
237: }
238:
239: public String getBody() {
240: return GetterUtil.getString(_body);
241: }
242:
243: public void setBody(String body) {
244: if (((body == null) && (_body != null))
245: || ((body != null) && (_body == null))
246: || ((body != null) && (_body != null) && !body
247: .equals(_body))) {
248: _body = body;
249: }
250: }
251:
252: public boolean getAttachments() {
253: return _attachments;
254: }
255:
256: public boolean isAttachments() {
257: return _attachments;
258: }
259:
260: public void setAttachments(boolean attachments) {
261: if (attachments != _attachments) {
262: _attachments = attachments;
263: }
264: }
265:
266: public boolean getAnonymous() {
267: return _anonymous;
268: }
269:
270: public boolean isAnonymous() {
271: return _anonymous;
272: }
273:
274: public void setAnonymous(boolean anonymous) {
275: if (anonymous != _anonymous) {
276: _anonymous = anonymous;
277: }
278: }
279:
280: public MBMessage toEscapedModel() {
281: if (isEscapedModel()) {
282: return (MBMessage) this ;
283: } else {
284: MBMessage model = new MBMessageImpl();
285:
286: model.setEscapedModel(true);
287:
288: model.setUuid(Html.escape(getUuid()));
289: model.setMessageId(getMessageId());
290: model.setCompanyId(getCompanyId());
291: model.setUserId(getUserId());
292: model.setUserName(Html.escape(getUserName()));
293: model.setCreateDate(getCreateDate());
294: model.setModifiedDate(getModifiedDate());
295: model.setCategoryId(getCategoryId());
296: model.setThreadId(getThreadId());
297: model.setParentMessageId(getParentMessageId());
298: model.setSubject(Html.escape(getSubject()));
299: model.setBody(Html.escape(getBody()));
300: model.setAttachments(getAttachments());
301: model.setAnonymous(getAnonymous());
302:
303: model = (MBMessage) Proxy.newProxyInstance(MBMessage.class
304: .getClassLoader(), new Class[] { MBMessage.class },
305: new ReadOnlyBeanHandler(model));
306:
307: return model;
308: }
309: }
310:
311: public Object clone() {
312: MBMessageImpl clone = new MBMessageImpl();
313:
314: clone.setUuid(getUuid());
315: clone.setMessageId(getMessageId());
316: clone.setCompanyId(getCompanyId());
317: clone.setUserId(getUserId());
318: clone.setUserName(getUserName());
319: clone.setCreateDate(getCreateDate());
320: clone.setModifiedDate(getModifiedDate());
321: clone.setCategoryId(getCategoryId());
322: clone.setThreadId(getThreadId());
323: clone.setParentMessageId(getParentMessageId());
324: clone.setSubject(getSubject());
325: clone.setBody(getBody());
326: clone.setAttachments(getAttachments());
327: clone.setAnonymous(getAnonymous());
328:
329: return clone;
330: }
331:
332: public int compareTo(Object obj) {
333: if (obj == null) {
334: return -1;
335: }
336:
337: MBMessageImpl mbMessage = (MBMessageImpl) obj;
338:
339: int value = 0;
340:
341: value = DateUtil.compareTo(getCreateDate(), mbMessage
342: .getCreateDate());
343:
344: if (value != 0) {
345: return value;
346: }
347:
348: if (getMessageId() < mbMessage.getMessageId()) {
349: value = -1;
350: } else if (getMessageId() > mbMessage.getMessageId()) {
351: value = 1;
352: } else {
353: value = 0;
354: }
355:
356: if (value != 0) {
357: return value;
358: }
359:
360: return 0;
361: }
362:
363: public boolean equals(Object obj) {
364: if (obj == null) {
365: return false;
366: }
367:
368: MBMessageImpl mbMessage = null;
369:
370: try {
371: mbMessage = (MBMessageImpl) obj;
372: } catch (ClassCastException cce) {
373: return false;
374: }
375:
376: long pk = mbMessage.getPrimaryKey();
377:
378: if (getPrimaryKey() == pk) {
379: return true;
380: } else {
381: return false;
382: }
383: }
384:
385: public int hashCode() {
386: return (int) getPrimaryKey();
387: }
388:
389: private String _uuid;
390: private long _messageId;
391: private long _companyId;
392: private long _userId;
393: private String _userName;
394: private Date _createDate;
395: private Date _modifiedDate;
396: private long _categoryId;
397: private long _threadId;
398: private long _parentMessageId;
399: private String _subject;
400: private String _body;
401: private boolean _attachments;
402: private boolean _anonymous;
403: }
|