1   /**
2    * Copyright (c) 2000-2008 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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
93              true);
94  
95      public static SocialRelation toModel(SocialRelationSoap soapModel) {
96          SocialRelation model = new SocialRelationImpl();
97  
98          model.setUuid(soapModel.getUuid());
99          model.setRelationId(soapModel.getRelationId());
100         model.setCompanyId(soapModel.getCompanyId());
101         model.setCreateDate(soapModel.getCreateDate());
102         model.setUserId1(soapModel.getUserId1());
103         model.setUserId2(soapModel.getUserId2());
104         model.setType(soapModel.getType());
105 
106         return model;
107     }
108 
109     public static List<SocialRelation> toModels(SocialRelationSoap[] soapModels) {
110         List<SocialRelation> models = new ArrayList<SocialRelation>(soapModels.length);
111 
112         for (SocialRelationSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
121 
122     public SocialRelationModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _relationId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setRelationId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_relationId);
135     }
136 
137     public String getUuid() {
138         return GetterUtil.getString(_uuid);
139     }
140 
141     public void setUuid(String uuid) {
142         if ((uuid != null) && (uuid != _uuid)) {
143             _uuid = uuid;
144         }
145     }
146 
147     public long getRelationId() {
148         return _relationId;
149     }
150 
151     public void setRelationId(long relationId) {
152         if (relationId != _relationId) {
153             _relationId = relationId;
154         }
155     }
156 
157     public long getCompanyId() {
158         return _companyId;
159     }
160 
161     public void setCompanyId(long companyId) {
162         if (companyId != _companyId) {
163             _companyId = companyId;
164         }
165     }
166 
167     public Date getCreateDate() {
168         return _createDate;
169     }
170 
171     public void setCreateDate(Date createDate) {
172         if (((createDate == null) && (_createDate != null)) ||
173                 ((createDate != null) && (_createDate == null)) ||
174                 ((createDate != null) && (_createDate != null) &&
175                 !createDate.equals(_createDate))) {
176             _createDate = createDate;
177         }
178     }
179 
180     public long getUserId1() {
181         return _userId1;
182     }
183 
184     public void setUserId1(long userId1) {
185         if (userId1 != _userId1) {
186             _userId1 = userId1;
187         }
188     }
189 
190     public long getUserId2() {
191         return _userId2;
192     }
193 
194     public void setUserId2(long userId2) {
195         if (userId2 != _userId2) {
196             _userId2 = userId2;
197         }
198     }
199 
200     public int getType() {
201         return _type;
202     }
203 
204     public void setType(int type) {
205         if (type != _type) {
206             _type = type;
207         }
208     }
209 
210     public SocialRelation toEscapedModel() {
211         if (isEscapedModel()) {
212             return (SocialRelation)this;
213         }
214         else {
215             SocialRelation model = new SocialRelationImpl();
216 
217             model.setNew(isNew());
218             model.setEscapedModel(true);
219 
220             model.setUuid(HtmlUtil.escape(getUuid()));
221             model.setRelationId(getRelationId());
222             model.setCompanyId(getCompanyId());
223             model.setCreateDate(getCreateDate());
224             model.setUserId1(getUserId1());
225             model.setUserId2(getUserId2());
226             model.setType(getType());
227 
228             model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
229                     new Class[] { SocialRelation.class },
230                     new ReadOnlyBeanHandler(model));
231 
232             return model;
233         }
234     }
235 
236     public Object clone() {
237         SocialRelationImpl clone = new SocialRelationImpl();
238 
239         clone.setUuid(getUuid());
240         clone.setRelationId(getRelationId());
241         clone.setCompanyId(getCompanyId());
242         clone.setCreateDate(getCreateDate());
243         clone.setUserId1(getUserId1());
244         clone.setUserId2(getUserId2());
245         clone.setType(getType());
246 
247         return clone;
248     }
249 
250     public int compareTo(Object obj) {
251         if (obj == null) {
252             return -1;
253         }
254 
255         SocialRelationImpl socialRelation = (SocialRelationImpl)obj;
256 
257         long pk = socialRelation.getPrimaryKey();
258 
259         if (getPrimaryKey() < pk) {
260             return -1;
261         }
262         else if (getPrimaryKey() > pk) {
263             return 1;
264         }
265         else {
266             return 0;
267         }
268     }
269 
270     public boolean equals(Object obj) {
271         if (obj == null) {
272             return false;
273         }
274 
275         SocialRelationImpl socialRelation = null;
276 
277         try {
278             socialRelation = (SocialRelationImpl)obj;
279         }
280         catch (ClassCastException cce) {
281             return false;
282         }
283 
284         long pk = socialRelation.getPrimaryKey();
285 
286         if (getPrimaryKey() == pk) {
287             return true;
288         }
289         else {
290             return false;
291         }
292     }
293 
294     public int hashCode() {
295         return (int)getPrimaryKey();
296     }
297 
298     private String _uuid;
299     private long _relationId;
300     private long _companyId;
301     private Date _createDate;
302     private long _userId1;
303     private long _userId2;
304     private int _type;
305 }