1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.social.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  
24  import com.liferay.portlet.expando.model.ExpandoBridge;
25  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
26  import com.liferay.portlet.social.model.SocialRelation;
27  import com.liferay.portlet.social.model.SocialRelationSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  
38  /**
39   * <a href="SocialRelationModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the SocialRelation table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       SocialRelationImpl
53   * @see       com.liferay.portlet.social.model.SocialRelation
54   * @see       com.liferay.portlet.social.model.SocialRelationModel
55   * @generated
56   */
57  public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation> {
58      public static final String TABLE_NAME = "SocialRelation";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "uuid_", new Integer(Types.VARCHAR) },
61              { "relationId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "createDate", new Integer(Types.BIGINT) },
64              { "userId1", new Integer(Types.BIGINT) },
65              { "userId2", new Integer(Types.BIGINT) },
66              { "type_", new Integer(Types.INTEGER) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table SocialRelation (uuid_ VARCHAR(75) null,relationId LONG not null primary key,companyId LONG,createDate LONG,userId1 LONG,userId2 LONG,type_ INTEGER)";
69      public static final String TABLE_SQL_DROP = "drop table SocialRelation";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
78              true);
79  
80      public static SocialRelation toModel(SocialRelationSoap soapModel) {
81          SocialRelation model = new SocialRelationImpl();
82  
83          model.setUuid(soapModel.getUuid());
84          model.setRelationId(soapModel.getRelationId());
85          model.setCompanyId(soapModel.getCompanyId());
86          model.setCreateDate(soapModel.getCreateDate());
87          model.setUserId1(soapModel.getUserId1());
88          model.setUserId2(soapModel.getUserId2());
89          model.setType(soapModel.getType());
90  
91          return model;
92      }
93  
94      public static List<SocialRelation> toModels(SocialRelationSoap[] soapModels) {
95          List<SocialRelation> models = new ArrayList<SocialRelation>(soapModels.length);
96  
97          for (SocialRelationSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
106 
107     public SocialRelationModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _relationId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setRelationId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_relationId);
120     }
121 
122     public String getUuid() {
123         return GetterUtil.getString(_uuid);
124     }
125 
126     public void setUuid(String uuid) {
127         _uuid = uuid;
128     }
129 
130     public long getRelationId() {
131         return _relationId;
132     }
133 
134     public void setRelationId(long relationId) {
135         _relationId = relationId;
136     }
137 
138     public long getCompanyId() {
139         return _companyId;
140     }
141 
142     public void setCompanyId(long companyId) {
143         _companyId = companyId;
144     }
145 
146     public long getCreateDate() {
147         return _createDate;
148     }
149 
150     public void setCreateDate(long createDate) {
151         _createDate = createDate;
152     }
153 
154     public long getUserId1() {
155         return _userId1;
156     }
157 
158     public void setUserId1(long userId1) {
159         _userId1 = userId1;
160 
161         if (!_setOriginalUserId1) {
162             _setOriginalUserId1 = true;
163 
164             _originalUserId1 = userId1;
165         }
166     }
167 
168     public long getOriginalUserId1() {
169         return _originalUserId1;
170     }
171 
172     public long getUserId2() {
173         return _userId2;
174     }
175 
176     public void setUserId2(long userId2) {
177         _userId2 = userId2;
178 
179         if (!_setOriginalUserId2) {
180             _setOriginalUserId2 = true;
181 
182             _originalUserId2 = userId2;
183         }
184     }
185 
186     public long getOriginalUserId2() {
187         return _originalUserId2;
188     }
189 
190     public int getType() {
191         return _type;
192     }
193 
194     public void setType(int type) {
195         _type = type;
196 
197         if (!_setOriginalType) {
198             _setOriginalType = true;
199 
200             _originalType = type;
201         }
202     }
203 
204     public int getOriginalType() {
205         return _originalType;
206     }
207 
208     public SocialRelation toEscapedModel() {
209         if (isEscapedModel()) {
210             return (SocialRelation)this;
211         }
212         else {
213             SocialRelation model = new SocialRelationImpl();
214 
215             model.setNew(isNew());
216             model.setEscapedModel(true);
217 
218             model.setUuid(HtmlUtil.escape(getUuid()));
219             model.setRelationId(getRelationId());
220             model.setCompanyId(getCompanyId());
221             model.setCreateDate(getCreateDate());
222             model.setUserId1(getUserId1());
223             model.setUserId2(getUserId2());
224             model.setType(getType());
225 
226             model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
227                     new Class[] { SocialRelation.class },
228                     new ReadOnlyBeanHandler(model));
229 
230             return model;
231         }
232     }
233 
234     public ExpandoBridge getExpandoBridge() {
235         if (_expandoBridge == null) {
236             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
237                     SocialRelation.class.getName(), getPrimaryKey());
238         }
239 
240         return _expandoBridge;
241     }
242 
243     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
244         getExpandoBridge().setAttributes(serviceContext);
245     }
246 
247     public Object clone() {
248         SocialRelationImpl clone = new SocialRelationImpl();
249 
250         clone.setUuid(getUuid());
251         clone.setRelationId(getRelationId());
252         clone.setCompanyId(getCompanyId());
253         clone.setCreateDate(getCreateDate());
254         clone.setUserId1(getUserId1());
255         clone.setUserId2(getUserId2());
256         clone.setType(getType());
257 
258         return clone;
259     }
260 
261     public int compareTo(SocialRelation socialRelation) {
262         long pk = socialRelation.getPrimaryKey();
263 
264         if (getPrimaryKey() < pk) {
265             return -1;
266         }
267         else if (getPrimaryKey() > pk) {
268             return 1;
269         }
270         else {
271             return 0;
272         }
273     }
274 
275     public boolean equals(Object obj) {
276         if (obj == null) {
277             return false;
278         }
279 
280         SocialRelation socialRelation = null;
281 
282         try {
283             socialRelation = (SocialRelation)obj;
284         }
285         catch (ClassCastException cce) {
286             return false;
287         }
288 
289         long pk = socialRelation.getPrimaryKey();
290 
291         if (getPrimaryKey() == pk) {
292             return true;
293         }
294         else {
295             return false;
296         }
297     }
298 
299     public int hashCode() {
300         return (int)getPrimaryKey();
301     }
302 
303     public String toString() {
304         StringBundler sb = new StringBundler(15);
305 
306         sb.append("{uuid=");
307         sb.append(getUuid());
308         sb.append(", relationId=");
309         sb.append(getRelationId());
310         sb.append(", companyId=");
311         sb.append(getCompanyId());
312         sb.append(", createDate=");
313         sb.append(getCreateDate());
314         sb.append(", userId1=");
315         sb.append(getUserId1());
316         sb.append(", userId2=");
317         sb.append(getUserId2());
318         sb.append(", type=");
319         sb.append(getType());
320         sb.append("}");
321 
322         return sb.toString();
323     }
324 
325     public String toXmlString() {
326         StringBundler sb = new StringBundler(25);
327 
328         sb.append("<model><model-name>");
329         sb.append("com.liferay.portlet.social.model.SocialRelation");
330         sb.append("</model-name>");
331 
332         sb.append(
333             "<column><column-name>uuid</column-name><column-value><![CDATA[");
334         sb.append(getUuid());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>relationId</column-name><column-value><![CDATA[");
338         sb.append(getRelationId());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>companyId</column-name><column-value><![CDATA[");
342         sb.append(getCompanyId());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>createDate</column-name><column-value><![CDATA[");
346         sb.append(getCreateDate());
347         sb.append("]]></column-value></column>");
348         sb.append(
349             "<column><column-name>userId1</column-name><column-value><![CDATA[");
350         sb.append(getUserId1());
351         sb.append("]]></column-value></column>");
352         sb.append(
353             "<column><column-name>userId2</column-name><column-value><![CDATA[");
354         sb.append(getUserId2());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>type</column-name><column-value><![CDATA[");
358         sb.append(getType());
359         sb.append("]]></column-value></column>");
360 
361         sb.append("</model>");
362 
363         return sb.toString();
364     }
365 
366     private String _uuid;
367     private long _relationId;
368     private long _companyId;
369     private long _createDate;
370     private long _userId1;
371     private long _originalUserId1;
372     private boolean _setOriginalUserId1;
373     private long _userId2;
374     private long _originalUserId2;
375     private boolean _setOriginalUserId2;
376     private int _type;
377     private int _originalType;
378     private boolean _setOriginalType;
379     private transient ExpandoBridge _expandoBridge;
380 }