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.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.wiki.model.WikiNode;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing WikiNode in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see WikiNode
035     * @generated
036     */
037    public class WikiNodeCacheModel implements CacheModel<WikiNode>, Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(31);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", nodeId=");
045                    sb.append(nodeId);
046                    sb.append(", groupId=");
047                    sb.append(groupId);
048                    sb.append(", companyId=");
049                    sb.append(companyId);
050                    sb.append(", userId=");
051                    sb.append(userId);
052                    sb.append(", userName=");
053                    sb.append(userName);
054                    sb.append(", createDate=");
055                    sb.append(createDate);
056                    sb.append(", modifiedDate=");
057                    sb.append(modifiedDate);
058                    sb.append(", name=");
059                    sb.append(name);
060                    sb.append(", description=");
061                    sb.append(description);
062                    sb.append(", lastPostDate=");
063                    sb.append(lastPostDate);
064                    sb.append(", status=");
065                    sb.append(status);
066                    sb.append(", statusByUserId=");
067                    sb.append(statusByUserId);
068                    sb.append(", statusByUserName=");
069                    sb.append(statusByUserName);
070                    sb.append(", statusDate=");
071                    sb.append(statusDate);
072                    sb.append("}");
073    
074                    return sb.toString();
075            }
076    
077            public WikiNode toEntityModel() {
078                    WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
079    
080                    if (uuid == null) {
081                            wikiNodeImpl.setUuid(StringPool.BLANK);
082                    }
083                    else {
084                            wikiNodeImpl.setUuid(uuid);
085                    }
086    
087                    wikiNodeImpl.setNodeId(nodeId);
088                    wikiNodeImpl.setGroupId(groupId);
089                    wikiNodeImpl.setCompanyId(companyId);
090                    wikiNodeImpl.setUserId(userId);
091    
092                    if (userName == null) {
093                            wikiNodeImpl.setUserName(StringPool.BLANK);
094                    }
095                    else {
096                            wikiNodeImpl.setUserName(userName);
097                    }
098    
099                    if (createDate == Long.MIN_VALUE) {
100                            wikiNodeImpl.setCreateDate(null);
101                    }
102                    else {
103                            wikiNodeImpl.setCreateDate(new Date(createDate));
104                    }
105    
106                    if (modifiedDate == Long.MIN_VALUE) {
107                            wikiNodeImpl.setModifiedDate(null);
108                    }
109                    else {
110                            wikiNodeImpl.setModifiedDate(new Date(modifiedDate));
111                    }
112    
113                    if (name == null) {
114                            wikiNodeImpl.setName(StringPool.BLANK);
115                    }
116                    else {
117                            wikiNodeImpl.setName(name);
118                    }
119    
120                    if (description == null) {
121                            wikiNodeImpl.setDescription(StringPool.BLANK);
122                    }
123                    else {
124                            wikiNodeImpl.setDescription(description);
125                    }
126    
127                    if (lastPostDate == Long.MIN_VALUE) {
128                            wikiNodeImpl.setLastPostDate(null);
129                    }
130                    else {
131                            wikiNodeImpl.setLastPostDate(new Date(lastPostDate));
132                    }
133    
134                    wikiNodeImpl.setStatus(status);
135                    wikiNodeImpl.setStatusByUserId(statusByUserId);
136    
137                    if (statusByUserName == null) {
138                            wikiNodeImpl.setStatusByUserName(StringPool.BLANK);
139                    }
140                    else {
141                            wikiNodeImpl.setStatusByUserName(statusByUserName);
142                    }
143    
144                    if (statusDate == Long.MIN_VALUE) {
145                            wikiNodeImpl.setStatusDate(null);
146                    }
147                    else {
148                            wikiNodeImpl.setStatusDate(new Date(statusDate));
149                    }
150    
151                    wikiNodeImpl.resetOriginalValues();
152    
153                    return wikiNodeImpl;
154            }
155    
156            public void readExternal(ObjectInput objectInput) throws IOException {
157                    uuid = objectInput.readUTF();
158                    nodeId = objectInput.readLong();
159                    groupId = objectInput.readLong();
160                    companyId = objectInput.readLong();
161                    userId = objectInput.readLong();
162                    userName = objectInput.readUTF();
163                    createDate = objectInput.readLong();
164                    modifiedDate = objectInput.readLong();
165                    name = objectInput.readUTF();
166                    description = objectInput.readUTF();
167                    lastPostDate = objectInput.readLong();
168                    status = objectInput.readInt();
169                    statusByUserId = objectInput.readLong();
170                    statusByUserName = objectInput.readUTF();
171                    statusDate = objectInput.readLong();
172            }
173    
174            public void writeExternal(ObjectOutput objectOutput)
175                    throws IOException {
176                    if (uuid == null) {
177                            objectOutput.writeUTF(StringPool.BLANK);
178                    }
179                    else {
180                            objectOutput.writeUTF(uuid);
181                    }
182    
183                    objectOutput.writeLong(nodeId);
184                    objectOutput.writeLong(groupId);
185                    objectOutput.writeLong(companyId);
186                    objectOutput.writeLong(userId);
187    
188                    if (userName == null) {
189                            objectOutput.writeUTF(StringPool.BLANK);
190                    }
191                    else {
192                            objectOutput.writeUTF(userName);
193                    }
194    
195                    objectOutput.writeLong(createDate);
196                    objectOutput.writeLong(modifiedDate);
197    
198                    if (name == null) {
199                            objectOutput.writeUTF(StringPool.BLANK);
200                    }
201                    else {
202                            objectOutput.writeUTF(name);
203                    }
204    
205                    if (description == null) {
206                            objectOutput.writeUTF(StringPool.BLANK);
207                    }
208                    else {
209                            objectOutput.writeUTF(description);
210                    }
211    
212                    objectOutput.writeLong(lastPostDate);
213                    objectOutput.writeInt(status);
214                    objectOutput.writeLong(statusByUserId);
215    
216                    if (statusByUserName == null) {
217                            objectOutput.writeUTF(StringPool.BLANK);
218                    }
219                    else {
220                            objectOutput.writeUTF(statusByUserName);
221                    }
222    
223                    objectOutput.writeLong(statusDate);
224            }
225    
226            public String uuid;
227            public long nodeId;
228            public long groupId;
229            public long companyId;
230            public long userId;
231            public String userName;
232            public long createDate;
233            public long modifiedDate;
234            public String name;
235            public String description;
236            public long lastPostDate;
237            public int status;
238            public long statusByUserId;
239            public String statusByUserName;
240            public long statusDate;
241    }