001    /**
002     * Copyright (c) 2000-2011 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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.PortletPreferences;
022    import com.liferay.portal.model.PortletPreferencesModel;
023    import com.liferay.portal.model.PortletPreferencesSoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.List;
037    
038    /**
039     * The base model implementation for the PortletPreferences service. Represents a row in the "PortletPreferences" database table, with each column mapped to a property of this class.
040     *
041     * <p>
042     * This implementation and its corresponding interface {@link com.liferay.portal.model.PortletPreferencesModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortletPreferencesImpl}.
043     * </p>
044     *
045     * <p>
046     * Never modify or reference this class directly. All methods that expect a portlet preferences model instance should use the {@link com.liferay.portal.model.PortletPreferences} interface instead.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see PortletPreferencesImpl
051     * @see com.liferay.portal.model.PortletPreferences
052     * @see com.liferay.portal.model.PortletPreferencesModel
053     * @generated
054     */
055    public class PortletPreferencesModelImpl extends BaseModelImpl<PortletPreferences>
056            implements PortletPreferencesModel {
057            public static final String TABLE_NAME = "PortletPreferences";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "portletPreferencesId", new Integer(Types.BIGINT) },
060                            { "ownerId", new Integer(Types.BIGINT) },
061                            { "ownerType", new Integer(Types.INTEGER) },
062                            { "plid", new Integer(Types.BIGINT) },
063                            { "portletId", new Integer(Types.VARCHAR) },
064                            { "preferences", new Integer(Types.CLOB) }
065                    };
066            public static final String TABLE_SQL_CREATE = "create table PortletPreferences (portletPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,plid LONG,portletId VARCHAR(200) null,preferences TEXT null)";
067            public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
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.PortletPreferences"),
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.PortletPreferences"),
076                            true);
077    
078            /**
079             * Converts the soap model instance into a normal model instance.
080             *
081             * @param soapModel the soap model instance to convert
082             * @return the normal model instance
083             */
084            public static PortletPreferences toModel(PortletPreferencesSoap soapModel) {
085                    PortletPreferences model = new PortletPreferencesImpl();
086    
087                    model.setPortletPreferencesId(soapModel.getPortletPreferencesId());
088                    model.setOwnerId(soapModel.getOwnerId());
089                    model.setOwnerType(soapModel.getOwnerType());
090                    model.setPlid(soapModel.getPlid());
091                    model.setPortletId(soapModel.getPortletId());
092                    model.setPreferences(soapModel.getPreferences());
093    
094                    return model;
095            }
096    
097            /**
098             * Converts the soap model instances into normal model instances.
099             *
100             * @param soapModels the soap model instances to convert
101             * @return the normal model instances
102             */
103            public static List<PortletPreferences> toModels(
104                    PortletPreferencesSoap[] soapModels) {
105                    List<PortletPreferences> models = new ArrayList<PortletPreferences>(soapModels.length);
106    
107                    for (PortletPreferencesSoap soapModel : soapModels) {
108                            models.add(toModel(soapModel));
109                    }
110    
111                    return models;
112            }
113    
114            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                                    "lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
116    
117            public PortletPreferencesModelImpl() {
118            }
119    
120            public long getPrimaryKey() {
121                    return _portletPreferencesId;
122            }
123    
124            public void setPrimaryKey(long pk) {
125                    setPortletPreferencesId(pk);
126            }
127    
128            public Serializable getPrimaryKeyObj() {
129                    return new Long(_portletPreferencesId);
130            }
131    
132            public long getPortletPreferencesId() {
133                    return _portletPreferencesId;
134            }
135    
136            public void setPortletPreferencesId(long portletPreferencesId) {
137                    _portletPreferencesId = portletPreferencesId;
138            }
139    
140            public long getOwnerId() {
141                    return _ownerId;
142            }
143    
144            public void setOwnerId(long ownerId) {
145                    if (!_setOriginalOwnerId) {
146                            _setOriginalOwnerId = true;
147    
148                            _originalOwnerId = _ownerId;
149                    }
150    
151                    _ownerId = ownerId;
152            }
153    
154            public long getOriginalOwnerId() {
155                    return _originalOwnerId;
156            }
157    
158            public int getOwnerType() {
159                    return _ownerType;
160            }
161    
162            public void setOwnerType(int ownerType) {
163                    if (!_setOriginalOwnerType) {
164                            _setOriginalOwnerType = true;
165    
166                            _originalOwnerType = _ownerType;
167                    }
168    
169                    _ownerType = ownerType;
170            }
171    
172            public int getOriginalOwnerType() {
173                    return _originalOwnerType;
174            }
175    
176            public long getPlid() {
177                    return _plid;
178            }
179    
180            public void setPlid(long plid) {
181                    if (!_setOriginalPlid) {
182                            _setOriginalPlid = true;
183    
184                            _originalPlid = _plid;
185                    }
186    
187                    _plid = plid;
188            }
189    
190            public long getOriginalPlid() {
191                    return _originalPlid;
192            }
193    
194            public String getPortletId() {
195                    if (_portletId == null) {
196                            return StringPool.BLANK;
197                    }
198                    else {
199                            return _portletId;
200                    }
201            }
202    
203            public void setPortletId(String portletId) {
204                    if (_originalPortletId == null) {
205                            _originalPortletId = _portletId;
206                    }
207    
208                    _portletId = portletId;
209            }
210    
211            public String getOriginalPortletId() {
212                    return GetterUtil.getString(_originalPortletId);
213            }
214    
215            public String getPreferences() {
216                    if (_preferences == null) {
217                            return StringPool.BLANK;
218                    }
219                    else {
220                            return _preferences;
221                    }
222            }
223    
224            public void setPreferences(String preferences) {
225                    _preferences = preferences;
226            }
227    
228            public PortletPreferences toEscapedModel() {
229                    if (isEscapedModel()) {
230                            return (PortletPreferences)this;
231                    }
232                    else {
233                            return (PortletPreferences)Proxy.newProxyInstance(PortletPreferences.class.getClassLoader(),
234                                    new Class[] { PortletPreferences.class },
235                                    new AutoEscapeBeanHandler(this));
236                    }
237            }
238    
239            public ExpandoBridge getExpandoBridge() {
240                    if (_expandoBridge == null) {
241                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
242                                            PortletPreferences.class.getName(), getPrimaryKey());
243                    }
244    
245                    return _expandoBridge;
246            }
247    
248            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
249                    getExpandoBridge().setAttributes(serviceContext);
250            }
251    
252            public Object clone() {
253                    PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
254    
255                    portletPreferencesImpl.setPortletPreferencesId(getPortletPreferencesId());
256    
257                    portletPreferencesImpl.setOwnerId(getOwnerId());
258    
259                    PortletPreferencesModelImpl portletPreferencesModelImpl = portletPreferencesImpl;
260    
261                    portletPreferencesModelImpl._originalOwnerId = portletPreferencesModelImpl._ownerId;
262    
263                    portletPreferencesModelImpl._setOriginalOwnerId = false;
264                    portletPreferencesImpl.setOwnerType(getOwnerType());
265    
266                    portletPreferencesModelImpl._originalOwnerType = portletPreferencesModelImpl._ownerType;
267    
268                    portletPreferencesModelImpl._setOriginalOwnerType = false;
269                    portletPreferencesImpl.setPlid(getPlid());
270    
271                    portletPreferencesModelImpl._originalPlid = portletPreferencesModelImpl._plid;
272    
273                    portletPreferencesModelImpl._setOriginalPlid = false;
274                    portletPreferencesImpl.setPortletId(getPortletId());
275    
276                    portletPreferencesModelImpl._originalPortletId = portletPreferencesModelImpl._portletId;
277    
278                    portletPreferencesImpl.setPreferences(getPreferences());
279    
280                    return portletPreferencesImpl;
281            }
282    
283            public int compareTo(PortletPreferences portletPreferences) {
284                    long pk = portletPreferences.getPrimaryKey();
285    
286                    if (getPrimaryKey() < pk) {
287                            return -1;
288                    }
289                    else if (getPrimaryKey() > pk) {
290                            return 1;
291                    }
292                    else {
293                            return 0;
294                    }
295            }
296    
297            public boolean equals(Object obj) {
298                    if (obj == null) {
299                            return false;
300                    }
301    
302                    PortletPreferences portletPreferences = null;
303    
304                    try {
305                            portletPreferences = (PortletPreferences)obj;
306                    }
307                    catch (ClassCastException cce) {
308                            return false;
309                    }
310    
311                    long pk = portletPreferences.getPrimaryKey();
312    
313                    if (getPrimaryKey() == pk) {
314                            return true;
315                    }
316                    else {
317                            return false;
318                    }
319            }
320    
321            public int hashCode() {
322                    return (int)getPrimaryKey();
323            }
324    
325            public String toString() {
326                    StringBundler sb = new StringBundler(13);
327    
328                    sb.append("{portletPreferencesId=");
329                    sb.append(getPortletPreferencesId());
330                    sb.append(", ownerId=");
331                    sb.append(getOwnerId());
332                    sb.append(", ownerType=");
333                    sb.append(getOwnerType());
334                    sb.append(", plid=");
335                    sb.append(getPlid());
336                    sb.append(", portletId=");
337                    sb.append(getPortletId());
338                    sb.append(", preferences=");
339                    sb.append(getPreferences());
340                    sb.append("}");
341    
342                    return sb.toString();
343            }
344    
345            public String toXmlString() {
346                    StringBundler sb = new StringBundler(22);
347    
348                    sb.append("<model><model-name>");
349                    sb.append("com.liferay.portal.model.PortletPreferences");
350                    sb.append("</model-name>");
351    
352                    sb.append(
353                            "<column><column-name>portletPreferencesId</column-name><column-value><![CDATA[");
354                    sb.append(getPortletPreferencesId());
355                    sb.append("]]></column-value></column>");
356                    sb.append(
357                            "<column><column-name>ownerId</column-name><column-value><![CDATA[");
358                    sb.append(getOwnerId());
359                    sb.append("]]></column-value></column>");
360                    sb.append(
361                            "<column><column-name>ownerType</column-name><column-value><![CDATA[");
362                    sb.append(getOwnerType());
363                    sb.append("]]></column-value></column>");
364                    sb.append(
365                            "<column><column-name>plid</column-name><column-value><![CDATA[");
366                    sb.append(getPlid());
367                    sb.append("]]></column-value></column>");
368                    sb.append(
369                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
370                    sb.append(getPortletId());
371                    sb.append("]]></column-value></column>");
372                    sb.append(
373                            "<column><column-name>preferences</column-name><column-value><![CDATA[");
374                    sb.append(getPreferences());
375                    sb.append("]]></column-value></column>");
376    
377                    sb.append("</model>");
378    
379                    return sb.toString();
380            }
381    
382            private long _portletPreferencesId;
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 long _plid;
390            private long _originalPlid;
391            private boolean _setOriginalPlid;
392            private String _portletId;
393            private String _originalPortletId;
394            private String _preferences;
395            private transient ExpandoBridge _expandoBridge;
396    }