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