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