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     * <p>
037     * This interface is a model that represents the SocialRelation table in the
038     * database.
039     * </p>
040     *
041     * @author    Brian Wing Shun Chan
042     * @see       SocialRelationImpl
043     * @see       com.liferay.portlet.social.model.SocialRelation
044     * @see       com.liferay.portlet.social.model.SocialRelationModel
045     * @generated
046     */
047    public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation>
048            implements SocialRelationModel {
049            public static final String TABLE_NAME = "SocialRelation";
050            public static final Object[][] TABLE_COLUMNS = {
051                            { "uuid_", new Integer(Types.VARCHAR) },
052                            { "relationId", new Integer(Types.BIGINT) },
053                            { "companyId", new Integer(Types.BIGINT) },
054                            { "createDate", new Integer(Types.BIGINT) },
055                            { "userId1", new Integer(Types.BIGINT) },
056                            { "userId2", new Integer(Types.BIGINT) },
057                            { "type_", new Integer(Types.INTEGER) }
058                    };
059            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)";
060            public static final String TABLE_SQL_DROP = "drop table SocialRelation";
061            public static final String DATA_SOURCE = "liferayDataSource";
062            public static final String SESSION_FACTORY = "liferaySessionFactory";
063            public static final String TX_MANAGER = "liferayTransactionManager";
064            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
065                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
066                            true);
067            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
068                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
069                            true);
070            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
071                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
072    
073            public SocialRelationModelImpl() {
074            }
075    
076            public long getPrimaryKey() {
077                    return _relationId;
078            }
079    
080            public void setPrimaryKey(long pk) {
081                    setRelationId(pk);
082            }
083    
084            public Serializable getPrimaryKeyObj() {
085                    return new Long(_relationId);
086            }
087    
088            public String getUuid() {
089                    if (_uuid == null) {
090                            return StringPool.BLANK;
091                    }
092                    else {
093                            return _uuid;
094                    }
095            }
096    
097            public void setUuid(String uuid) {
098                    _uuid = uuid;
099            }
100    
101            public long getRelationId() {
102                    return _relationId;
103            }
104    
105            public void setRelationId(long relationId) {
106                    _relationId = relationId;
107            }
108    
109            public long getCompanyId() {
110                    return _companyId;
111            }
112    
113            public void setCompanyId(long companyId) {
114                    _companyId = companyId;
115            }
116    
117            public long getCreateDate() {
118                    return _createDate;
119            }
120    
121            public void setCreateDate(long createDate) {
122                    _createDate = createDate;
123            }
124    
125            public long getUserId1() {
126                    return _userId1;
127            }
128    
129            public void setUserId1(long userId1) {
130                    _userId1 = userId1;
131    
132                    if (!_setOriginalUserId1) {
133                            _setOriginalUserId1 = true;
134    
135                            _originalUserId1 = userId1;
136                    }
137            }
138    
139            public long getOriginalUserId1() {
140                    return _originalUserId1;
141            }
142    
143            public long getUserId2() {
144                    return _userId2;
145            }
146    
147            public void setUserId2(long userId2) {
148                    _userId2 = userId2;
149    
150                    if (!_setOriginalUserId2) {
151                            _setOriginalUserId2 = true;
152    
153                            _originalUserId2 = userId2;
154                    }
155            }
156    
157            public long getOriginalUserId2() {
158                    return _originalUserId2;
159            }
160    
161            public int getType() {
162                    return _type;
163            }
164    
165            public void setType(int type) {
166                    _type = type;
167    
168                    if (!_setOriginalType) {
169                            _setOriginalType = true;
170    
171                            _originalType = type;
172                    }
173            }
174    
175            public int getOriginalType() {
176                    return _originalType;
177            }
178    
179            public SocialRelation toEscapedModel() {
180                    if (isEscapedModel()) {
181                            return (SocialRelation)this;
182                    }
183                    else {
184                            return (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
185                                    new Class[] { SocialRelation.class },
186                                    new AutoEscapeBeanHandler(this));
187                    }
188            }
189    
190            public ExpandoBridge getExpandoBridge() {
191                    if (_expandoBridge == null) {
192                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
193                                            SocialRelation.class.getName(), getPrimaryKey());
194                    }
195    
196                    return _expandoBridge;
197            }
198    
199            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
200                    getExpandoBridge().setAttributes(serviceContext);
201            }
202    
203            public Object clone() {
204                    SocialRelationImpl clone = new SocialRelationImpl();
205    
206                    clone.setUuid(getUuid());
207                    clone.setRelationId(getRelationId());
208                    clone.setCompanyId(getCompanyId());
209                    clone.setCreateDate(getCreateDate());
210                    clone.setUserId1(getUserId1());
211                    clone.setUserId2(getUserId2());
212                    clone.setType(getType());
213    
214                    return clone;
215            }
216    
217            public int compareTo(SocialRelation socialRelation) {
218                    long pk = socialRelation.getPrimaryKey();
219    
220                    if (getPrimaryKey() < pk) {
221                            return -1;
222                    }
223                    else if (getPrimaryKey() > pk) {
224                            return 1;
225                    }
226                    else {
227                            return 0;
228                    }
229            }
230    
231            public boolean equals(Object obj) {
232                    if (obj == null) {
233                            return false;
234                    }
235    
236                    SocialRelation socialRelation = null;
237    
238                    try {
239                            socialRelation = (SocialRelation)obj;
240                    }
241                    catch (ClassCastException cce) {
242                            return false;
243                    }
244    
245                    long pk = socialRelation.getPrimaryKey();
246    
247                    if (getPrimaryKey() == pk) {
248                            return true;
249                    }
250                    else {
251                            return false;
252                    }
253            }
254    
255            public int hashCode() {
256                    return (int)getPrimaryKey();
257            }
258    
259            public String toString() {
260                    StringBundler sb = new StringBundler(15);
261    
262                    sb.append("{uuid=");
263                    sb.append(getUuid());
264                    sb.append(", relationId=");
265                    sb.append(getRelationId());
266                    sb.append(", companyId=");
267                    sb.append(getCompanyId());
268                    sb.append(", createDate=");
269                    sb.append(getCreateDate());
270                    sb.append(", userId1=");
271                    sb.append(getUserId1());
272                    sb.append(", userId2=");
273                    sb.append(getUserId2());
274                    sb.append(", type=");
275                    sb.append(getType());
276                    sb.append("}");
277    
278                    return sb.toString();
279            }
280    
281            public String toXmlString() {
282                    StringBundler sb = new StringBundler(25);
283    
284                    sb.append("<model><model-name>");
285                    sb.append("com.liferay.portlet.social.model.SocialRelation");
286                    sb.append("</model-name>");
287    
288                    sb.append(
289                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
290                    sb.append(getUuid());
291                    sb.append("]]></column-value></column>");
292                    sb.append(
293                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
294                    sb.append(getRelationId());
295                    sb.append("]]></column-value></column>");
296                    sb.append(
297                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
298                    sb.append(getCompanyId());
299                    sb.append("]]></column-value></column>");
300                    sb.append(
301                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
302                    sb.append(getCreateDate());
303                    sb.append("]]></column-value></column>");
304                    sb.append(
305                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
306                    sb.append(getUserId1());
307                    sb.append("]]></column-value></column>");
308                    sb.append(
309                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
310                    sb.append(getUserId2());
311                    sb.append("]]></column-value></column>");
312                    sb.append(
313                            "<column><column-name>type</column-name><column-value><![CDATA[");
314                    sb.append(getType());
315                    sb.append("]]></column-value></column>");
316    
317                    sb.append("</model>");
318    
319                    return sb.toString();
320            }
321    
322            private String _uuid;
323            private long _relationId;
324            private long _companyId;
325            private long _createDate;
326            private long _userId1;
327            private long _originalUserId1;
328            private boolean _setOriginalUserId1;
329            private long _userId2;
330            private long _originalUserId2;
331            private boolean _setOriginalUserId2;
332            private int _type;
333            private int _originalType;
334            private boolean _setOriginalType;
335            private transient ExpandoBridge _expandoBridge;
336    }