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