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