001    /**
002     * Copyright (c) 2000-2012 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.portal.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.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.PortalPreferences;
024    import com.liferay.portal.model.PortalPreferencesModel;
025    import com.liferay.portal.service.ServiceContext;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.sql.Types;
033    
034    /**
035     * The base model implementation for the PortalPreferences service. Represents a row in the "PortalPreferences" database table, with each column mapped to a property of this class.
036     *
037     * <p>
038     * This implementation and its corresponding interface {@link com.liferay.portal.model.PortalPreferencesModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortalPreferencesImpl}.
039     * </p>
040     *
041     * @author Brian Wing Shun Chan
042     * @see PortalPreferencesImpl
043     * @see com.liferay.portal.model.PortalPreferences
044     * @see com.liferay.portal.model.PortalPreferencesModel
045     * @generated
046     */
047    public class PortalPreferencesModelImpl extends BaseModelImpl<PortalPreferences>
048            implements PortalPreferencesModel {
049            /*
050             * NOTE FOR DEVELOPERS:
051             *
052             * Never modify or reference this class directly. All methods that expect a portal preferences model instance should use the {@link com.liferay.portal.model.PortalPreferences} interface instead.
053             */
054            public static final String TABLE_NAME = "PortalPreferences";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "portalPreferencesId", Types.BIGINT },
057                            { "ownerId", Types.BIGINT },
058                            { "ownerType", Types.INTEGER },
059                            { "preferences", Types.CLOB }
060                    };
061            public static final String TABLE_SQL_CREATE = "create table PortalPreferences (portalPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,preferences TEXT null)";
062            public static final String TABLE_SQL_DROP = "drop table PortalPreferences";
063            public static final String DATA_SOURCE = "liferayDataSource";
064            public static final String SESSION_FACTORY = "liferaySessionFactory";
065            public static final String TX_MANAGER = "liferayTransactionManager";
066            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
067                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PortalPreferences"),
068                            true);
069            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PortalPreferences"),
071                            true);
072            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PortalPreferences"),
074                            true);
075            public static long OWNERID_COLUMN_BITMASK = 1L;
076            public static long OWNERTYPE_COLUMN_BITMASK = 2L;
077            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
078                                    "lock.expiration.time.com.liferay.portal.model.PortalPreferences"));
079    
080            public PortalPreferencesModelImpl() {
081            }
082    
083            public long getPrimaryKey() {
084                    return _portalPreferencesId;
085            }
086    
087            public void setPrimaryKey(long primaryKey) {
088                    setPortalPreferencesId(primaryKey);
089            }
090    
091            public Serializable getPrimaryKeyObj() {
092                    return new Long(_portalPreferencesId);
093            }
094    
095            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
096                    setPrimaryKey(((Long)primaryKeyObj).longValue());
097            }
098    
099            public Class<?> getModelClass() {
100                    return PortalPreferences.class;
101            }
102    
103            public String getModelClassName() {
104                    return PortalPreferences.class.getName();
105            }
106    
107            public long getPortalPreferencesId() {
108                    return _portalPreferencesId;
109            }
110    
111            public void setPortalPreferencesId(long portalPreferencesId) {
112                    _portalPreferencesId = portalPreferencesId;
113            }
114    
115            public long getOwnerId() {
116                    return _ownerId;
117            }
118    
119            public void setOwnerId(long ownerId) {
120                    _columnBitmask |= OWNERID_COLUMN_BITMASK;
121    
122                    if (!_setOriginalOwnerId) {
123                            _setOriginalOwnerId = true;
124    
125                            _originalOwnerId = _ownerId;
126                    }
127    
128                    _ownerId = ownerId;
129            }
130    
131            public long getOriginalOwnerId() {
132                    return _originalOwnerId;
133            }
134    
135            public int getOwnerType() {
136                    return _ownerType;
137            }
138    
139            public void setOwnerType(int ownerType) {
140                    _columnBitmask |= OWNERTYPE_COLUMN_BITMASK;
141    
142                    if (!_setOriginalOwnerType) {
143                            _setOriginalOwnerType = true;
144    
145                            _originalOwnerType = _ownerType;
146                    }
147    
148                    _ownerType = ownerType;
149            }
150    
151            public int getOriginalOwnerType() {
152                    return _originalOwnerType;
153            }
154    
155            public String getPreferences() {
156                    if (_preferences == null) {
157                            return StringPool.BLANK;
158                    }
159                    else {
160                            return _preferences;
161                    }
162            }
163    
164            public void setPreferences(String preferences) {
165                    _preferences = preferences;
166            }
167    
168            public long getColumnBitmask() {
169                    return _columnBitmask;
170            }
171    
172            @Override
173            public PortalPreferences toEscapedModel() {
174                    if (_escapedModelProxy == null) {
175                            _escapedModelProxy = (PortalPreferences)ProxyUtil.newProxyInstance(_classLoader,
176                                            _escapedModelProxyInterfaces,
177                                            new AutoEscapeBeanHandler(this));
178                    }
179    
180                    return _escapedModelProxy;
181            }
182    
183            @Override
184            public ExpandoBridge getExpandoBridge() {
185                    if (_expandoBridge == null) {
186                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
187                                            PortalPreferences.class.getName(), getPrimaryKey());
188                    }
189    
190                    return _expandoBridge;
191            }
192    
193            @Override
194            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
195                    getExpandoBridge().setAttributes(serviceContext);
196            }
197    
198            @Override
199            public Object clone() {
200                    PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
201    
202                    portalPreferencesImpl.setPortalPreferencesId(getPortalPreferencesId());
203                    portalPreferencesImpl.setOwnerId(getOwnerId());
204                    portalPreferencesImpl.setOwnerType(getOwnerType());
205                    portalPreferencesImpl.setPreferences(getPreferences());
206    
207                    portalPreferencesImpl.resetOriginalValues();
208    
209                    return portalPreferencesImpl;
210            }
211    
212            public int compareTo(PortalPreferences portalPreferences) {
213                    long primaryKey = portalPreferences.getPrimaryKey();
214    
215                    if (getPrimaryKey() < primaryKey) {
216                            return -1;
217                    }
218                    else if (getPrimaryKey() > primaryKey) {
219                            return 1;
220                    }
221                    else {
222                            return 0;
223                    }
224            }
225    
226            @Override
227            public boolean equals(Object obj) {
228                    if (obj == null) {
229                            return false;
230                    }
231    
232                    PortalPreferences portalPreferences = null;
233    
234                    try {
235                            portalPreferences = (PortalPreferences)obj;
236                    }
237                    catch (ClassCastException cce) {
238                            return false;
239                    }
240    
241                    long primaryKey = portalPreferences.getPrimaryKey();
242    
243                    if (getPrimaryKey() == primaryKey) {
244                            return true;
245                    }
246                    else {
247                            return false;
248                    }
249            }
250    
251            @Override
252            public int hashCode() {
253                    return (int)getPrimaryKey();
254            }
255    
256            @Override
257            public void resetOriginalValues() {
258                    PortalPreferencesModelImpl portalPreferencesModelImpl = this;
259    
260                    portalPreferencesModelImpl._originalOwnerId = portalPreferencesModelImpl._ownerId;
261    
262                    portalPreferencesModelImpl._setOriginalOwnerId = false;
263    
264                    portalPreferencesModelImpl._originalOwnerType = portalPreferencesModelImpl._ownerType;
265    
266                    portalPreferencesModelImpl._setOriginalOwnerType = false;
267    
268                    portalPreferencesModelImpl._columnBitmask = 0;
269            }
270    
271            @Override
272            public CacheModel<PortalPreferences> toCacheModel() {
273                    PortalPreferencesCacheModel portalPreferencesCacheModel = new PortalPreferencesCacheModel();
274    
275                    portalPreferencesCacheModel.portalPreferencesId = getPortalPreferencesId();
276    
277                    portalPreferencesCacheModel.ownerId = getOwnerId();
278    
279                    portalPreferencesCacheModel.ownerType = getOwnerType();
280    
281                    portalPreferencesCacheModel.preferences = getPreferences();
282    
283                    String preferences = portalPreferencesCacheModel.preferences;
284    
285                    if ((preferences != null) && (preferences.length() == 0)) {
286                            portalPreferencesCacheModel.preferences = null;
287                    }
288    
289                    return portalPreferencesCacheModel;
290            }
291    
292            @Override
293            public String toString() {
294                    StringBundler sb = new StringBundler(9);
295    
296                    sb.append("{portalPreferencesId=");
297                    sb.append(getPortalPreferencesId());
298                    sb.append(", ownerId=");
299                    sb.append(getOwnerId());
300                    sb.append(", ownerType=");
301                    sb.append(getOwnerType());
302                    sb.append(", preferences=");
303                    sb.append(getPreferences());
304                    sb.append("}");
305    
306                    return sb.toString();
307            }
308    
309            public String toXmlString() {
310                    StringBundler sb = new StringBundler(16);
311    
312                    sb.append("<model><model-name>");
313                    sb.append("com.liferay.portal.model.PortalPreferences");
314                    sb.append("</model-name>");
315    
316                    sb.append(
317                            "<column><column-name>portalPreferencesId</column-name><column-value><![CDATA[");
318                    sb.append(getPortalPreferencesId());
319                    sb.append("]]></column-value></column>");
320                    sb.append(
321                            "<column><column-name>ownerId</column-name><column-value><![CDATA[");
322                    sb.append(getOwnerId());
323                    sb.append("]]></column-value></column>");
324                    sb.append(
325                            "<column><column-name>ownerType</column-name><column-value><![CDATA[");
326                    sb.append(getOwnerType());
327                    sb.append("]]></column-value></column>");
328                    sb.append(
329                            "<column><column-name>preferences</column-name><column-value><![CDATA[");
330                    sb.append(getPreferences());
331                    sb.append("]]></column-value></column>");
332    
333                    sb.append("</model>");
334    
335                    return sb.toString();
336            }
337    
338            private static ClassLoader _classLoader = PortalPreferences.class.getClassLoader();
339            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
340                            PortalPreferences.class
341                    };
342            private long _portalPreferencesId;
343            private long _ownerId;
344            private long _originalOwnerId;
345            private boolean _setOriginalOwnerId;
346            private int _ownerType;
347            private int _originalOwnerType;
348            private boolean _setOriginalOwnerType;
349            private String _preferences;
350            private transient ExpandoBridge _expandoBridge;
351            private long _columnBitmask;
352            private PortalPreferences _escapedModelProxy;
353    }