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