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