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