001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.social.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    
024    import com.liferay.portlet.expando.model.ExpandoBridge;
025    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
026    import com.liferay.portlet.social.model.SocialRelation;
027    import com.liferay.portlet.social.model.SocialRelationModel;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    /**
036     * The base model implementation for the SocialRelation service. Represents a row in the "SocialRelation" database table, with each column mapped to a property of this class.
037     *
038     * <p>
039     * This implementation and its corresponding interface {@link com.liferay.portlet.social.model.SocialRelationModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SocialRelationImpl}.
040     * </p>
041     *
042     * <p>
043     * Never modify or reference this class directly. All methods that expect a social relation model instance should use the {@link com.liferay.portlet.social.model.SocialRelation} interface instead.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see SocialRelationImpl
048     * @see com.liferay.portlet.social.model.SocialRelation
049     * @see com.liferay.portlet.social.model.SocialRelationModel
050     * @generated
051     */
052    public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation>
053            implements SocialRelationModel {
054            public static final String TABLE_NAME = "SocialRelation";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "uuid_", new Integer(Types.VARCHAR) },
057                            { "relationId", new Integer(Types.BIGINT) },
058                            { "companyId", new Integer(Types.BIGINT) },
059                            { "createDate", new Integer(Types.BIGINT) },
060                            { "userId1", new Integer(Types.BIGINT) },
061                            { "userId2", new Integer(Types.BIGINT) },
062                            { "type_", new Integer(Types.INTEGER) }
063                    };
064            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)";
065            public static final String TABLE_SQL_DROP = "drop table SocialRelation";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
074                            true);
075            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
076                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
077    
078            public SocialRelationModelImpl() {
079            }
080    
081            public long getPrimaryKey() {
082                    return _relationId;
083            }
084    
085            public void setPrimaryKey(long pk) {
086                    setRelationId(pk);
087            }
088    
089            public Serializable getPrimaryKeyObj() {
090                    return new Long(_relationId);
091            }
092    
093            public String getUuid() {
094                    if (_uuid == null) {
095                            return StringPool.BLANK;
096                    }
097                    else {
098                            return _uuid;
099                    }
100            }
101    
102            public void setUuid(String uuid) {
103                    _uuid = uuid;
104            }
105    
106            public long getRelationId() {
107                    return _relationId;
108            }
109    
110            public void setRelationId(long relationId) {
111                    _relationId = relationId;
112            }
113    
114            public long getCompanyId() {
115                    return _companyId;
116            }
117    
118            public void setCompanyId(long companyId) {
119                    _companyId = companyId;
120            }
121    
122            public long getCreateDate() {
123                    return _createDate;
124            }
125    
126            public void setCreateDate(long createDate) {
127                    _createDate = createDate;
128            }
129    
130            public long getUserId1() {
131                    return _userId1;
132            }
133    
134            public void setUserId1(long userId1) {
135                    if (!_setOriginalUserId1) {
136                            _setOriginalUserId1 = true;
137    
138                            _originalUserId1 = _userId1;
139                    }
140    
141                    _userId1 = userId1;
142            }
143    
144            public long getOriginalUserId1() {
145                    return _originalUserId1;
146            }
147    
148            public long getUserId2() {
149                    return _userId2;
150            }
151    
152            public void setUserId2(long userId2) {
153                    if (!_setOriginalUserId2) {
154                            _setOriginalUserId2 = true;
155    
156                            _originalUserId2 = _userId2;
157                    }
158    
159                    _userId2 = userId2;
160            }
161    
162            public long getOriginalUserId2() {
163                    return _originalUserId2;
164            }
165    
166            public int getType() {
167                    return _type;
168            }
169    
170            public void setType(int type) {
171                    if (!_setOriginalType) {
172                            _setOriginalType = true;
173    
174                            _originalType = _type;
175                    }
176    
177                    _type = type;
178            }
179    
180            public int getOriginalType() {
181                    return _originalType;
182            }
183    
184            public SocialRelation toEscapedModel() {
185                    if (isEscapedModel()) {
186                            return (SocialRelation)this;
187                    }
188                    else {
189                            return (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
190                                    new Class[] { SocialRelation.class },
191                                    new AutoEscapeBeanHandler(this));
192                    }
193            }
194    
195            public ExpandoBridge getExpandoBridge() {
196                    if (_expandoBridge == null) {
197                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
198                                            SocialRelation.class.getName(), getPrimaryKey());
199                    }
200    
201                    return _expandoBridge;
202            }
203    
204            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
205                    getExpandoBridge().setAttributes(serviceContext);
206            }
207    
208            public Object clone() {
209                    SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
210    
211                    socialRelationImpl.setUuid(getUuid());
212    
213                    socialRelationImpl.setRelationId(getRelationId());
214    
215                    socialRelationImpl.setCompanyId(getCompanyId());
216    
217                    socialRelationImpl.setCreateDate(getCreateDate());
218    
219                    socialRelationImpl.setUserId1(getUserId1());
220    
221                    SocialRelationModelImpl socialRelationModelImpl = socialRelationImpl;
222    
223                    socialRelationModelImpl._originalUserId1 = socialRelationModelImpl._userId1;
224    
225                    socialRelationModelImpl._setOriginalUserId1 = false;
226                    socialRelationImpl.setUserId2(getUserId2());
227    
228                    socialRelationModelImpl._originalUserId2 = socialRelationModelImpl._userId2;
229    
230                    socialRelationModelImpl._setOriginalUserId2 = false;
231                    socialRelationImpl.setType(getType());
232    
233                    socialRelationModelImpl._originalType = socialRelationModelImpl._type;
234    
235                    socialRelationModelImpl._setOriginalType = false;
236    
237                    return socialRelationImpl;
238            }
239    
240            public int compareTo(SocialRelation socialRelation) {
241                    long pk = socialRelation.getPrimaryKey();
242    
243                    if (getPrimaryKey() < pk) {
244                            return -1;
245                    }
246                    else if (getPrimaryKey() > pk) {
247                            return 1;
248                    }
249                    else {
250                            return 0;
251                    }
252            }
253    
254            public boolean equals(Object obj) {
255                    if (obj == null) {
256                            return false;
257                    }
258    
259                    SocialRelation socialRelation = null;
260    
261                    try {
262                            socialRelation = (SocialRelation)obj;
263                    }
264                    catch (ClassCastException cce) {
265                            return false;
266                    }
267    
268                    long pk = socialRelation.getPrimaryKey();
269    
270                    if (getPrimaryKey() == pk) {
271                            return true;
272                    }
273                    else {
274                            return false;
275                    }
276            }
277    
278            public int hashCode() {
279                    return (int)getPrimaryKey();
280            }
281    
282            public String toString() {
283                    StringBundler sb = new StringBundler(15);
284    
285                    sb.append("{uuid=");
286                    sb.append(getUuid());
287                    sb.append(", relationId=");
288                    sb.append(getRelationId());
289                    sb.append(", companyId=");
290                    sb.append(getCompanyId());
291                    sb.append(", createDate=");
292                    sb.append(getCreateDate());
293                    sb.append(", userId1=");
294                    sb.append(getUserId1());
295                    sb.append(", userId2=");
296                    sb.append(getUserId2());
297                    sb.append(", type=");
298                    sb.append(getType());
299                    sb.append("}");
300    
301                    return sb.toString();
302            }
303    
304            public String toXmlString() {
305                    StringBundler sb = new StringBundler(25);
306    
307                    sb.append("<model><model-name>");
308                    sb.append("com.liferay.portlet.social.model.SocialRelation");
309                    sb.append("</model-name>");
310    
311                    sb.append(
312                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
313                    sb.append(getUuid());
314                    sb.append("]]></column-value></column>");
315                    sb.append(
316                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
317                    sb.append(getRelationId());
318                    sb.append("]]></column-value></column>");
319                    sb.append(
320                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
321                    sb.append(getCompanyId());
322                    sb.append("]]></column-value></column>");
323                    sb.append(
324                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
325                    sb.append(getCreateDate());
326                    sb.append("]]></column-value></column>");
327                    sb.append(
328                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
329                    sb.append(getUserId1());
330                    sb.append("]]></column-value></column>");
331                    sb.append(
332                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
333                    sb.append(getUserId2());
334                    sb.append("]]></column-value></column>");
335                    sb.append(
336                            "<column><column-name>type</column-name><column-value><![CDATA[");
337                    sb.append(getType());
338                    sb.append("]]></column-value></column>");
339    
340                    sb.append("</model>");
341    
342                    return sb.toString();
343            }
344    
345            private String _uuid;
346            private long _relationId;
347            private long _companyId;
348            private long _createDate;
349            private long _userId1;
350            private long _originalUserId1;
351            private boolean _setOriginalUserId1;
352            private long _userId2;
353            private long _originalUserId2;
354            private boolean _setOriginalUserId2;
355            private int _type;
356            private int _originalType;
357            private boolean _setOriginalType;
358            private transient ExpandoBridge _expandoBridge;
359    }