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.kernel.util.StringPool;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.social.model.SocialRequest;
33  import com.liferay.portlet.social.model.SocialRequestSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="SocialRequestModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>SocialRequest</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.social.model.SocialRequest
61   * @see com.liferay.portlet.social.model.SocialRequestModel
62   * @see com.liferay.portlet.social.model.impl.SocialRequestImpl
63   *
64   */
65  public class SocialRequestModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "SocialRequest";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "uuid_", new Integer(Types.VARCHAR) },
69              
70  
71              { "requestId", new Integer(Types.BIGINT) },
72              
73  
74              { "groupId", new Integer(Types.BIGINT) },
75              
76  
77              { "companyId", new Integer(Types.BIGINT) },
78              
79  
80              { "userId", new Integer(Types.BIGINT) },
81              
82  
83              { "createDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "modifiedDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "classNameId", new Integer(Types.BIGINT) },
90              
91  
92              { "classPK", new Integer(Types.BIGINT) },
93              
94  
95              { "type_", new Integer(Types.INTEGER) },
96              
97  
98              { "extraData", new Integer(Types.VARCHAR) },
99              
100 
101             { "receiverUserId", new Integer(Types.BIGINT) },
102             
103 
104             { "status", new Integer(Types.INTEGER) }
105         };
106     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)";
107     public static final String TABLE_SQL_DROP = "drop table SocialRequest";
108     public static final String DATA_SOURCE = "liferayDataSource";
109     public static final String SESSION_FACTORY = "liferaySessionFactory";
110     public static final String TX_MANAGER = "liferayTransactionManager";
111     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
112                 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRequest"),
113             true);
114 
115     public static SocialRequest toModel(SocialRequestSoap soapModel) {
116         SocialRequest model = new SocialRequestImpl();
117 
118         model.setUuid(soapModel.getUuid());
119         model.setRequestId(soapModel.getRequestId());
120         model.setGroupId(soapModel.getGroupId());
121         model.setCompanyId(soapModel.getCompanyId());
122         model.setUserId(soapModel.getUserId());
123         model.setCreateDate(soapModel.getCreateDate());
124         model.setModifiedDate(soapModel.getModifiedDate());
125         model.setClassNameId(soapModel.getClassNameId());
126         model.setClassPK(soapModel.getClassPK());
127         model.setType(soapModel.getType());
128         model.setExtraData(soapModel.getExtraData());
129         model.setReceiverUserId(soapModel.getReceiverUserId());
130         model.setStatus(soapModel.getStatus());
131 
132         return model;
133     }
134 
135     public static List<SocialRequest> toModels(SocialRequestSoap[] soapModels) {
136         List<SocialRequest> models = new ArrayList<SocialRequest>(soapModels.length);
137 
138         for (SocialRequestSoap soapModel : soapModels) {
139             models.add(toModel(soapModel));
140         }
141 
142         return models;
143     }
144 
145     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
146                 "lock.expiration.time.com.liferay.portlet.social.model.SocialRequest"));
147 
148     public SocialRequestModelImpl() {
149     }
150 
151     public long getPrimaryKey() {
152         return _requestId;
153     }
154 
155     public void setPrimaryKey(long pk) {
156         setRequestId(pk);
157     }
158 
159     public Serializable getPrimaryKeyObj() {
160         return new Long(_requestId);
161     }
162 
163     public String getUuid() {
164         return GetterUtil.getString(_uuid);
165     }
166 
167     public void setUuid(String uuid) {
168         if ((uuid != null) && (uuid != _uuid)) {
169             _uuid = uuid;
170         }
171     }
172 
173     public long getRequestId() {
174         return _requestId;
175     }
176 
177     public void setRequestId(long requestId) {
178         if (requestId != _requestId) {
179             _requestId = requestId;
180         }
181     }
182 
183     public long getGroupId() {
184         return _groupId;
185     }
186 
187     public void setGroupId(long groupId) {
188         if (groupId != _groupId) {
189             _groupId = groupId;
190         }
191     }
192 
193     public long getCompanyId() {
194         return _companyId;
195     }
196 
197     public void setCompanyId(long companyId) {
198         if (companyId != _companyId) {
199             _companyId = companyId;
200         }
201     }
202 
203     public long getUserId() {
204         return _userId;
205     }
206 
207     public void setUserId(long userId) {
208         if (userId != _userId) {
209             _userId = userId;
210         }
211     }
212 
213     public Date getCreateDate() {
214         return _createDate;
215     }
216 
217     public void setCreateDate(Date createDate) {
218         if (((createDate == null) && (_createDate != null)) ||
219                 ((createDate != null) && (_createDate == null)) ||
220                 ((createDate != null) && (_createDate != null) &&
221                 !createDate.equals(_createDate))) {
222             _createDate = createDate;
223         }
224     }
225 
226     public Date getModifiedDate() {
227         return _modifiedDate;
228     }
229 
230     public void setModifiedDate(Date modifiedDate) {
231         if (((modifiedDate == null) && (_modifiedDate != null)) ||
232                 ((modifiedDate != null) && (_modifiedDate == null)) ||
233                 ((modifiedDate != null) && (_modifiedDate != null) &&
234                 !modifiedDate.equals(_modifiedDate))) {
235             _modifiedDate = modifiedDate;
236         }
237     }
238 
239     public String getClassName() {
240         if (getClassNameId() <= 0) {
241             return StringPool.BLANK;
242         }
243 
244         return PortalUtil.getClassName(getClassNameId());
245     }
246 
247     public long getClassNameId() {
248         return _classNameId;
249     }
250 
251     public void setClassNameId(long classNameId) {
252         if (classNameId != _classNameId) {
253             _classNameId = classNameId;
254         }
255     }
256 
257     public long getClassPK() {
258         return _classPK;
259     }
260 
261     public void setClassPK(long classPK) {
262         if (classPK != _classPK) {
263             _classPK = classPK;
264         }
265     }
266 
267     public int getType() {
268         return _type;
269     }
270 
271     public void setType(int type) {
272         if (type != _type) {
273             _type = type;
274         }
275     }
276 
277     public String getExtraData() {
278         return GetterUtil.getString(_extraData);
279     }
280 
281     public void setExtraData(String extraData) {
282         if (((extraData == null) && (_extraData != null)) ||
283                 ((extraData != null) && (_extraData == null)) ||
284                 ((extraData != null) && (_extraData != null) &&
285                 !extraData.equals(_extraData))) {
286             _extraData = extraData;
287         }
288     }
289 
290     public long getReceiverUserId() {
291         return _receiverUserId;
292     }
293 
294     public void setReceiverUserId(long receiverUserId) {
295         if (receiverUserId != _receiverUserId) {
296             _receiverUserId = receiverUserId;
297         }
298     }
299 
300     public int getStatus() {
301         return _status;
302     }
303 
304     public void setStatus(int status) {
305         if (status != _status) {
306             _status = status;
307         }
308     }
309 
310     public SocialRequest toEscapedModel() {
311         if (isEscapedModel()) {
312             return (SocialRequest)this;
313         }
314         else {
315             SocialRequest model = new SocialRequestImpl();
316 
317             model.setNew(isNew());
318             model.setEscapedModel(true);
319 
320             model.setUuid(HtmlUtil.escape(getUuid()));
321             model.setRequestId(getRequestId());
322             model.setGroupId(getGroupId());
323             model.setCompanyId(getCompanyId());
324             model.setUserId(getUserId());
325             model.setCreateDate(getCreateDate());
326             model.setModifiedDate(getModifiedDate());
327             model.setClassNameId(getClassNameId());
328             model.setClassPK(getClassPK());
329             model.setType(getType());
330             model.setExtraData(HtmlUtil.escape(getExtraData()));
331             model.setReceiverUserId(getReceiverUserId());
332             model.setStatus(getStatus());
333 
334             model = (SocialRequest)Proxy.newProxyInstance(SocialRequest.class.getClassLoader(),
335                     new Class[] { SocialRequest.class },
336                     new ReadOnlyBeanHandler(model));
337 
338             return model;
339         }
340     }
341 
342     public Object clone() {
343         SocialRequestImpl clone = new SocialRequestImpl();
344 
345         clone.setUuid(getUuid());
346         clone.setRequestId(getRequestId());
347         clone.setGroupId(getGroupId());
348         clone.setCompanyId(getCompanyId());
349         clone.setUserId(getUserId());
350         clone.setCreateDate(getCreateDate());
351         clone.setModifiedDate(getModifiedDate());
352         clone.setClassNameId(getClassNameId());
353         clone.setClassPK(getClassPK());
354         clone.setType(getType());
355         clone.setExtraData(getExtraData());
356         clone.setReceiverUserId(getReceiverUserId());
357         clone.setStatus(getStatus());
358 
359         return clone;
360     }
361 
362     public int compareTo(Object obj) {
363         if (obj == null) {
364             return -1;
365         }
366 
367         SocialRequestImpl socialRequest = (SocialRequestImpl)obj;
368 
369         int value = 0;
370 
371         if (getRequestId() < socialRequest.getRequestId()) {
372             value = -1;
373         }
374         else if (getRequestId() > socialRequest.getRequestId()) {
375             value = 1;
376         }
377         else {
378             value = 0;
379         }
380 
381         value = value * -1;
382 
383         if (value != 0) {
384             return value;
385         }
386 
387         return 0;
388     }
389 
390     public boolean equals(Object obj) {
391         if (obj == null) {
392             return false;
393         }
394 
395         SocialRequestImpl socialRequest = null;
396 
397         try {
398             socialRequest = (SocialRequestImpl)obj;
399         }
400         catch (ClassCastException cce) {
401             return false;
402         }
403 
404         long pk = socialRequest.getPrimaryKey();
405 
406         if (getPrimaryKey() == pk) {
407             return true;
408         }
409         else {
410             return false;
411         }
412     }
413 
414     public int hashCode() {
415         return (int)getPrimaryKey();
416     }
417 
418     private String _uuid;
419     private long _requestId;
420     private long _groupId;
421     private long _companyId;
422     private long _userId;
423     private Date _createDate;
424     private Date _modifiedDate;
425     private long _classNameId;
426     private long _classPK;
427     private int _type;
428     private String _extraData;
429     private long _receiverUserId;
430     private int _status;
431 }