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