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