1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.social.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
29  import com.liferay.portlet.social.model.SocialRelation;
30  import com.liferay.portlet.social.model.SocialRelationSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="SocialRelationModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>SocialRelation</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.social.model.SocialRelation
58   * @see com.liferay.portlet.social.model.SocialRelationModel
59   * @see com.liferay.portlet.social.model.impl.SocialRelationImpl
60   *
61   */
62  public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation> {
63      public static final String TABLE_NAME = "SocialRelation";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "relationId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "createDate", new Integer(Types.TIMESTAMP) },
75              
76  
77              { "userId1", new Integer(Types.BIGINT) },
78              
79  
80              { "userId2", new Integer(Types.BIGINT) },
81              
82  
83              { "type_", new Integer(Types.INTEGER) }
84          };
85      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)";
86      public static final String TABLE_SQL_DROP = "drop table SocialRelation";
87      public static final String DATA_SOURCE = "liferayDataSource";
88      public static final String SESSION_FACTORY = "liferaySessionFactory";
89      public static final String TX_MANAGER = "liferayTransactionManager";
90      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91                  "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
92              true);
93      public static final boolean FINDER_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         _uuid = uuid;
145     }
146 
147     public long getRelationId() {
148         return _relationId;
149     }
150 
151     public void setRelationId(long relationId) {
152         _relationId = relationId;
153     }
154 
155     public long getCompanyId() {
156         return _companyId;
157     }
158 
159     public void setCompanyId(long companyId) {
160         _companyId = companyId;
161     }
162 
163     public Date getCreateDate() {
164         return _createDate;
165     }
166 
167     public void setCreateDate(Date createDate) {
168         _createDate = createDate;
169     }
170 
171     public long getUserId1() {
172         return _userId1;
173     }
174 
175     public void setUserId1(long userId1) {
176         _userId1 = userId1;
177 
178         if (!_setOriginalUserId1) {
179             _setOriginalUserId1 = true;
180 
181             _originalUserId1 = userId1;
182         }
183     }
184 
185     public long getOriginalUserId1() {
186         return _originalUserId1;
187     }
188 
189     public long getUserId2() {
190         return _userId2;
191     }
192 
193     public void setUserId2(long userId2) {
194         _userId2 = userId2;
195 
196         if (!_setOriginalUserId2) {
197             _setOriginalUserId2 = true;
198 
199             _originalUserId2 = userId2;
200         }
201     }
202 
203     public long getOriginalUserId2() {
204         return _originalUserId2;
205     }
206 
207     public int getType() {
208         return _type;
209     }
210 
211     public void setType(int type) {
212         _type = type;
213 
214         if (!_setOriginalType) {
215             _setOriginalType = true;
216 
217             _originalType = type;
218         }
219     }
220 
221     public int getOriginalType() {
222         return _originalType;
223     }
224 
225     public SocialRelation toEscapedModel() {
226         if (isEscapedModel()) {
227             return (SocialRelation)this;
228         }
229         else {
230             SocialRelation model = new SocialRelationImpl();
231 
232             model.setNew(isNew());
233             model.setEscapedModel(true);
234 
235             model.setUuid(HtmlUtil.escape(getUuid()));
236             model.setRelationId(getRelationId());
237             model.setCompanyId(getCompanyId());
238             model.setCreateDate(getCreateDate());
239             model.setUserId1(getUserId1());
240             model.setUserId2(getUserId2());
241             model.setType(getType());
242 
243             model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
244                     new Class[] { SocialRelation.class },
245                     new ReadOnlyBeanHandler(model));
246 
247             return model;
248         }
249     }
250 
251     public ExpandoBridge getExpandoBridge() {
252         if (_expandoBridge == null) {
253             _expandoBridge = new ExpandoBridgeImpl(SocialRelation.class.getName(),
254                     getPrimaryKey());
255         }
256 
257         return _expandoBridge;
258     }
259 
260     public Object clone() {
261         SocialRelationImpl clone = new SocialRelationImpl();
262 
263         clone.setUuid(getUuid());
264         clone.setRelationId(getRelationId());
265         clone.setCompanyId(getCompanyId());
266         clone.setCreateDate(getCreateDate());
267         clone.setUserId1(getUserId1());
268         clone.setUserId2(getUserId2());
269         clone.setType(getType());
270 
271         return clone;
272     }
273 
274     public int compareTo(SocialRelation socialRelation) {
275         long pk = socialRelation.getPrimaryKey();
276 
277         if (getPrimaryKey() < pk) {
278             return -1;
279         }
280         else if (getPrimaryKey() > pk) {
281             return 1;
282         }
283         else {
284             return 0;
285         }
286     }
287 
288     public boolean equals(Object obj) {
289         if (obj == null) {
290             return false;
291         }
292 
293         SocialRelation socialRelation = null;
294 
295         try {
296             socialRelation = (SocialRelation)obj;
297         }
298         catch (ClassCastException cce) {
299             return false;
300         }
301 
302         long pk = socialRelation.getPrimaryKey();
303 
304         if (getPrimaryKey() == pk) {
305             return true;
306         }
307         else {
308             return false;
309         }
310     }
311 
312     public int hashCode() {
313         return (int)getPrimaryKey();
314     }
315 
316     public String toString() {
317         StringBuilder sb = new StringBuilder();
318 
319         sb.append("{uuid=");
320         sb.append(getUuid());
321         sb.append(", relationId=");
322         sb.append(getRelationId());
323         sb.append(", companyId=");
324         sb.append(getCompanyId());
325         sb.append(", createDate=");
326         sb.append(getCreateDate());
327         sb.append(", userId1=");
328         sb.append(getUserId1());
329         sb.append(", userId2=");
330         sb.append(getUserId2());
331         sb.append(", type=");
332         sb.append(getType());
333         sb.append("}");
334 
335         return sb.toString();
336     }
337 
338     public String toXmlString() {
339         StringBuilder sb = new StringBuilder();
340 
341         sb.append("<model><model-name>");
342         sb.append("com.liferay.portlet.social.model.SocialRelation");
343         sb.append("</model-name>");
344 
345         sb.append(
346             "<column><column-name>uuid</column-name><column-value><![CDATA[");
347         sb.append(getUuid());
348         sb.append("]]></column-value></column>");
349         sb.append(
350             "<column><column-name>relationId</column-name><column-value><![CDATA[");
351         sb.append(getRelationId());
352         sb.append("]]></column-value></column>");
353         sb.append(
354             "<column><column-name>companyId</column-name><column-value><![CDATA[");
355         sb.append(getCompanyId());
356         sb.append("]]></column-value></column>");
357         sb.append(
358             "<column><column-name>createDate</column-name><column-value><![CDATA[");
359         sb.append(getCreateDate());
360         sb.append("]]></column-value></column>");
361         sb.append(
362             "<column><column-name>userId1</column-name><column-value><![CDATA[");
363         sb.append(getUserId1());
364         sb.append("]]></column-value></column>");
365         sb.append(
366             "<column><column-name>userId2</column-name><column-value><![CDATA[");
367         sb.append(getUserId2());
368         sb.append("]]></column-value></column>");
369         sb.append(
370             "<column><column-name>type</column-name><column-value><![CDATA[");
371         sb.append(getType());
372         sb.append("]]></column-value></column>");
373 
374         sb.append("</model>");
375 
376         return sb.toString();
377     }
378 
379     private String _uuid;
380     private long _relationId;
381     private long _companyId;
382     private Date _createDate;
383     private long _userId1;
384     private long _originalUserId1;
385     private boolean _setOriginalUserId1;
386     private long _userId2;
387     private long _originalUserId2;
388     private boolean _setOriginalUserId2;
389     private int _type;
390     private int _originalType;
391     private boolean _setOriginalType;
392     private transient ExpandoBridge _expandoBridge;
393 }