001    /**
002     * Copyright (c) 2000-2010 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                    _userId1 = userId1;
136    
137                    if (!_setOriginalUserId1) {
138                            _setOriginalUserId1 = true;
139    
140                            _originalUserId1 = userId1;
141                    }
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                    _userId2 = userId2;
154    
155                    if (!_setOriginalUserId2) {
156                            _setOriginalUserId2 = true;
157    
158                            _originalUserId2 = userId2;
159                    }
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                    _type = type;
172    
173                    if (!_setOriginalType) {
174                            _setOriginalType = true;
175    
176                            _originalType = type;
177                    }
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 clone = new SocialRelationImpl();
210    
211                    clone.setUuid(getUuid());
212                    clone.setRelationId(getRelationId());
213                    clone.setCompanyId(getCompanyId());
214                    clone.setCreateDate(getCreateDate());
215                    clone.setUserId1(getUserId1());
216                    clone.setUserId2(getUserId2());
217                    clone.setType(getType());
218    
219                    return clone;
220            }
221    
222            public int compareTo(SocialRelation socialRelation) {
223                    long pk = socialRelation.getPrimaryKey();
224    
225                    if (getPrimaryKey() < pk) {
226                            return -1;
227                    }
228                    else if (getPrimaryKey() > pk) {
229                            return 1;
230                    }
231                    else {
232                            return 0;
233                    }
234            }
235    
236            public boolean equals(Object obj) {
237                    if (obj == null) {
238                            return false;
239                    }
240    
241                    SocialRelation socialRelation = null;
242    
243                    try {
244                            socialRelation = (SocialRelation)obj;
245                    }
246                    catch (ClassCastException cce) {
247                            return false;
248                    }
249    
250                    long pk = socialRelation.getPrimaryKey();
251    
252                    if (getPrimaryKey() == pk) {
253                            return true;
254                    }
255                    else {
256                            return false;
257                    }
258            }
259    
260            public int hashCode() {
261                    return (int)getPrimaryKey();
262            }
263    
264            public String toString() {
265                    StringBundler sb = new StringBundler(15);
266    
267                    sb.append("{uuid=");
268                    sb.append(getUuid());
269                    sb.append(", relationId=");
270                    sb.append(getRelationId());
271                    sb.append(", companyId=");
272                    sb.append(getCompanyId());
273                    sb.append(", createDate=");
274                    sb.append(getCreateDate());
275                    sb.append(", userId1=");
276                    sb.append(getUserId1());
277                    sb.append(", userId2=");
278                    sb.append(getUserId2());
279                    sb.append(", type=");
280                    sb.append(getType());
281                    sb.append("}");
282    
283                    return sb.toString();
284            }
285    
286            public String toXmlString() {
287                    StringBundler sb = new StringBundler(25);
288    
289                    sb.append("<model><model-name>");
290                    sb.append("com.liferay.portlet.social.model.SocialRelation");
291                    sb.append("</model-name>");
292    
293                    sb.append(
294                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
295                    sb.append(getUuid());
296                    sb.append("]]></column-value></column>");
297                    sb.append(
298                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
299                    sb.append(getRelationId());
300                    sb.append("]]></column-value></column>");
301                    sb.append(
302                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
303                    sb.append(getCompanyId());
304                    sb.append("]]></column-value></column>");
305                    sb.append(
306                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
307                    sb.append(getCreateDate());
308                    sb.append("]]></column-value></column>");
309                    sb.append(
310                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
311                    sb.append(getUserId1());
312                    sb.append("]]></column-value></column>");
313                    sb.append(
314                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
315                    sb.append(getUserId2());
316                    sb.append("]]></column-value></column>");
317                    sb.append(
318                            "<column><column-name>type</column-name><column-value><![CDATA[");
319                    sb.append(getType());
320                    sb.append("]]></column-value></column>");
321    
322                    sb.append("</model>");
323    
324                    return sb.toString();
325            }
326    
327            private String _uuid;
328            private long _relationId;
329            private long _companyId;
330            private long _createDate;
331            private long _userId1;
332            private long _originalUserId1;
333            private boolean _setOriginalUserId1;
334            private long _userId2;
335            private long _originalUserId2;
336            private boolean _setOriginalUserId2;
337            private int _type;
338            private int _originalType;
339            private boolean _setOriginalType;
340            private transient ExpandoBridge _expandoBridge;
341    }