1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.messageboards.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
29  import com.liferay.portlet.messageboards.model.MBCategory;
30  import com.liferay.portlet.messageboards.model.MBCategorySoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="MBCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>MBCategory</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.messageboards.model.MBCategory
58   * @see com.liferay.portlet.messageboards.model.MBCategoryModel
59   * @see com.liferay.portlet.messageboards.model.impl.MBCategoryImpl
60   *
61   */
62  public class MBCategoryModelImpl extends BaseModelImpl<MBCategory> {
63      public static final String TABLE_NAME = "MBCategory";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "categoryId", new Integer(Types.BIGINT) },
69              
70  
71              { "groupId", new Integer(Types.BIGINT) },
72              
73  
74              { "companyId", new Integer(Types.BIGINT) },
75              
76  
77              { "userId", new Integer(Types.BIGINT) },
78              
79  
80              { "userName", new Integer(Types.VARCHAR) },
81              
82  
83              { "createDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "modifiedDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "parentCategoryId", new Integer(Types.BIGINT) },
90              
91  
92              { "name", new Integer(Types.VARCHAR) },
93              
94  
95              { "description", new Integer(Types.VARCHAR) },
96              
97  
98              { "threadCount", new Integer(Types.INTEGER) },
99              
100 
101             { "messageCount", new Integer(Types.INTEGER) },
102             
103 
104             { "lastPostDate", new Integer(Types.TIMESTAMP) }
105         };
106     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,threadCount INTEGER,messageCount INTEGER,lastPostDate DATE null)";
107     public static final String TABLE_SQL_DROP = "drop table MBCategory";
108     public static final String DATA_SOURCE = "liferayDataSource";
109     public static final String SESSION_FACTORY = "liferaySessionFactory";
110     public static final String TX_MANAGER = "liferayTransactionManager";
111     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
112                 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
113             true);
114     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
115                 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
116             true);
117 
118     public static MBCategory toModel(MBCategorySoap soapModel) {
119         MBCategory model = new MBCategoryImpl();
120 
121         model.setUuid(soapModel.getUuid());
122         model.setCategoryId(soapModel.getCategoryId());
123         model.setGroupId(soapModel.getGroupId());
124         model.setCompanyId(soapModel.getCompanyId());
125         model.setUserId(soapModel.getUserId());
126         model.setUserName(soapModel.getUserName());
127         model.setCreateDate(soapModel.getCreateDate());
128         model.setModifiedDate(soapModel.getModifiedDate());
129         model.setParentCategoryId(soapModel.getParentCategoryId());
130         model.setName(soapModel.getName());
131         model.setDescription(soapModel.getDescription());
132         model.setThreadCount(soapModel.getThreadCount());
133         model.setMessageCount(soapModel.getMessageCount());
134         model.setLastPostDate(soapModel.getLastPostDate());
135 
136         return model;
137     }
138 
139     public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
140         List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
141 
142         for (MBCategorySoap soapModel : soapModels) {
143             models.add(toModel(soapModel));
144         }
145 
146         return models;
147     }
148 
149     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
150                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
151 
152     public MBCategoryModelImpl() {
153     }
154 
155     public long getPrimaryKey() {
156         return _categoryId;
157     }
158 
159     public void setPrimaryKey(long pk) {
160         setCategoryId(pk);
161     }
162 
163     public Serializable getPrimaryKeyObj() {
164         return new Long(_categoryId);
165     }
166 
167     public String getUuid() {
168         return GetterUtil.getString(_uuid);
169     }
170 
171     public void setUuid(String uuid) {
172         _uuid = uuid;
173 
174         if (_originalUuid == null) {
175             _originalUuid = uuid;
176         }
177     }
178 
179     public String getOriginalUuid() {
180         return GetterUtil.getString(_originalUuid);
181     }
182 
183     public long getCategoryId() {
184         return _categoryId;
185     }
186 
187     public void setCategoryId(long categoryId) {
188         _categoryId = categoryId;
189     }
190 
191     public long getGroupId() {
192         return _groupId;
193     }
194 
195     public void setGroupId(long groupId) {
196         _groupId = groupId;
197 
198         if (!_setOriginalGroupId) {
199             _setOriginalGroupId = true;
200 
201             _originalGroupId = groupId;
202         }
203     }
204 
205     public long getOriginalGroupId() {
206         return _originalGroupId;
207     }
208 
209     public long getCompanyId() {
210         return _companyId;
211     }
212 
213     public void setCompanyId(long companyId) {
214         _companyId = companyId;
215     }
216 
217     public long getUserId() {
218         return _userId;
219     }
220 
221     public void setUserId(long userId) {
222         _userId = userId;
223     }
224 
225     public String getUserName() {
226         return GetterUtil.getString(_userName);
227     }
228 
229     public void setUserName(String userName) {
230         _userName = userName;
231     }
232 
233     public Date getCreateDate() {
234         return _createDate;
235     }
236 
237     public void setCreateDate(Date createDate) {
238         _createDate = createDate;
239     }
240 
241     public Date getModifiedDate() {
242         return _modifiedDate;
243     }
244 
245     public void setModifiedDate(Date modifiedDate) {
246         _modifiedDate = modifiedDate;
247     }
248 
249     public long getParentCategoryId() {
250         return _parentCategoryId;
251     }
252 
253     public void setParentCategoryId(long parentCategoryId) {
254         _parentCategoryId = parentCategoryId;
255     }
256 
257     public String getName() {
258         return GetterUtil.getString(_name);
259     }
260 
261     public void setName(String name) {
262         _name = name;
263     }
264 
265     public String getDescription() {
266         return GetterUtil.getString(_description);
267     }
268 
269     public void setDescription(String description) {
270         _description = description;
271     }
272 
273     public int getThreadCount() {
274         return _threadCount;
275     }
276 
277     public void setThreadCount(int threadCount) {
278         _threadCount = threadCount;
279     }
280 
281     public int getMessageCount() {
282         return _messageCount;
283     }
284 
285     public void setMessageCount(int messageCount) {
286         _messageCount = messageCount;
287     }
288 
289     public Date getLastPostDate() {
290         return _lastPostDate;
291     }
292 
293     public void setLastPostDate(Date lastPostDate) {
294         _lastPostDate = lastPostDate;
295     }
296 
297     public MBCategory toEscapedModel() {
298         if (isEscapedModel()) {
299             return (MBCategory)this;
300         }
301         else {
302             MBCategory model = new MBCategoryImpl();
303 
304             model.setNew(isNew());
305             model.setEscapedModel(true);
306 
307             model.setUuid(HtmlUtil.escape(getUuid()));
308             model.setCategoryId(getCategoryId());
309             model.setGroupId(getGroupId());
310             model.setCompanyId(getCompanyId());
311             model.setUserId(getUserId());
312             model.setUserName(HtmlUtil.escape(getUserName()));
313             model.setCreateDate(getCreateDate());
314             model.setModifiedDate(getModifiedDate());
315             model.setParentCategoryId(getParentCategoryId());
316             model.setName(HtmlUtil.escape(getName()));
317             model.setDescription(HtmlUtil.escape(getDescription()));
318             model.setThreadCount(getThreadCount());
319             model.setMessageCount(getMessageCount());
320             model.setLastPostDate(getLastPostDate());
321 
322             model = (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
323                     new Class[] { MBCategory.class },
324                     new ReadOnlyBeanHandler(model));
325 
326             return model;
327         }
328     }
329 
330     public ExpandoBridge getExpandoBridge() {
331         if (_expandoBridge == null) {
332             _expandoBridge = new ExpandoBridgeImpl(MBCategory.class.getName(),
333                     getPrimaryKey());
334         }
335 
336         return _expandoBridge;
337     }
338 
339     public Object clone() {
340         MBCategoryImpl clone = new MBCategoryImpl();
341 
342         clone.setUuid(getUuid());
343         clone.setCategoryId(getCategoryId());
344         clone.setGroupId(getGroupId());
345         clone.setCompanyId(getCompanyId());
346         clone.setUserId(getUserId());
347         clone.setUserName(getUserName());
348         clone.setCreateDate(getCreateDate());
349         clone.setModifiedDate(getModifiedDate());
350         clone.setParentCategoryId(getParentCategoryId());
351         clone.setName(getName());
352         clone.setDescription(getDescription());
353         clone.setThreadCount(getThreadCount());
354         clone.setMessageCount(getMessageCount());
355         clone.setLastPostDate(getLastPostDate());
356 
357         return clone;
358     }
359 
360     public int compareTo(MBCategory mbCategory) {
361         int value = 0;
362 
363         if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
364             value = -1;
365         }
366         else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
367             value = 1;
368         }
369         else {
370             value = 0;
371         }
372 
373         if (value != 0) {
374             return value;
375         }
376 
377         value = getName().toLowerCase()
378                     .compareTo(mbCategory.getName().toLowerCase());
379 
380         if (value != 0) {
381             return value;
382         }
383 
384         return 0;
385     }
386 
387     public boolean equals(Object obj) {
388         if (obj == null) {
389             return false;
390         }
391 
392         MBCategory mbCategory = null;
393 
394         try {
395             mbCategory = (MBCategory)obj;
396         }
397         catch (ClassCastException cce) {
398             return false;
399         }
400 
401         long pk = mbCategory.getPrimaryKey();
402 
403         if (getPrimaryKey() == pk) {
404             return true;
405         }
406         else {
407             return false;
408         }
409     }
410 
411     public int hashCode() {
412         return (int)getPrimaryKey();
413     }
414 
415     public String toString() {
416         StringBuilder sb = new StringBuilder();
417 
418         sb.append("{uuid=");
419         sb.append(getUuid());
420         sb.append(", categoryId=");
421         sb.append(getCategoryId());
422         sb.append(", groupId=");
423         sb.append(getGroupId());
424         sb.append(", companyId=");
425         sb.append(getCompanyId());
426         sb.append(", userId=");
427         sb.append(getUserId());
428         sb.append(", userName=");
429         sb.append(getUserName());
430         sb.append(", createDate=");
431         sb.append(getCreateDate());
432         sb.append(", modifiedDate=");
433         sb.append(getModifiedDate());
434         sb.append(", parentCategoryId=");
435         sb.append(getParentCategoryId());
436         sb.append(", name=");
437         sb.append(getName());
438         sb.append(", description=");
439         sb.append(getDescription());
440         sb.append(", threadCount=");
441         sb.append(getThreadCount());
442         sb.append(", messageCount=");
443         sb.append(getMessageCount());
444         sb.append(", lastPostDate=");
445         sb.append(getLastPostDate());
446         sb.append("}");
447 
448         return sb.toString();
449     }
450 
451     public String toXmlString() {
452         StringBuilder sb = new StringBuilder();
453 
454         sb.append("<model><model-name>");
455         sb.append("com.liferay.portlet.messageboards.model.MBCategory");
456         sb.append("</model-name>");
457 
458         sb.append(
459             "<column><column-name>uuid</column-name><column-value><![CDATA[");
460         sb.append(getUuid());
461         sb.append("]]></column-value></column>");
462         sb.append(
463             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
464         sb.append(getCategoryId());
465         sb.append("]]></column-value></column>");
466         sb.append(
467             "<column><column-name>groupId</column-name><column-value><![CDATA[");
468         sb.append(getGroupId());
469         sb.append("]]></column-value></column>");
470         sb.append(
471             "<column><column-name>companyId</column-name><column-value><![CDATA[");
472         sb.append(getCompanyId());
473         sb.append("]]></column-value></column>");
474         sb.append(
475             "<column><column-name>userId</column-name><column-value><![CDATA[");
476         sb.append(getUserId());
477         sb.append("]]></column-value></column>");
478         sb.append(
479             "<column><column-name>userName</column-name><column-value><![CDATA[");
480         sb.append(getUserName());
481         sb.append("]]></column-value></column>");
482         sb.append(
483             "<column><column-name>createDate</column-name><column-value><![CDATA[");
484         sb.append(getCreateDate());
485         sb.append("]]></column-value></column>");
486         sb.append(
487             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
488         sb.append(getModifiedDate());
489         sb.append("]]></column-value></column>");
490         sb.append(
491             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
492         sb.append(getParentCategoryId());
493         sb.append("]]></column-value></column>");
494         sb.append(
495             "<column><column-name>name</column-name><column-value><![CDATA[");
496         sb.append(getName());
497         sb.append("]]></column-value></column>");
498         sb.append(
499             "<column><column-name>description</column-name><column-value><![CDATA[");
500         sb.append(getDescription());
501         sb.append("]]></column-value></column>");
502         sb.append(
503             "<column><column-name>threadCount</column-name><column-value><![CDATA[");
504         sb.append(getThreadCount());
505         sb.append("]]></column-value></column>");
506         sb.append(
507             "<column><column-name>messageCount</column-name><column-value><![CDATA[");
508         sb.append(getMessageCount());
509         sb.append("]]></column-value></column>");
510         sb.append(
511             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
512         sb.append(getLastPostDate());
513         sb.append("]]></column-value></column>");
514 
515         sb.append("</model>");
516 
517         return sb.toString();
518     }
519 
520     private String _uuid;
521     private String _originalUuid;
522     private long _categoryId;
523     private long _groupId;
524     private long _originalGroupId;
525     private boolean _setOriginalGroupId;
526     private long _companyId;
527     private long _userId;
528     private String _userName;
529     private Date _createDate;
530     private Date _modifiedDate;
531     private long _parentCategoryId;
532     private String _name;
533     private String _description;
534     private int _threadCount;
535     private int _messageCount;
536     private Date _lastPostDate;
537     private transient ExpandoBridge _expandoBridge;
538 }