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