1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.model.impl;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  import java.util.Date;
36  
37  /**
38   * <a href="MBCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>MBCategory</code> table in the
47   * database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.messageboards.service.model.MBCategory
53   * @see com.liferay.portlet.messageboards.service.model.MBCategoryModel
54   * @see com.liferay.portlet.messageboards.service.model.impl.MBCategoryImpl
55   *
56   */
57  public class MBCategoryModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "MBCategory";
59      public static Object[][] TABLE_COLUMNS = {
60              { "categoryId", new Integer(Types.BIGINT) },
61              { "groupId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "userId", new Integer(Types.BIGINT) },
64              { "userName", new Integer(Types.VARCHAR) },
65              { "createDate", new Integer(Types.TIMESTAMP) },
66              { "modifiedDate", new Integer(Types.TIMESTAMP) },
67              { "parentCategoryId", new Integer(Types.BIGINT) },
68              { "name", new Integer(Types.VARCHAR) },
69              { "description", new Integer(Types.VARCHAR) },
70              { "lastPostDate", new Integer(Types.TIMESTAMP) }
71          };
72      public static String TABLE_SQL_CREATE = "create table MBCategory (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)";
73      public static String TABLE_SQL_DROP = "drop table MBCategory";
74      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
75                  "xss.allow.com.liferay.portlet.messageboards.model.MBCategory"),
76              XSS_ALLOW);
77      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
78                  "xss.allow.com.liferay.portlet.messageboards.model.MBCategory.userName"),
79              XSS_ALLOW_BY_MODEL);
80      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
81                  "xss.allow.com.liferay.portlet.messageboards.model.MBCategory.name"),
82              XSS_ALLOW_BY_MODEL);
83      public static boolean XSS_ALLOW_DESCRIPTION = GetterUtil.getBoolean(PropsUtil.get(
84                  "xss.allow.com.liferay.portlet.messageboards.model.MBCategory.description"),
85              XSS_ALLOW_BY_MODEL);
86      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
87                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategoryModel"));
88  
89      public MBCategoryModelImpl() {
90      }
91  
92      public long getPrimaryKey() {
93          return _categoryId;
94      }
95  
96      public void setPrimaryKey(long pk) {
97          setCategoryId(pk);
98      }
99  
100     public Serializable getPrimaryKeyObj() {
101         return new Long(_categoryId);
102     }
103 
104     public long getCategoryId() {
105         return _categoryId;
106     }
107 
108     public void setCategoryId(long categoryId) {
109         if (categoryId != _categoryId) {
110             _categoryId = categoryId;
111         }
112     }
113 
114     public long getGroupId() {
115         return _groupId;
116     }
117 
118     public void setGroupId(long groupId) {
119         if (groupId != _groupId) {
120             _groupId = groupId;
121         }
122     }
123 
124     public long getCompanyId() {
125         return _companyId;
126     }
127 
128     public void setCompanyId(long companyId) {
129         if (companyId != _companyId) {
130             _companyId = companyId;
131         }
132     }
133 
134     public long getUserId() {
135         return _userId;
136     }
137 
138     public void setUserId(long userId) {
139         if (userId != _userId) {
140             _userId = userId;
141         }
142     }
143 
144     public String getUserName() {
145         return GetterUtil.getString(_userName);
146     }
147 
148     public void setUserName(String userName) {
149         if (((userName == null) && (_userName != null)) ||
150                 ((userName != null) && (_userName == null)) ||
151                 ((userName != null) && (_userName != null) &&
152                 !userName.equals(_userName))) {
153             if (!XSS_ALLOW_USERNAME) {
154                 userName = XSSUtil.strip(userName);
155             }
156 
157             _userName = userName;
158         }
159     }
160 
161     public Date getCreateDate() {
162         return _createDate;
163     }
164 
165     public void setCreateDate(Date createDate) {
166         if (((createDate == null) && (_createDate != null)) ||
167                 ((createDate != null) && (_createDate == null)) ||
168                 ((createDate != null) && (_createDate != null) &&
169                 !createDate.equals(_createDate))) {
170             _createDate = createDate;
171         }
172     }
173 
174     public Date getModifiedDate() {
175         return _modifiedDate;
176     }
177 
178     public void setModifiedDate(Date modifiedDate) {
179         if (((modifiedDate == null) && (_modifiedDate != null)) ||
180                 ((modifiedDate != null) && (_modifiedDate == null)) ||
181                 ((modifiedDate != null) && (_modifiedDate != null) &&
182                 !modifiedDate.equals(_modifiedDate))) {
183             _modifiedDate = modifiedDate;
184         }
185     }
186 
187     public long getParentCategoryId() {
188         return _parentCategoryId;
189     }
190 
191     public void setParentCategoryId(long parentCategoryId) {
192         if (parentCategoryId != _parentCategoryId) {
193             _parentCategoryId = parentCategoryId;
194         }
195     }
196 
197     public String getName() {
198         return GetterUtil.getString(_name);
199     }
200 
201     public void setName(String name) {
202         if (((name == null) && (_name != null)) ||
203                 ((name != null) && (_name == null)) ||
204                 ((name != null) && (_name != null) && !name.equals(_name))) {
205             if (!XSS_ALLOW_NAME) {
206                 name = XSSUtil.strip(name);
207             }
208 
209             _name = name;
210         }
211     }
212 
213     public String getDescription() {
214         return GetterUtil.getString(_description);
215     }
216 
217     public void setDescription(String description) {
218         if (((description == null) && (_description != null)) ||
219                 ((description != null) && (_description == null)) ||
220                 ((description != null) && (_description != null) &&
221                 !description.equals(_description))) {
222             if (!XSS_ALLOW_DESCRIPTION) {
223                 description = XSSUtil.strip(description);
224             }
225 
226             _description = description;
227         }
228     }
229 
230     public Date getLastPostDate() {
231         return _lastPostDate;
232     }
233 
234     public void setLastPostDate(Date lastPostDate) {
235         if (((lastPostDate == null) && (_lastPostDate != null)) ||
236                 ((lastPostDate != null) && (_lastPostDate == null)) ||
237                 ((lastPostDate != null) && (_lastPostDate != null) &&
238                 !lastPostDate.equals(_lastPostDate))) {
239             _lastPostDate = lastPostDate;
240         }
241     }
242 
243     public Object clone() {
244         MBCategoryImpl clone = new MBCategoryImpl();
245         clone.setCategoryId(getCategoryId());
246         clone.setGroupId(getGroupId());
247         clone.setCompanyId(getCompanyId());
248         clone.setUserId(getUserId());
249         clone.setUserName(getUserName());
250         clone.setCreateDate(getCreateDate());
251         clone.setModifiedDate(getModifiedDate());
252         clone.setParentCategoryId(getParentCategoryId());
253         clone.setName(getName());
254         clone.setDescription(getDescription());
255         clone.setLastPostDate(getLastPostDate());
256 
257         return clone;
258     }
259 
260     public int compareTo(Object obj) {
261         if (obj == null) {
262             return -1;
263         }
264 
265         MBCategoryImpl mbCategory = (MBCategoryImpl)obj;
266         int value = 0;
267 
268         if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
269             value = -1;
270         }
271         else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
272             value = 1;
273         }
274         else {
275             value = 0;
276         }
277 
278         if (value != 0) {
279             return value;
280         }
281 
282         value = getName().toLowerCase().compareTo(mbCategory.getName()
283                                                             .toLowerCase());
284 
285         if (value != 0) {
286             return value;
287         }
288 
289         return 0;
290     }
291 
292     public boolean equals(Object obj) {
293         if (obj == null) {
294             return false;
295         }
296 
297         MBCategoryImpl mbCategory = null;
298 
299         try {
300             mbCategory = (MBCategoryImpl)obj;
301         }
302         catch (ClassCastException cce) {
303             return false;
304         }
305 
306         long pk = mbCategory.getPrimaryKey();
307 
308         if (getPrimaryKey() == pk) {
309             return true;
310         }
311         else {
312             return false;
313         }
314     }
315 
316     public int hashCode() {
317         return (int)getPrimaryKey();
318     }
319 
320     private long _categoryId;
321     private long _groupId;
322     private long _companyId;
323     private long _userId;
324     private String _userName;
325     private Date _createDate;
326     private Date _modifiedDate;
327     private long _parentCategoryId;
328     private String _name;
329     private String _description;
330     private Date _lastPostDate;
331 }