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.GetterUtil;
025: import com.liferay.portal.model.impl.BaseModelImpl;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.portlet.messageboards.model.MBCategory;
029:
030: import com.liferay.util.Html;
031:
032: import java.io.Serializable;
033:
034: import java.lang.reflect.Proxy;
035:
036: import java.sql.Types;
037:
038: import java.util.Date;
039:
040: /**
041: * <a href="MBCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
042: *
043: * <p>
044: * ServiceBuilder generated this class. Modifications in this class will be
045: * overwritten the next time is generated.
046: * </p>
047: *
048: * <p>
049: * This class is a model that represents the <code>MBCategory</code> table
050: * in the database.
051: * </p>
052: *
053: * @author Brian Wing Shun Chan
054: *
055: * @see com.liferay.portlet.messageboards.service.model.MBCategory
056: * @see com.liferay.portlet.messageboards.service.model.MBCategoryModel
057: * @see com.liferay.portlet.messageboards.service.model.impl.MBCategoryImpl
058: *
059: */
060: public class MBCategoryModelImpl extends BaseModelImpl {
061: public static final String TABLE_NAME = "MBCategory";
062: public static final Object[][] TABLE_COLUMNS = {
063: { "uuid_", new Integer(Types.VARCHAR) },
064:
065: { "categoryId", new Integer(Types.BIGINT) },
066:
067: { "groupId", new Integer(Types.BIGINT) },
068:
069: { "companyId", new Integer(Types.BIGINT) },
070:
071: { "userId", new Integer(Types.BIGINT) },
072:
073: { "userName", new Integer(Types.VARCHAR) },
074:
075: { "createDate", new Integer(Types.TIMESTAMP) },
076:
077: { "modifiedDate", new Integer(Types.TIMESTAMP) },
078:
079: { "parentCategoryId", new Integer(Types.BIGINT) },
080:
081: { "name", new Integer(Types.VARCHAR) },
082:
083: { "description", new Integer(Types.VARCHAR) },
084:
085: { "lastPostDate", new Integer(Types.TIMESTAMP) } };
086: public static final String TABLE_SQL_CREATE = "create table MBCategory (uuid_ VARCHAR(75) null,categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null,lastPostDate DATE null)";
087: public static final String TABLE_SQL_DROP = "drop table MBCategory";
088: public static final boolean CACHE_ENABLED = GetterUtil
089: .getBoolean(
090: PropsUtil
091: .get("value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
092: true);
093: public static final long LOCK_EXPIRATION_TIME = GetterUtil
094: .getLong(PropsUtil
095: .get("lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
096:
097: public MBCategoryModelImpl() {
098: }
099:
100: public long getPrimaryKey() {
101: return _categoryId;
102: }
103:
104: public void setPrimaryKey(long pk) {
105: setCategoryId(pk);
106: }
107:
108: public Serializable getPrimaryKeyObj() {
109: return new Long(_categoryId);
110: }
111:
112: public String getUuid() {
113: return GetterUtil.getString(_uuid);
114: }
115:
116: public void setUuid(String uuid) {
117: if ((uuid != null) && (uuid != _uuid)) {
118: _uuid = uuid;
119: }
120: }
121:
122: public long getCategoryId() {
123: return _categoryId;
124: }
125:
126: public void setCategoryId(long categoryId) {
127: if (categoryId != _categoryId) {
128: _categoryId = categoryId;
129: }
130: }
131:
132: public long getGroupId() {
133: return _groupId;
134: }
135:
136: public void setGroupId(long groupId) {
137: if (groupId != _groupId) {
138: _groupId = groupId;
139: }
140: }
141:
142: public long getCompanyId() {
143: return _companyId;
144: }
145:
146: public void setCompanyId(long companyId) {
147: if (companyId != _companyId) {
148: _companyId = companyId;
149: }
150: }
151:
152: public long getUserId() {
153: return _userId;
154: }
155:
156: public void setUserId(long userId) {
157: if (userId != _userId) {
158: _userId = userId;
159: }
160: }
161:
162: public String getUserName() {
163: return GetterUtil.getString(_userName);
164: }
165:
166: public void setUserName(String userName) {
167: if (((userName == null) && (_userName != null))
168: || ((userName != null) && (_userName == null))
169: || ((userName != null) && (_userName != null) && !userName
170: .equals(_userName))) {
171: _userName = userName;
172: }
173: }
174:
175: public Date getCreateDate() {
176: return _createDate;
177: }
178:
179: public void setCreateDate(Date createDate) {
180: if (((createDate == null) && (_createDate != null))
181: || ((createDate != null) && (_createDate == null))
182: || ((createDate != null) && (_createDate != null) && !createDate
183: .equals(_createDate))) {
184: _createDate = createDate;
185: }
186: }
187:
188: public Date getModifiedDate() {
189: return _modifiedDate;
190: }
191:
192: public void setModifiedDate(Date modifiedDate) {
193: if (((modifiedDate == null) && (_modifiedDate != null))
194: || ((modifiedDate != null) && (_modifiedDate == null))
195: || ((modifiedDate != null) && (_modifiedDate != null) && !modifiedDate
196: .equals(_modifiedDate))) {
197: _modifiedDate = modifiedDate;
198: }
199: }
200:
201: public long getParentCategoryId() {
202: return _parentCategoryId;
203: }
204:
205: public void setParentCategoryId(long parentCategoryId) {
206: if (parentCategoryId != _parentCategoryId) {
207: _parentCategoryId = parentCategoryId;
208: }
209: }
210:
211: public String getName() {
212: return GetterUtil.getString(_name);
213: }
214:
215: public void setName(String name) {
216: if (((name == null) && (_name != null))
217: || ((name != null) && (_name == null))
218: || ((name != null) && (_name != null) && !name
219: .equals(_name))) {
220: _name = name;
221: }
222: }
223:
224: public String getDescription() {
225: return GetterUtil.getString(_description);
226: }
227:
228: public void setDescription(String description) {
229: if (((description == null) && (_description != null))
230: || ((description != null) && (_description == null))
231: || ((description != null) && (_description != null) && !description
232: .equals(_description))) {
233: _description = description;
234: }
235: }
236:
237: public Date getLastPostDate() {
238: return _lastPostDate;
239: }
240:
241: public void setLastPostDate(Date lastPostDate) {
242: if (((lastPostDate == null) && (_lastPostDate != null))
243: || ((lastPostDate != null) && (_lastPostDate == null))
244: || ((lastPostDate != null) && (_lastPostDate != null) && !lastPostDate
245: .equals(_lastPostDate))) {
246: _lastPostDate = lastPostDate;
247: }
248: }
249:
250: public MBCategory toEscapedModel() {
251: if (isEscapedModel()) {
252: return (MBCategory) this ;
253: } else {
254: MBCategory model = new MBCategoryImpl();
255:
256: model.setEscapedModel(true);
257:
258: model.setUuid(Html.escape(getUuid()));
259: model.setCategoryId(getCategoryId());
260: model.setGroupId(getGroupId());
261: model.setCompanyId(getCompanyId());
262: model.setUserId(getUserId());
263: model.setUserName(Html.escape(getUserName()));
264: model.setCreateDate(getCreateDate());
265: model.setModifiedDate(getModifiedDate());
266: model.setParentCategoryId(getParentCategoryId());
267: model.setName(Html.escape(getName()));
268: model.setDescription(Html.escape(getDescription()));
269: model.setLastPostDate(getLastPostDate());
270:
271: model = (MBCategory) Proxy.newProxyInstance(
272: MBCategory.class.getClassLoader(),
273: new Class[] { MBCategory.class },
274: new ReadOnlyBeanHandler(model));
275:
276: return model;
277: }
278: }
279:
280: public Object clone() {
281: MBCategoryImpl clone = new MBCategoryImpl();
282:
283: clone.setUuid(getUuid());
284: clone.setCategoryId(getCategoryId());
285: clone.setGroupId(getGroupId());
286: clone.setCompanyId(getCompanyId());
287: clone.setUserId(getUserId());
288: clone.setUserName(getUserName());
289: clone.setCreateDate(getCreateDate());
290: clone.setModifiedDate(getModifiedDate());
291: clone.setParentCategoryId(getParentCategoryId());
292: clone.setName(getName());
293: clone.setDescription(getDescription());
294: clone.setLastPostDate(getLastPostDate());
295:
296: return clone;
297: }
298:
299: public int compareTo(Object obj) {
300: if (obj == null) {
301: return -1;
302: }
303:
304: MBCategoryImpl mbCategory = (MBCategoryImpl) obj;
305:
306: int value = 0;
307:
308: if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
309: value = -1;
310: } else if (getParentCategoryId() > mbCategory
311: .getParentCategoryId()) {
312: value = 1;
313: } else {
314: value = 0;
315: }
316:
317: if (value != 0) {
318: return value;
319: }
320:
321: value = getName().toLowerCase().compareTo(
322: mbCategory.getName().toLowerCase());
323:
324: if (value != 0) {
325: return value;
326: }
327:
328: return 0;
329: }
330:
331: public boolean equals(Object obj) {
332: if (obj == null) {
333: return false;
334: }
335:
336: MBCategoryImpl mbCategory = null;
337:
338: try {
339: mbCategory = (MBCategoryImpl) obj;
340: } catch (ClassCastException cce) {
341: return false;
342: }
343:
344: long pk = mbCategory.getPrimaryKey();
345:
346: if (getPrimaryKey() == pk) {
347: return true;
348: } else {
349: return false;
350: }
351: }
352:
353: public int hashCode() {
354: return (int) getPrimaryKey();
355: }
356:
357: private String _uuid;
358: private long _categoryId;
359: private long _groupId;
360: private long _companyId;
361: private long _userId;
362: private String _userName;
363: private Date _createDate;
364: private Date _modifiedDate;
365: private long _parentCategoryId;
366: private String _name;
367: private String _description;
368: private Date _lastPostDate;
369: }
|