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.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.social.model.SocialActivity;
33  import com.liferay.portlet.social.model.SocialActivitySoap;
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="SocialActivityModelImpl.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>SocialActivity</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.social.service.model.SocialActivity
61   * @see com.liferay.portlet.social.service.model.SocialActivityModel
62   * @see com.liferay.portlet.social.service.model.impl.SocialActivityImpl
63   *
64   */
65  public class SocialActivityModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "SocialActivity";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "activityId", 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              { "mirrorActivityId", new Integer(Types.BIGINT) },
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     public static final String TABLE_SQL_CREATE = "create table SocialActivity (activityId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,mirrorActivityId LONG,classNameId LONG,classPK LONG,type_ INTEGER,extraData STRING null,receiverUserId LONG)";
101     public static final String TABLE_SQL_DROP = "drop table SocialActivity";
102     public static final String DATA_SOURCE = "liferayDataSource";
103     public static final String SESSION_FACTORY = "liferaySessionFactory";
104     public static final String TX_MANAGER = "liferayTransactionManager";
105     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106                 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialActivity"),
107             true);
108 
109     public static SocialActivity toModel(SocialActivitySoap soapModel) {
110         SocialActivity model = new SocialActivityImpl();
111 
112         model.setActivityId(soapModel.getActivityId());
113         model.setGroupId(soapModel.getGroupId());
114         model.setCompanyId(soapModel.getCompanyId());
115         model.setUserId(soapModel.getUserId());
116         model.setCreateDate(soapModel.getCreateDate());
117         model.setMirrorActivityId(soapModel.getMirrorActivityId());
118         model.setClassNameId(soapModel.getClassNameId());
119         model.setClassPK(soapModel.getClassPK());
120         model.setType(soapModel.getType());
121         model.setExtraData(soapModel.getExtraData());
122         model.setReceiverUserId(soapModel.getReceiverUserId());
123 
124         return model;
125     }
126 
127     public static List<SocialActivity> toModels(SocialActivitySoap[] soapModels) {
128         List<SocialActivity> models = new ArrayList<SocialActivity>(soapModels.length);
129 
130         for (SocialActivitySoap soapModel : soapModels) {
131             models.add(toModel(soapModel));
132         }
133 
134         return models;
135     }
136 
137     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
138                 "lock.expiration.time.com.liferay.portlet.social.model.SocialActivity"));
139 
140     public SocialActivityModelImpl() {
141     }
142 
143     public long getPrimaryKey() {
144         return _activityId;
145     }
146 
147     public void setPrimaryKey(long pk) {
148         setActivityId(pk);
149     }
150 
151     public Serializable getPrimaryKeyObj() {
152         return new Long(_activityId);
153     }
154 
155     public long getActivityId() {
156         return _activityId;
157     }
158 
159     public void setActivityId(long activityId) {
160         if (activityId != _activityId) {
161             _activityId = activityId;
162         }
163     }
164 
165     public long getGroupId() {
166         return _groupId;
167     }
168 
169     public void setGroupId(long groupId) {
170         if (groupId != _groupId) {
171             _groupId = groupId;
172         }
173     }
174 
175     public long getCompanyId() {
176         return _companyId;
177     }
178 
179     public void setCompanyId(long companyId) {
180         if (companyId != _companyId) {
181             _companyId = companyId;
182         }
183     }
184 
185     public long getUserId() {
186         return _userId;
187     }
188 
189     public void setUserId(long userId) {
190         if (userId != _userId) {
191             _userId = userId;
192         }
193     }
194 
195     public Date getCreateDate() {
196         return _createDate;
197     }
198 
199     public void setCreateDate(Date createDate) {
200         if (((createDate == null) && (_createDate != null)) ||
201                 ((createDate != null) && (_createDate == null)) ||
202                 ((createDate != null) && (_createDate != null) &&
203                 !createDate.equals(_createDate))) {
204             _createDate = createDate;
205         }
206     }
207 
208     public long getMirrorActivityId() {
209         return _mirrorActivityId;
210     }
211 
212     public void setMirrorActivityId(long mirrorActivityId) {
213         if (mirrorActivityId != _mirrorActivityId) {
214             _mirrorActivityId = mirrorActivityId;
215         }
216     }
217 
218     public String getClassName() {
219         return PortalUtil.getClassName(getClassNameId());
220     }
221 
222     public long getClassNameId() {
223         return _classNameId;
224     }
225 
226     public void setClassNameId(long classNameId) {
227         if (classNameId != _classNameId) {
228             _classNameId = classNameId;
229         }
230     }
231 
232     public long getClassPK() {
233         return _classPK;
234     }
235 
236     public void setClassPK(long classPK) {
237         if (classPK != _classPK) {
238             _classPK = classPK;
239         }
240     }
241 
242     public int getType() {
243         return _type;
244     }
245 
246     public void setType(int type) {
247         if (type != _type) {
248             _type = type;
249         }
250     }
251 
252     public String getExtraData() {
253         return GetterUtil.getString(_extraData);
254     }
255 
256     public void setExtraData(String extraData) {
257         if (((extraData == null) && (_extraData != null)) ||
258                 ((extraData != null) && (_extraData == null)) ||
259                 ((extraData != null) && (_extraData != null) &&
260                 !extraData.equals(_extraData))) {
261             _extraData = extraData;
262         }
263     }
264 
265     public long getReceiverUserId() {
266         return _receiverUserId;
267     }
268 
269     public void setReceiverUserId(long receiverUserId) {
270         if (receiverUserId != _receiverUserId) {
271             _receiverUserId = receiverUserId;
272         }
273     }
274 
275     public SocialActivity toEscapedModel() {
276         if (isEscapedModel()) {
277             return (SocialActivity)this;
278         }
279         else {
280             SocialActivity model = new SocialActivityImpl();
281 
282             model.setEscapedModel(true);
283 
284             model.setActivityId(getActivityId());
285             model.setGroupId(getGroupId());
286             model.setCompanyId(getCompanyId());
287             model.setUserId(getUserId());
288             model.setCreateDate(getCreateDate());
289             model.setMirrorActivityId(getMirrorActivityId());
290             model.setClassNameId(getClassNameId());
291             model.setClassPK(getClassPK());
292             model.setType(getType());
293             model.setExtraData(HtmlUtil.escape(getExtraData()));
294             model.setReceiverUserId(getReceiverUserId());
295 
296             model = (SocialActivity)Proxy.newProxyInstance(SocialActivity.class.getClassLoader(),
297                     new Class[] { SocialActivity.class },
298                     new ReadOnlyBeanHandler(model));
299 
300             return model;
301         }
302     }
303 
304     public Object clone() {
305         SocialActivityImpl clone = new SocialActivityImpl();
306 
307         clone.setActivityId(getActivityId());
308         clone.setGroupId(getGroupId());
309         clone.setCompanyId(getCompanyId());
310         clone.setUserId(getUserId());
311         clone.setCreateDate(getCreateDate());
312         clone.setMirrorActivityId(getMirrorActivityId());
313         clone.setClassNameId(getClassNameId());
314         clone.setClassPK(getClassPK());
315         clone.setType(getType());
316         clone.setExtraData(getExtraData());
317         clone.setReceiverUserId(getReceiverUserId());
318 
319         return clone;
320     }
321 
322     public int compareTo(Object obj) {
323         if (obj == null) {
324             return -1;
325         }
326 
327         SocialActivityImpl socialActivity = (SocialActivityImpl)obj;
328 
329         int value = 0;
330 
331         value = DateUtil.compareTo(getCreateDate(),
332                 socialActivity.getCreateDate());
333 
334         value = value * -1;
335 
336         if (value != 0) {
337             return value;
338         }
339 
340         return 0;
341     }
342 
343     public boolean equals(Object obj) {
344         if (obj == null) {
345             return false;
346         }
347 
348         SocialActivityImpl socialActivity = null;
349 
350         try {
351             socialActivity = (SocialActivityImpl)obj;
352         }
353         catch (ClassCastException cce) {
354             return false;
355         }
356 
357         long pk = socialActivity.getPrimaryKey();
358 
359         if (getPrimaryKey() == pk) {
360             return true;
361         }
362         else {
363             return false;
364         }
365     }
366 
367     public int hashCode() {
368         return (int)getPrimaryKey();
369     }
370 
371     private long _activityId;
372     private long _groupId;
373     private long _companyId;
374     private long _userId;
375     private Date _createDate;
376     private long _mirrorActivityId;
377     private long _classNameId;
378     private long _classPK;
379     private int _type;
380     private String _extraData;
381     private long _receiverUserId;
382 }