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