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