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 {
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 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         if ((uuid != null) && (uuid != _uuid)) {
145             _uuid = uuid;
146         }
147     }
148 
149     public long getRelationId() {
150         return _relationId;
151     }
152 
153     public void setRelationId(long relationId) {
154         if (relationId != _relationId) {
155             _relationId = relationId;
156         }
157     }
158 
159     public long getCompanyId() {
160         return _companyId;
161     }
162 
163     public void setCompanyId(long companyId) {
164         if (companyId != _companyId) {
165             _companyId = companyId;
166         }
167     }
168 
169     public Date getCreateDate() {
170         return _createDate;
171     }
172 
173     public void setCreateDate(Date createDate) {
174         if (((createDate == null) && (_createDate != null)) ||
175                 ((createDate != null) && (_createDate == null)) ||
176                 ((createDate != null) && (_createDate != null) &&
177                 !createDate.equals(_createDate))) {
178             _createDate = createDate;
179         }
180     }
181 
182     public long getUserId1() {
183         return _userId1;
184     }
185 
186     public void setUserId1(long userId1) {
187         if (userId1 != _userId1) {
188             _userId1 = userId1;
189         }
190     }
191 
192     public long getUserId2() {
193         return _userId2;
194     }
195 
196     public void setUserId2(long userId2) {
197         if (userId2 != _userId2) {
198             _userId2 = userId2;
199         }
200     }
201 
202     public int getType() {
203         return _type;
204     }
205 
206     public void setType(int type) {
207         if (type != _type) {
208             _type = type;
209         }
210     }
211 
212     public SocialRelation toEscapedModel() {
213         if (isEscapedModel()) {
214             return (SocialRelation)this;
215         }
216         else {
217             SocialRelation model = new SocialRelationImpl();
218 
219             model.setNew(isNew());
220             model.setEscapedModel(true);
221 
222             model.setUuid(HtmlUtil.escape(getUuid()));
223             model.setRelationId(getRelationId());
224             model.setCompanyId(getCompanyId());
225             model.setCreateDate(getCreateDate());
226             model.setUserId1(getUserId1());
227             model.setUserId2(getUserId2());
228             model.setType(getType());
229 
230             model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
231                     new Class[] { SocialRelation.class },
232                     new ReadOnlyBeanHandler(model));
233 
234             return model;
235         }
236     }
237 
238     public ExpandoBridge getExpandoBridge() {
239         if (_expandoBridge == null) {
240             _expandoBridge = new ExpandoBridgeImpl(SocialRelation.class.getName(),
241                     getPrimaryKey());
242         }
243 
244         return _expandoBridge;
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(Object obj) {
262         if (obj == null) {
263             return -1;
264         }
265 
266         SocialRelationImpl socialRelation = (SocialRelationImpl)obj;
267 
268         long pk = socialRelation.getPrimaryKey();
269 
270         if (getPrimaryKey() < pk) {
271             return -1;
272         }
273         else if (getPrimaryKey() > pk) {
274             return 1;
275         }
276         else {
277             return 0;
278         }
279     }
280 
281     public boolean equals(Object obj) {
282         if (obj == null) {
283             return false;
284         }
285 
286         SocialRelationImpl socialRelation = null;
287 
288         try {
289             socialRelation = (SocialRelationImpl)obj;
290         }
291         catch (ClassCastException cce) {
292             return false;
293         }
294 
295         long pk = socialRelation.getPrimaryKey();
296 
297         if (getPrimaryKey() == pk) {
298             return true;
299         }
300         else {
301             return false;
302         }
303     }
304 
305     public int hashCode() {
306         return (int)getPrimaryKey();
307     }
308 
309     private String _uuid;
310     private long _relationId;
311     private long _companyId;
312     private Date _createDate;
313     private long _userId1;
314     private long _userId2;
315     private int _type;
316     private transient ExpandoBridge _expandoBridge;
317 }