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