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