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    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * 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.
039     *
040     * <p>
041     * 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}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see PortalPreferencesImpl
046     * @see com.liferay.portal.model.PortalPreferences
047     * @see com.liferay.portal.model.PortalPreferencesModel
048     * @generated
049     */
050    public class PortalPreferencesModelImpl extends BaseModelImpl<PortalPreferences>
051            implements PortalPreferencesModel {
052            /*
053             * NOTE FOR DEVELOPERS:
054             *
055             * 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.
056             */
057            public static final String TABLE_NAME = "PortalPreferences";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "portalPreferencesId", Types.BIGINT },
060                            { "ownerId", Types.BIGINT },
061                            { "ownerType", Types.INTEGER },
062                            { "preferences", Types.CLOB }
063                    };
064            public static final String TABLE_SQL_CREATE = "create table PortalPreferences (portalPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,preferences TEXT null)";
065            public static final String TABLE_SQL_DROP = "drop table PortalPreferences";
066            public static final String ORDER_BY_JPQL = " ORDER BY portalPreferences.portalPreferencesId ASC";
067            public static final String ORDER_BY_SQL = " ORDER BY PortalPreferences.portalPreferencesId ASC";
068            public static final String DATA_SOURCE = "liferayDataSource";
069            public static final String SESSION_FACTORY = "liferaySessionFactory";
070            public static final String TX_MANAGER = "liferayTransactionManager";
071            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PortalPreferences"),
073                            true);
074            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PortalPreferences"),
076                            true);
077            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PortalPreferences"),
079                            true);
080            public static long OWNERID_COLUMN_BITMASK = 1L;
081            public static long OWNERTYPE_COLUMN_BITMASK = 2L;
082            public static long PORTALPREFERENCESID_COLUMN_BITMASK = 4L;
083            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
084                                    "lock.expiration.time.com.liferay.portal.model.PortalPreferences"));
085    
086            public PortalPreferencesModelImpl() {
087            }
088    
089            public long getPrimaryKey() {
090                    return _portalPreferencesId;
091            }
092    
093            public void setPrimaryKey(long primaryKey) {
094                    setPortalPreferencesId(primaryKey);
095            }
096    
097            public Serializable getPrimaryKeyObj() {
098                    return new Long(_portalPreferencesId);
099            }
100    
101            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
102                    setPrimaryKey(((Long)primaryKeyObj).longValue());
103            }
104    
105            public Class<?> getModelClass() {
106                    return PortalPreferences.class;
107            }
108    
109            public String getModelClassName() {
110                    return PortalPreferences.class.getName();
111            }
112    
113            @Override
114            public Map<String, Object> getModelAttributes() {
115                    Map<String, Object> attributes = new HashMap<String, Object>();
116    
117                    attributes.put("portalPreferencesId", getPortalPreferencesId());
118                    attributes.put("ownerId", getOwnerId());
119                    attributes.put("ownerType", getOwnerType());
120                    attributes.put("preferences", getPreferences());
121    
122                    return attributes;
123            }
124    
125            @Override
126            public void setModelAttributes(Map<String, Object> attributes) {
127                    Long portalPreferencesId = (Long)attributes.get("portalPreferencesId");
128    
129                    if (portalPreferencesId != null) {
130                            setPortalPreferencesId(portalPreferencesId);
131                    }
132    
133                    Long ownerId = (Long)attributes.get("ownerId");
134    
135                    if (ownerId != null) {
136                            setOwnerId(ownerId);
137                    }
138    
139                    Integer ownerType = (Integer)attributes.get("ownerType");
140    
141                    if (ownerType != null) {
142                            setOwnerType(ownerType);
143                    }
144    
145                    String preferences = (String)attributes.get("preferences");
146    
147                    if (preferences != null) {
148                            setPreferences(preferences);
149                    }
150            }
151    
152            public long getPortalPreferencesId() {
153                    return _portalPreferencesId;
154            }
155    
156            public void setPortalPreferencesId(long portalPreferencesId) {
157                    _portalPreferencesId = portalPreferencesId;
158            }
159    
160            public long getOwnerId() {
161                    return _ownerId;
162            }
163    
164            public void setOwnerId(long ownerId) {
165                    _columnBitmask |= OWNERID_COLUMN_BITMASK;
166    
167                    if (!_setOriginalOwnerId) {
168                            _setOriginalOwnerId = true;
169    
170                            _originalOwnerId = _ownerId;
171                    }
172    
173                    _ownerId = ownerId;
174            }
175    
176            public long getOriginalOwnerId() {
177                    return _originalOwnerId;
178            }
179    
180            public int getOwnerType() {
181                    return _ownerType;
182            }
183    
184            public void setOwnerType(int ownerType) {
185                    _columnBitmask |= OWNERTYPE_COLUMN_BITMASK;
186    
187                    if (!_setOriginalOwnerType) {
188                            _setOriginalOwnerType = true;
189    
190                            _originalOwnerType = _ownerType;
191                    }
192    
193                    _ownerType = ownerType;
194            }
195    
196            public int getOriginalOwnerType() {
197                    return _originalOwnerType;
198            }
199    
200            public String getPreferences() {
201                    if (_preferences == null) {
202                            return StringPool.BLANK;
203                    }
204                    else {
205                            return _preferences;
206                    }
207            }
208    
209            public void setPreferences(String preferences) {
210                    _preferences = preferences;
211            }
212    
213            public long getColumnBitmask() {
214                    return _columnBitmask;
215            }
216    
217            @Override
218            public ExpandoBridge getExpandoBridge() {
219                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
220                            PortalPreferences.class.getName(), getPrimaryKey());
221            }
222    
223            @Override
224            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
225                    ExpandoBridge expandoBridge = getExpandoBridge();
226    
227                    expandoBridge.setAttributes(serviceContext);
228            }
229    
230            @Override
231            public PortalPreferences toEscapedModel() {
232                    if (_escapedModel == null) {
233                            _escapedModel = (PortalPreferences)ProxyUtil.newProxyInstance(_classLoader,
234                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
235                    }
236    
237                    return _escapedModel;
238            }
239    
240            @Override
241            public Object clone() {
242                    PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
243    
244                    portalPreferencesImpl.setPortalPreferencesId(getPortalPreferencesId());
245                    portalPreferencesImpl.setOwnerId(getOwnerId());
246                    portalPreferencesImpl.setOwnerType(getOwnerType());
247                    portalPreferencesImpl.setPreferences(getPreferences());
248    
249                    portalPreferencesImpl.resetOriginalValues();
250    
251                    return portalPreferencesImpl;
252            }
253    
254            public int compareTo(PortalPreferences portalPreferences) {
255                    long primaryKey = portalPreferences.getPrimaryKey();
256    
257                    if (getPrimaryKey() < primaryKey) {
258                            return -1;
259                    }
260                    else if (getPrimaryKey() > primaryKey) {
261                            return 1;
262                    }
263                    else {
264                            return 0;
265                    }
266            }
267    
268            @Override
269            public boolean equals(Object obj) {
270                    if (obj == null) {
271                            return false;
272                    }
273    
274                    PortalPreferences portalPreferences = null;
275    
276                    try {
277                            portalPreferences = (PortalPreferences)obj;
278                    }
279                    catch (ClassCastException cce) {
280                            return false;
281                    }
282    
283                    long primaryKey = portalPreferences.getPrimaryKey();
284    
285                    if (getPrimaryKey() == primaryKey) {
286                            return true;
287                    }
288                    else {
289                            return false;
290                    }
291            }
292    
293            @Override
294            public int hashCode() {
295                    return (int)getPrimaryKey();
296            }
297    
298            @Override
299            public void resetOriginalValues() {
300                    PortalPreferencesModelImpl portalPreferencesModelImpl = this;
301    
302                    portalPreferencesModelImpl._originalOwnerId = portalPreferencesModelImpl._ownerId;
303    
304                    portalPreferencesModelImpl._setOriginalOwnerId = false;
305    
306                    portalPreferencesModelImpl._originalOwnerType = portalPreferencesModelImpl._ownerType;
307    
308                    portalPreferencesModelImpl._setOriginalOwnerType = false;
309    
310                    portalPreferencesModelImpl._columnBitmask = 0;
311            }
312    
313            @Override
314            public CacheModel<PortalPreferences> toCacheModel() {
315                    PortalPreferencesCacheModel portalPreferencesCacheModel = new PortalPreferencesCacheModel();
316    
317                    portalPreferencesCacheModel.portalPreferencesId = getPortalPreferencesId();
318    
319                    portalPreferencesCacheModel.ownerId = getOwnerId();
320    
321                    portalPreferencesCacheModel.ownerType = getOwnerType();
322    
323                    portalPreferencesCacheModel.preferences = getPreferences();
324    
325                    String preferences = portalPreferencesCacheModel.preferences;
326    
327                    if ((preferences != null) && (preferences.length() == 0)) {
328                            portalPreferencesCacheModel.preferences = null;
329                    }
330    
331                    return portalPreferencesCacheModel;
332            }
333    
334            @Override
335            public String toString() {
336                    StringBundler sb = new StringBundler(9);
337    
338                    sb.append("{portalPreferencesId=");
339                    sb.append(getPortalPreferencesId());
340                    sb.append(", ownerId=");
341                    sb.append(getOwnerId());
342                    sb.append(", ownerType=");
343                    sb.append(getOwnerType());
344                    sb.append(", preferences=");
345                    sb.append(getPreferences());
346                    sb.append("}");
347    
348                    return sb.toString();
349            }
350    
351            public String toXmlString() {
352                    StringBundler sb = new StringBundler(16);
353    
354                    sb.append("<model><model-name>");
355                    sb.append("com.liferay.portal.model.PortalPreferences");
356                    sb.append("</model-name>");
357    
358                    sb.append(
359                            "<column><column-name>portalPreferencesId</column-name><column-value><![CDATA[");
360                    sb.append(getPortalPreferencesId());
361                    sb.append("]]></column-value></column>");
362                    sb.append(
363                            "<column><column-name>ownerId</column-name><column-value><![CDATA[");
364                    sb.append(getOwnerId());
365                    sb.append("]]></column-value></column>");
366                    sb.append(
367                            "<column><column-name>ownerType</column-name><column-value><![CDATA[");
368                    sb.append(getOwnerType());
369                    sb.append("]]></column-value></column>");
370                    sb.append(
371                            "<column><column-name>preferences</column-name><column-value><![CDATA[");
372                    sb.append(getPreferences());
373                    sb.append("]]></column-value></column>");
374    
375                    sb.append("</model>");
376    
377                    return sb.toString();
378            }
379    
380            private static ClassLoader _classLoader = PortalPreferences.class.getClassLoader();
381            private static Class<?>[] _escapedModelInterfaces = new Class[] {
382                            PortalPreferences.class
383                    };
384            private long _portalPreferencesId;
385            private long _ownerId;
386            private long _originalOwnerId;
387            private boolean _setOriginalOwnerId;
388            private int _ownerType;
389            private int _originalOwnerType;
390            private boolean _setOriginalOwnerType;
391            private String _preferences;
392            private long _columnBitmask;
393            private PortalPreferences _escapedModel;
394    }