001    /**
002     * Copyright (c) 2000-2010 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.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.wiki.model.WikiNode;
029    import com.liferay.portlet.wiki.model.WikiNodeModel;
030    import com.liferay.portlet.wiki.model.WikiNodeSoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the WikiNode service. Represents a row in the "WikiNode" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.wiki.model.WikiNodeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link WikiNodeImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a wiki node model instance should use the {@link com.liferay.portlet.wiki.model.WikiNode} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see WikiNodeImpl
055     * @see com.liferay.portlet.wiki.model.WikiNode
056     * @see com.liferay.portlet.wiki.model.WikiNodeModel
057     * @generated
058     */
059    public class WikiNodeModelImpl extends BaseModelImpl<WikiNode>
060            implements WikiNodeModel {
061            public static final String TABLE_NAME = "WikiNode";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "uuid_", new Integer(Types.VARCHAR) },
064                            { "nodeId", new Integer(Types.BIGINT) },
065                            { "groupId", new Integer(Types.BIGINT) },
066                            { "companyId", new Integer(Types.BIGINT) },
067                            { "userId", new Integer(Types.BIGINT) },
068                            { "userName", new Integer(Types.VARCHAR) },
069                            { "createDate", new Integer(Types.TIMESTAMP) },
070                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
071                            { "name", new Integer(Types.VARCHAR) },
072                            { "description", new Integer(Types.VARCHAR) },
073                            { "lastPostDate", new Integer(Types.TIMESTAMP) }
074                    };
075            public static final String TABLE_SQL_CREATE = "create table WikiNode (uuid_ VARCHAR(75) null,nodeId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,description STRING null,lastPostDate DATE null)";
076            public static final String TABLE_SQL_DROP = "drop table WikiNode";
077            public static final String ORDER_BY_JPQL = " ORDER BY wikiNode.name ASC";
078            public static final String ORDER_BY_SQL = " ORDER BY WikiNode.name ASC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portlet.wiki.model.WikiNode"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiNode"),
087                            true);
088    
089            /**
090             * Converts the soap model instance into a normal model instance.
091             *
092             * @param soapModel the soap model instance to convert
093             * @return the normal model instance
094             */
095            public static WikiNode toModel(WikiNodeSoap soapModel) {
096                    WikiNode model = new WikiNodeImpl();
097    
098                    model.setUuid(soapModel.getUuid());
099                    model.setNodeId(soapModel.getNodeId());
100                    model.setGroupId(soapModel.getGroupId());
101                    model.setCompanyId(soapModel.getCompanyId());
102                    model.setUserId(soapModel.getUserId());
103                    model.setUserName(soapModel.getUserName());
104                    model.setCreateDate(soapModel.getCreateDate());
105                    model.setModifiedDate(soapModel.getModifiedDate());
106                    model.setName(soapModel.getName());
107                    model.setDescription(soapModel.getDescription());
108                    model.setLastPostDate(soapModel.getLastPostDate());
109    
110                    return model;
111            }
112    
113            /**
114             * Converts the soap model instances into normal model instances.
115             *
116             * @param soapModels the soap model instances to convert
117             * @return the normal model instances
118             */
119            public static List<WikiNode> toModels(WikiNodeSoap[] soapModels) {
120                    List<WikiNode> models = new ArrayList<WikiNode>(soapModels.length);
121    
122                    for (WikiNodeSoap soapModel : soapModels) {
123                            models.add(toModel(soapModel));
124                    }
125    
126                    return models;
127            }
128    
129            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                                    "lock.expiration.time.com.liferay.portlet.wiki.model.WikiNode"));
131    
132            public WikiNodeModelImpl() {
133            }
134    
135            public long getPrimaryKey() {
136                    return _nodeId;
137            }
138    
139            public void setPrimaryKey(long pk) {
140                    setNodeId(pk);
141            }
142    
143            public Serializable getPrimaryKeyObj() {
144                    return new Long(_nodeId);
145            }
146    
147            public String getUuid() {
148                    if (_uuid == null) {
149                            return StringPool.BLANK;
150                    }
151                    else {
152                            return _uuid;
153                    }
154            }
155    
156            public void setUuid(String uuid) {
157                    _uuid = uuid;
158    
159                    if (_originalUuid == null) {
160                            _originalUuid = uuid;
161                    }
162            }
163    
164            public String getOriginalUuid() {
165                    return GetterUtil.getString(_originalUuid);
166            }
167    
168            public long getNodeId() {
169                    return _nodeId;
170            }
171    
172            public void setNodeId(long nodeId) {
173                    _nodeId = nodeId;
174            }
175    
176            public long getGroupId() {
177                    return _groupId;
178            }
179    
180            public void setGroupId(long groupId) {
181                    _groupId = groupId;
182    
183                    if (!_setOriginalGroupId) {
184                            _setOriginalGroupId = true;
185    
186                            _originalGroupId = groupId;
187                    }
188            }
189    
190            public long getOriginalGroupId() {
191                    return _originalGroupId;
192            }
193    
194            public long getCompanyId() {
195                    return _companyId;
196            }
197    
198            public void setCompanyId(long companyId) {
199                    _companyId = companyId;
200            }
201    
202            public long getUserId() {
203                    return _userId;
204            }
205    
206            public void setUserId(long userId) {
207                    _userId = userId;
208            }
209    
210            public String getUserUuid() throws SystemException {
211                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
212            }
213    
214            public void setUserUuid(String userUuid) {
215                    _userUuid = userUuid;
216            }
217    
218            public String getUserName() {
219                    if (_userName == null) {
220                            return StringPool.BLANK;
221                    }
222                    else {
223                            return _userName;
224                    }
225            }
226    
227            public void setUserName(String userName) {
228                    _userName = userName;
229            }
230    
231            public Date getCreateDate() {
232                    return _createDate;
233            }
234    
235            public void setCreateDate(Date createDate) {
236                    _createDate = createDate;
237            }
238    
239            public Date getModifiedDate() {
240                    return _modifiedDate;
241            }
242    
243            public void setModifiedDate(Date modifiedDate) {
244                    _modifiedDate = modifiedDate;
245            }
246    
247            public String getName() {
248                    if (_name == null) {
249                            return StringPool.BLANK;
250                    }
251                    else {
252                            return _name;
253                    }
254            }
255    
256            public void setName(String name) {
257                    _name = name;
258    
259                    if (_originalName == null) {
260                            _originalName = name;
261                    }
262            }
263    
264            public String getOriginalName() {
265                    return GetterUtil.getString(_originalName);
266            }
267    
268            public String getDescription() {
269                    if (_description == null) {
270                            return StringPool.BLANK;
271                    }
272                    else {
273                            return _description;
274                    }
275            }
276    
277            public void setDescription(String description) {
278                    _description = description;
279            }
280    
281            public Date getLastPostDate() {
282                    return _lastPostDate;
283            }
284    
285            public void setLastPostDate(Date lastPostDate) {
286                    _lastPostDate = lastPostDate;
287            }
288    
289            public WikiNode toEscapedModel() {
290                    if (isEscapedModel()) {
291                            return (WikiNode)this;
292                    }
293                    else {
294                            return (WikiNode)Proxy.newProxyInstance(WikiNode.class.getClassLoader(),
295                                    new Class[] { WikiNode.class }, new AutoEscapeBeanHandler(this));
296                    }
297            }
298    
299            public ExpandoBridge getExpandoBridge() {
300                    if (_expandoBridge == null) {
301                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
302                                            WikiNode.class.getName(), getPrimaryKey());
303                    }
304    
305                    return _expandoBridge;
306            }
307    
308            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
309                    getExpandoBridge().setAttributes(serviceContext);
310            }
311    
312            public Object clone() {
313                    WikiNodeImpl clone = new WikiNodeImpl();
314    
315                    clone.setUuid(getUuid());
316                    clone.setNodeId(getNodeId());
317                    clone.setGroupId(getGroupId());
318                    clone.setCompanyId(getCompanyId());
319                    clone.setUserId(getUserId());
320                    clone.setUserName(getUserName());
321                    clone.setCreateDate(getCreateDate());
322                    clone.setModifiedDate(getModifiedDate());
323                    clone.setName(getName());
324                    clone.setDescription(getDescription());
325                    clone.setLastPostDate(getLastPostDate());
326    
327                    return clone;
328            }
329    
330            public int compareTo(WikiNode wikiNode) {
331                    int value = 0;
332    
333                    value = getName().toLowerCase()
334                                            .compareTo(wikiNode.getName().toLowerCase());
335    
336                    if (value != 0) {
337                            return value;
338                    }
339    
340                    return 0;
341            }
342    
343            public boolean equals(Object obj) {
344                    if (obj == null) {
345                            return false;
346                    }
347    
348                    WikiNode wikiNode = null;
349    
350                    try {
351                            wikiNode = (WikiNode)obj;
352                    }
353                    catch (ClassCastException cce) {
354                            return false;
355                    }
356    
357                    long pk = wikiNode.getPrimaryKey();
358    
359                    if (getPrimaryKey() == pk) {
360                            return true;
361                    }
362                    else {
363                            return false;
364                    }
365            }
366    
367            public int hashCode() {
368                    return (int)getPrimaryKey();
369            }
370    
371            public String toString() {
372                    StringBundler sb = new StringBundler(23);
373    
374                    sb.append("{uuid=");
375                    sb.append(getUuid());
376                    sb.append(", nodeId=");
377                    sb.append(getNodeId());
378                    sb.append(", groupId=");
379                    sb.append(getGroupId());
380                    sb.append(", companyId=");
381                    sb.append(getCompanyId());
382                    sb.append(", userId=");
383                    sb.append(getUserId());
384                    sb.append(", userName=");
385                    sb.append(getUserName());
386                    sb.append(", createDate=");
387                    sb.append(getCreateDate());
388                    sb.append(", modifiedDate=");
389                    sb.append(getModifiedDate());
390                    sb.append(", name=");
391                    sb.append(getName());
392                    sb.append(", description=");
393                    sb.append(getDescription());
394                    sb.append(", lastPostDate=");
395                    sb.append(getLastPostDate());
396                    sb.append("}");
397    
398                    return sb.toString();
399            }
400    
401            public String toXmlString() {
402                    StringBundler sb = new StringBundler(37);
403    
404                    sb.append("<model><model-name>");
405                    sb.append("com.liferay.portlet.wiki.model.WikiNode");
406                    sb.append("</model-name>");
407    
408                    sb.append(
409                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
410                    sb.append(getUuid());
411                    sb.append("]]></column-value></column>");
412                    sb.append(
413                            "<column><column-name>nodeId</column-name><column-value><![CDATA[");
414                    sb.append(getNodeId());
415                    sb.append("]]></column-value></column>");
416                    sb.append(
417                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
418                    sb.append(getGroupId());
419                    sb.append("]]></column-value></column>");
420                    sb.append(
421                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
422                    sb.append(getCompanyId());
423                    sb.append("]]></column-value></column>");
424                    sb.append(
425                            "<column><column-name>userId</column-name><column-value><![CDATA[");
426                    sb.append(getUserId());
427                    sb.append("]]></column-value></column>");
428                    sb.append(
429                            "<column><column-name>userName</column-name><column-value><![CDATA[");
430                    sb.append(getUserName());
431                    sb.append("]]></column-value></column>");
432                    sb.append(
433                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
434                    sb.append(getCreateDate());
435                    sb.append("]]></column-value></column>");
436                    sb.append(
437                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
438                    sb.append(getModifiedDate());
439                    sb.append("]]></column-value></column>");
440                    sb.append(
441                            "<column><column-name>name</column-name><column-value><![CDATA[");
442                    sb.append(getName());
443                    sb.append("]]></column-value></column>");
444                    sb.append(
445                            "<column><column-name>description</column-name><column-value><![CDATA[");
446                    sb.append(getDescription());
447                    sb.append("]]></column-value></column>");
448                    sb.append(
449                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
450                    sb.append(getLastPostDate());
451                    sb.append("]]></column-value></column>");
452    
453                    sb.append("</model>");
454    
455                    return sb.toString();
456            }
457    
458            private String _uuid;
459            private String _originalUuid;
460            private long _nodeId;
461            private long _groupId;
462            private long _originalGroupId;
463            private boolean _setOriginalGroupId;
464            private long _companyId;
465            private long _userId;
466            private String _userUuid;
467            private String _userName;
468            private Date _createDate;
469            private Date _modifiedDate;
470            private String _name;
471            private String _originalName;
472            private String _description;
473            private Date _lastPostDate;
474            private transient ExpandoBridge _expandoBridge;
475    }