1   /**
2    * Copyright (c) 2000-2008 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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
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.service.model.SocialRequest
60   * @see com.liferay.portlet.social.service.model.SocialRequestModel
61   * @see com.liferay.portlet.social.service.model.impl.SocialRequestImpl
62   *
63   */
64  public class SocialRequestModelImpl extends BaseModelImpl {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
111                 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRequest"),
112             true);
113 
114     public static SocialRequest toModel(SocialRequestSoap soapModel) {
115         SocialRequest model = new SocialRequestImpl();
116 
117         model.setUuid(soapModel.getUuid());
118         model.setRequestId(soapModel.getRequestId());
119         model.setGroupId(soapModel.getGroupId());
120         model.setCompanyId(soapModel.getCompanyId());
121         model.setUserId(soapModel.getUserId());
122         model.setCreateDate(soapModel.getCreateDate());
123         model.setModifiedDate(soapModel.getModifiedDate());
124         model.setClassNameId(soapModel.getClassNameId());
125         model.setClassPK(soapModel.getClassPK());
126         model.setType(soapModel.getType());
127         model.setExtraData(soapModel.getExtraData());
128         model.setReceiverUserId(soapModel.getReceiverUserId());
129         model.setStatus(soapModel.getStatus());
130 
131         return model;
132     }
133 
134     public static List<SocialRequest> toModels(SocialRequestSoap[] soapModels) {
135         List<SocialRequest> models = new ArrayList<SocialRequest>(soapModels.length);
136 
137         for (SocialRequestSoap soapModel : soapModels) {
138             models.add(toModel(soapModel));
139         }
140 
141         return models;
142     }
143 
144     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
145                 "lock.expiration.time.com.liferay.portlet.social.model.SocialRequest"));
146 
147     public SocialRequestModelImpl() {
148     }
149 
150     public long getPrimaryKey() {
151         return _requestId;
152     }
153 
154     public void setPrimaryKey(long pk) {
155         setRequestId(pk);
156     }
157 
158     public Serializable getPrimaryKeyObj() {
159         return new Long(_requestId);
160     }
161 
162     public String getUuid() {
163         return GetterUtil.getString(_uuid);
164     }
165 
166     public void setUuid(String uuid) {
167         if ((uuid != null) && (uuid != _uuid)) {
168             _uuid = uuid;
169         }
170     }
171 
172     public long getRequestId() {
173         return _requestId;
174     }
175 
176     public void setRequestId(long requestId) {
177         if (requestId != _requestId) {
178             _requestId = requestId;
179         }
180     }
181 
182     public long getGroupId() {
183         return _groupId;
184     }
185 
186     public void setGroupId(long groupId) {
187         if (groupId != _groupId) {
188             _groupId = groupId;
189         }
190     }
191 
192     public long getCompanyId() {
193         return _companyId;
194     }
195 
196     public void setCompanyId(long companyId) {
197         if (companyId != _companyId) {
198             _companyId = companyId;
199         }
200     }
201 
202     public long getUserId() {
203         return _userId;
204     }
205 
206     public void setUserId(long userId) {
207         if (userId != _userId) {
208             _userId = userId;
209         }
210     }
211 
212     public Date getCreateDate() {
213         return _createDate;
214     }
215 
216     public void setCreateDate(Date createDate) {
217         if (((createDate == null) && (_createDate != null)) ||
218                 ((createDate != null) && (_createDate == null)) ||
219                 ((createDate != null) && (_createDate != null) &&
220                 !createDate.equals(_createDate))) {
221             _createDate = createDate;
222         }
223     }
224 
225     public Date getModifiedDate() {
226         return _modifiedDate;
227     }
228 
229     public void setModifiedDate(Date modifiedDate) {
230         if (((modifiedDate == null) && (_modifiedDate != null)) ||
231                 ((modifiedDate != null) && (_modifiedDate == null)) ||
232                 ((modifiedDate != null) && (_modifiedDate != null) &&
233                 !modifiedDate.equals(_modifiedDate))) {
234             _modifiedDate = modifiedDate;
235         }
236     }
237 
238     public String getClassName() {
239         return PortalUtil.getClassName(getClassNameId());
240     }
241 
242     public long getClassNameId() {
243         return _classNameId;
244     }
245 
246     public void setClassNameId(long classNameId) {
247         if (classNameId != _classNameId) {
248             _classNameId = classNameId;
249         }
250     }
251 
252     public long getClassPK() {
253         return _classPK;
254     }
255 
256     public void setClassPK(long classPK) {
257         if (classPK != _classPK) {
258             _classPK = classPK;
259         }
260     }
261 
262     public int getType() {
263         return _type;
264     }
265 
266     public void setType(int type) {
267         if (type != _type) {
268             _type = type;
269         }
270     }
271 
272     public String getExtraData() {
273         return GetterUtil.getString(_extraData);
274     }
275 
276     public void setExtraData(String extraData) {
277         if (((extraData == null) && (_extraData != null)) ||
278                 ((extraData != null) && (_extraData == null)) ||
279                 ((extraData != null) && (_extraData != null) &&
280                 !extraData.equals(_extraData))) {
281             _extraData = extraData;
282         }
283     }
284 
285     public long getReceiverUserId() {
286         return _receiverUserId;
287     }
288 
289     public void setReceiverUserId(long receiverUserId) {
290         if (receiverUserId != _receiverUserId) {
291             _receiverUserId = receiverUserId;
292         }
293     }
294 
295     public int getStatus() {
296         return _status;
297     }
298 
299     public void setStatus(int status) {
300         if (status != _status) {
301             _status = status;
302         }
303     }
304 
305     public SocialRequest toEscapedModel() {
306         if (isEscapedModel()) {
307             return (SocialRequest)this;
308         }
309         else {
310             SocialRequest model = new SocialRequestImpl();
311 
312             model.setEscapedModel(true);
313 
314             model.setUuid(HtmlUtil.escape(getUuid()));
315             model.setRequestId(getRequestId());
316             model.setGroupId(getGroupId());
317             model.setCompanyId(getCompanyId());
318             model.setUserId(getUserId());
319             model.setCreateDate(getCreateDate());
320             model.setModifiedDate(getModifiedDate());
321             model.setClassNameId(getClassNameId());
322             model.setClassPK(getClassPK());
323             model.setType(getType());
324             model.setExtraData(HtmlUtil.escape(getExtraData()));
325             model.setReceiverUserId(getReceiverUserId());
326             model.setStatus(getStatus());
327 
328             model = (SocialRequest)Proxy.newProxyInstance(SocialRequest.class.getClassLoader(),
329                     new Class[] { SocialRequest.class },
330                     new ReadOnlyBeanHandler(model));
331 
332             return model;
333         }
334     }
335 
336     public Object clone() {
337         SocialRequestImpl clone = new SocialRequestImpl();
338 
339         clone.setUuid(getUuid());
340         clone.setRequestId(getRequestId());
341         clone.setGroupId(getGroupId());
342         clone.setCompanyId(getCompanyId());
343         clone.setUserId(getUserId());
344         clone.setCreateDate(getCreateDate());
345         clone.setModifiedDate(getModifiedDate());
346         clone.setClassNameId(getClassNameId());
347         clone.setClassPK(getClassPK());
348         clone.setType(getType());
349         clone.setExtraData(getExtraData());
350         clone.setReceiverUserId(getReceiverUserId());
351         clone.setStatus(getStatus());
352 
353         return clone;
354     }
355 
356     public int compareTo(Object obj) {
357         if (obj == null) {
358             return -1;
359         }
360 
361         SocialRequestImpl socialRequest = (SocialRequestImpl)obj;
362 
363         int value = 0;
364 
365         if (getRequestId() < socialRequest.getRequestId()) {
366             value = -1;
367         }
368         else if (getRequestId() > socialRequest.getRequestId()) {
369             value = 1;
370         }
371         else {
372             value = 0;
373         }
374 
375         value = value * -1;
376 
377         if (value != 0) {
378             return value;
379         }
380 
381         return 0;
382     }
383 
384     public boolean equals(Object obj) {
385         if (obj == null) {
386             return false;
387         }
388 
389         SocialRequestImpl socialRequest = null;
390 
391         try {
392             socialRequest = (SocialRequestImpl)obj;
393         }
394         catch (ClassCastException cce) {
395             return false;
396         }
397 
398         long pk = socialRequest.getPrimaryKey();
399 
400         if (getPrimaryKey() == pk) {
401             return true;
402         }
403         else {
404             return false;
405         }
406     }
407 
408     public int hashCode() {
409         return (int)getPrimaryKey();
410     }
411 
412     private String _uuid;
413     private long _requestId;
414     private long _groupId;
415     private long _companyId;
416     private long _userId;
417     private Date _createDate;
418     private Date _modifiedDate;
419     private long _classNameId;
420     private long _classPK;
421     private int _type;
422     private String _extraData;
423     private long _receiverUserId;
424     private int _status;
425 }