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