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