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