001
014
015 package com.liferay.portlet.bookmarks.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.bookmarks.model.BookmarksFolder;
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 BookmarksFolderCacheModel implements CacheModel<BookmarksFolder>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(33);
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(", resourceBlockId=");
060 sb.append(resourceBlockId);
061 sb.append(", parentFolderId=");
062 sb.append(parentFolderId);
063 sb.append(", name=");
064 sb.append(name);
065 sb.append(", description=");
066 sb.append(description);
067 sb.append(", status=");
068 sb.append(status);
069 sb.append(", statusByUserId=");
070 sb.append(statusByUserId);
071 sb.append(", statusByUserName=");
072 sb.append(statusByUserName);
073 sb.append(", statusDate=");
074 sb.append(statusDate);
075 sb.append("}");
076
077 return sb.toString();
078 }
079
080 public BookmarksFolder toEntityModel() {
081 BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
082
083 if (uuid == null) {
084 bookmarksFolderImpl.setUuid(StringPool.BLANK);
085 }
086 else {
087 bookmarksFolderImpl.setUuid(uuid);
088 }
089
090 bookmarksFolderImpl.setFolderId(folderId);
091 bookmarksFolderImpl.setGroupId(groupId);
092 bookmarksFolderImpl.setCompanyId(companyId);
093 bookmarksFolderImpl.setUserId(userId);
094
095 if (userName == null) {
096 bookmarksFolderImpl.setUserName(StringPool.BLANK);
097 }
098 else {
099 bookmarksFolderImpl.setUserName(userName);
100 }
101
102 if (createDate == Long.MIN_VALUE) {
103 bookmarksFolderImpl.setCreateDate(null);
104 }
105 else {
106 bookmarksFolderImpl.setCreateDate(new Date(createDate));
107 }
108
109 if (modifiedDate == Long.MIN_VALUE) {
110 bookmarksFolderImpl.setModifiedDate(null);
111 }
112 else {
113 bookmarksFolderImpl.setModifiedDate(new Date(modifiedDate));
114 }
115
116 bookmarksFolderImpl.setResourceBlockId(resourceBlockId);
117 bookmarksFolderImpl.setParentFolderId(parentFolderId);
118
119 if (name == null) {
120 bookmarksFolderImpl.setName(StringPool.BLANK);
121 }
122 else {
123 bookmarksFolderImpl.setName(name);
124 }
125
126 if (description == null) {
127 bookmarksFolderImpl.setDescription(StringPool.BLANK);
128 }
129 else {
130 bookmarksFolderImpl.setDescription(description);
131 }
132
133 bookmarksFolderImpl.setStatus(status);
134 bookmarksFolderImpl.setStatusByUserId(statusByUserId);
135
136 if (statusByUserName == null) {
137 bookmarksFolderImpl.setStatusByUserName(StringPool.BLANK);
138 }
139 else {
140 bookmarksFolderImpl.setStatusByUserName(statusByUserName);
141 }
142
143 if (statusDate == Long.MIN_VALUE) {
144 bookmarksFolderImpl.setStatusDate(null);
145 }
146 else {
147 bookmarksFolderImpl.setStatusDate(new Date(statusDate));
148 }
149
150 bookmarksFolderImpl.resetOriginalValues();
151
152 return bookmarksFolderImpl;
153 }
154
155 public void readExternal(ObjectInput objectInput) throws IOException {
156 uuid = objectInput.readUTF();
157 folderId = objectInput.readLong();
158 groupId = objectInput.readLong();
159 companyId = objectInput.readLong();
160 userId = objectInput.readLong();
161 userName = objectInput.readUTF();
162 createDate = objectInput.readLong();
163 modifiedDate = objectInput.readLong();
164 resourceBlockId = objectInput.readLong();
165 parentFolderId = objectInput.readLong();
166 name = objectInput.readUTF();
167 description = objectInput.readUTF();
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(folderId);
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 objectOutput.writeLong(resourceBlockId);
198 objectOutput.writeLong(parentFolderId);
199
200 if (name == null) {
201 objectOutput.writeUTF(StringPool.BLANK);
202 }
203 else {
204 objectOutput.writeUTF(name);
205 }
206
207 if (description == null) {
208 objectOutput.writeUTF(StringPool.BLANK);
209 }
210 else {
211 objectOutput.writeUTF(description);
212 }
213
214 objectOutput.writeInt(status);
215 objectOutput.writeLong(statusByUserId);
216
217 if (statusByUserName == null) {
218 objectOutput.writeUTF(StringPool.BLANK);
219 }
220 else {
221 objectOutput.writeUTF(statusByUserName);
222 }
223
224 objectOutput.writeLong(statusDate);
225 }
226
227 public String uuid;
228 public long folderId;
229 public long groupId;
230 public long companyId;
231 public long userId;
232 public String userName;
233 public long createDate;
234 public long modifiedDate;
235 public long resourceBlockId;
236 public long parentFolderId;
237 public String name;
238 public String description;
239 public int status;
240 public long statusByUserId;
241 public String statusByUserName;
242 public long statusDate;
243 }