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