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.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            @Override
078            public WikiNode toEntityModel() {
079                    WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
080    
081                    if (uuid == null) {
082                            wikiNodeImpl.setUuid(StringPool.BLANK);
083                    }
084                    else {
085                            wikiNodeImpl.setUuid(uuid);
086                    }
087    
088                    wikiNodeImpl.setNodeId(nodeId);
089                    wikiNodeImpl.setGroupId(groupId);
090                    wikiNodeImpl.setCompanyId(companyId);
091                    wikiNodeImpl.setUserId(userId);
092    
093                    if (userName == null) {
094                            wikiNodeImpl.setUserName(StringPool.BLANK);
095                    }
096                    else {
097                            wikiNodeImpl.setUserName(userName);
098                    }
099    
100                    if (createDate == Long.MIN_VALUE) {
101                            wikiNodeImpl.setCreateDate(null);
102                    }
103                    else {
104                            wikiNodeImpl.setCreateDate(new Date(createDate));
105                    }
106    
107                    if (modifiedDate == Long.MIN_VALUE) {
108                            wikiNodeImpl.setModifiedDate(null);
109                    }
110                    else {
111                            wikiNodeImpl.setModifiedDate(new Date(modifiedDate));
112                    }
113    
114                    if (name == null) {
115                            wikiNodeImpl.setName(StringPool.BLANK);
116                    }
117                    else {
118                            wikiNodeImpl.setName(name);
119                    }
120    
121                    if (description == null) {
122                            wikiNodeImpl.setDescription(StringPool.BLANK);
123                    }
124                    else {
125                            wikiNodeImpl.setDescription(description);
126                    }
127    
128                    if (lastPostDate == Long.MIN_VALUE) {
129                            wikiNodeImpl.setLastPostDate(null);
130                    }
131                    else {
132                            wikiNodeImpl.setLastPostDate(new Date(lastPostDate));
133                    }
134    
135                    wikiNodeImpl.setStatus(status);
136                    wikiNodeImpl.setStatusByUserId(statusByUserId);
137    
138                    if (statusByUserName == null) {
139                            wikiNodeImpl.setStatusByUserName(StringPool.BLANK);
140                    }
141                    else {
142                            wikiNodeImpl.setStatusByUserName(statusByUserName);
143                    }
144    
145                    if (statusDate == Long.MIN_VALUE) {
146                            wikiNodeImpl.setStatusDate(null);
147                    }
148                    else {
149                            wikiNodeImpl.setStatusDate(new Date(statusDate));
150                    }
151    
152                    wikiNodeImpl.resetOriginalValues();
153    
154                    return wikiNodeImpl;
155            }
156    
157            @Override
158            public void readExternal(ObjectInput objectInput) throws IOException {
159                    uuid = objectInput.readUTF();
160                    nodeId = objectInput.readLong();
161                    groupId = objectInput.readLong();
162                    companyId = objectInput.readLong();
163                    userId = objectInput.readLong();
164                    userName = objectInput.readUTF();
165                    createDate = objectInput.readLong();
166                    modifiedDate = objectInput.readLong();
167                    name = objectInput.readUTF();
168                    description = objectInput.readUTF();
169                    lastPostDate = objectInput.readLong();
170                    status = objectInput.readInt();
171                    statusByUserId = objectInput.readLong();
172                    statusByUserName = objectInput.readUTF();
173                    statusDate = objectInput.readLong();
174            }
175    
176            @Override
177            public void writeExternal(ObjectOutput objectOutput)
178                    throws IOException {
179                    if (uuid == null) {
180                            objectOutput.writeUTF(StringPool.BLANK);
181                    }
182                    else {
183                            objectOutput.writeUTF(uuid);
184                    }
185    
186                    objectOutput.writeLong(nodeId);
187                    objectOutput.writeLong(groupId);
188                    objectOutput.writeLong(companyId);
189                    objectOutput.writeLong(userId);
190    
191                    if (userName == null) {
192                            objectOutput.writeUTF(StringPool.BLANK);
193                    }
194                    else {
195                            objectOutput.writeUTF(userName);
196                    }
197    
198                    objectOutput.writeLong(createDate);
199                    objectOutput.writeLong(modifiedDate);
200    
201                    if (name == null) {
202                            objectOutput.writeUTF(StringPool.BLANK);
203                    }
204                    else {
205                            objectOutput.writeUTF(name);
206                    }
207    
208                    if (description == null) {
209                            objectOutput.writeUTF(StringPool.BLANK);
210                    }
211                    else {
212                            objectOutput.writeUTF(description);
213                    }
214    
215                    objectOutput.writeLong(lastPostDate);
216                    objectOutput.writeInt(status);
217                    objectOutput.writeLong(statusByUserId);
218    
219                    if (statusByUserName == null) {
220                            objectOutput.writeUTF(StringPool.BLANK);
221                    }
222                    else {
223                            objectOutput.writeUTF(statusByUserName);
224                    }
225    
226                    objectOutput.writeLong(statusDate);
227            }
228    
229            public String uuid;
230            public long nodeId;
231            public long groupId;
232            public long companyId;
233            public long userId;
234            public String userName;
235            public long createDate;
236            public long modifiedDate;
237            public String name;
238            public String description;
239            public long lastPostDate;
240            public int status;
241            public long statusByUserId;
242            public String statusByUserName;
243            public long statusDate;
244    }