1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portlet.social.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
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         if (_uuid == null) {
124             return StringPool.BLANK;
125         }
126         else {
127             return _uuid;
128         }
129     }
130 
131     public void setUuid(String uuid) {
132         _uuid = uuid;
133     }
134 
135     public long getRelationId() {
136         return _relationId;
137     }
138 
139     public void setRelationId(long relationId) {
140         _relationId = relationId;
141     }
142 
143     public long getCompanyId() {
144         return _companyId;
145     }
146 
147     public void setCompanyId(long companyId) {
148         _companyId = companyId;
149     }
150 
151     public long getCreateDate() {
152         return _createDate;
153     }
154 
155     public void setCreateDate(long createDate) {
156         _createDate = createDate;
157     }
158 
159     public long getUserId1() {
160         return _userId1;
161     }
162 
163     public void setUserId1(long userId1) {
164         _userId1 = userId1;
165 
166         if (!_setOriginalUserId1) {
167             _setOriginalUserId1 = true;
168 
169             _originalUserId1 = userId1;
170         }
171     }
172 
173     public long getOriginalUserId1() {
174         return _originalUserId1;
175     }
176 
177     public long getUserId2() {
178         return _userId2;
179     }
180 
181     public void setUserId2(long userId2) {
182         _userId2 = userId2;
183 
184         if (!_setOriginalUserId2) {
185             _setOriginalUserId2 = true;
186 
187             _originalUserId2 = userId2;
188         }
189     }
190 
191     public long getOriginalUserId2() {
192         return _originalUserId2;
193     }
194 
195     public int getType() {
196         return _type;
197     }
198 
199     public void setType(int type) {
200         _type = type;
201 
202         if (!_setOriginalType) {
203             _setOriginalType = true;
204 
205             _originalType = type;
206         }
207     }
208 
209     public int getOriginalType() {
210         return _originalType;
211     }
212 
213     public SocialRelation toEscapedModel() {
214         if (isEscapedModel()) {
215             return (SocialRelation)this;
216         }
217         else {
218             return (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
219                 new Class[] { SocialRelation.class },
220                 new AutoEscapeBeanHandler(this));
221         }
222     }
223 
224     public ExpandoBridge getExpandoBridge() {
225         if (_expandoBridge == null) {
226             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(SocialRelation.class.getName(),
227                     getPrimaryKey());
228         }
229 
230         return _expandoBridge;
231     }
232 
233     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
234         getExpandoBridge().setAttributes(serviceContext);
235     }
236 
237     public Object clone() {
238         SocialRelationImpl clone = new SocialRelationImpl();
239 
240         clone.setUuid(getUuid());
241         clone.setRelationId(getRelationId());
242         clone.setCompanyId(getCompanyId());
243         clone.setCreateDate(getCreateDate());
244         clone.setUserId1(getUserId1());
245         clone.setUserId2(getUserId2());
246         clone.setType(getType());
247 
248         return clone;
249     }
250 
251     public int compareTo(SocialRelation socialRelation) {
252         long pk = socialRelation.getPrimaryKey();
253 
254         if (getPrimaryKey() < pk) {
255             return -1;
256         }
257         else if (getPrimaryKey() > pk) {
258             return 1;
259         }
260         else {
261             return 0;
262         }
263     }
264 
265     public boolean equals(Object obj) {
266         if (obj == null) {
267             return false;
268         }
269 
270         SocialRelation socialRelation = null;
271 
272         try {
273             socialRelation = (SocialRelation)obj;
274         }
275         catch (ClassCastException cce) {
276             return false;
277         }
278 
279         long pk = socialRelation.getPrimaryKey();
280 
281         if (getPrimaryKey() == pk) {
282             return true;
283         }
284         else {
285             return false;
286         }
287     }
288 
289     public int hashCode() {
290         return (int)getPrimaryKey();
291     }
292 
293     public String toString() {
294         StringBundler sb = new StringBundler(15);
295 
296         sb.append("{uuid=");
297         sb.append(getUuid());
298         sb.append(", relationId=");
299         sb.append(getRelationId());
300         sb.append(", companyId=");
301         sb.append(getCompanyId());
302         sb.append(", createDate=");
303         sb.append(getCreateDate());
304         sb.append(", userId1=");
305         sb.append(getUserId1());
306         sb.append(", userId2=");
307         sb.append(getUserId2());
308         sb.append(", type=");
309         sb.append(getType());
310         sb.append("}");
311 
312         return sb.toString();
313     }
314 
315     public String toXmlString() {
316         StringBundler sb = new StringBundler(25);
317 
318         sb.append("<model><model-name>");
319         sb.append("com.liferay.portlet.social.model.SocialRelation");
320         sb.append("</model-name>");
321 
322         sb.append(
323             "<column><column-name>uuid</column-name><column-value><![CDATA[");
324         sb.append(getUuid());
325         sb.append("]]></column-value></column>");
326         sb.append(
327             "<column><column-name>relationId</column-name><column-value><![CDATA[");
328         sb.append(getRelationId());
329         sb.append("]]></column-value></column>");
330         sb.append(
331             "<column><column-name>companyId</column-name><column-value><![CDATA[");
332         sb.append(getCompanyId());
333         sb.append("]]></column-value></column>");
334         sb.append(
335             "<column><column-name>createDate</column-name><column-value><![CDATA[");
336         sb.append(getCreateDate());
337         sb.append("]]></column-value></column>");
338         sb.append(
339             "<column><column-name>userId1</column-name><column-value><![CDATA[");
340         sb.append(getUserId1());
341         sb.append("]]></column-value></column>");
342         sb.append(
343             "<column><column-name>userId2</column-name><column-value><![CDATA[");
344         sb.append(getUserId2());
345         sb.append("]]></column-value></column>");
346         sb.append(
347             "<column><column-name>type</column-name><column-value><![CDATA[");
348         sb.append(getType());
349         sb.append("]]></column-value></column>");
350 
351         sb.append("</model>");
352 
353         return sb.toString();
354     }
355 
356     private String _uuid;
357     private long _relationId;
358     private long _companyId;
359     private long _createDate;
360     private long _userId1;
361     private long _originalUserId1;
362     private boolean _setOriginalUserId1;
363     private long _userId2;
364     private long _originalUserId2;
365     private boolean _setOriginalUserId2;
366     private int _type;
367     private int _originalType;
368     private boolean _setOriginalType;
369     private transient ExpandoBridge _expandoBridge;
370 }