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