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