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