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 @Override
081 public BookmarksFolder toEntityModel() {
082 BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
083
084 if (uuid == null) {
085 bookmarksFolderImpl.setUuid(StringPool.BLANK);
086 }
087 else {
088 bookmarksFolderImpl.setUuid(uuid);
089 }
090
091 bookmarksFolderImpl.setFolderId(folderId);
092 bookmarksFolderImpl.setGroupId(groupId);
093 bookmarksFolderImpl.setCompanyId(companyId);
094 bookmarksFolderImpl.setUserId(userId);
095
096 if (userName == null) {
097 bookmarksFolderImpl.setUserName(StringPool.BLANK);
098 }
099 else {
100 bookmarksFolderImpl.setUserName(userName);
101 }
102
103 if (createDate == Long.MIN_VALUE) {
104 bookmarksFolderImpl.setCreateDate(null);
105 }
106 else {
107 bookmarksFolderImpl.setCreateDate(new Date(createDate));
108 }
109
110 if (modifiedDate == Long.MIN_VALUE) {
111 bookmarksFolderImpl.setModifiedDate(null);
112 }
113 else {
114 bookmarksFolderImpl.setModifiedDate(new Date(modifiedDate));
115 }
116
117 bookmarksFolderImpl.setResourceBlockId(resourceBlockId);
118 bookmarksFolderImpl.setParentFolderId(parentFolderId);
119
120 if (name == null) {
121 bookmarksFolderImpl.setName(StringPool.BLANK);
122 }
123 else {
124 bookmarksFolderImpl.setName(name);
125 }
126
127 if (description == null) {
128 bookmarksFolderImpl.setDescription(StringPool.BLANK);
129 }
130 else {
131 bookmarksFolderImpl.setDescription(description);
132 }
133
134 bookmarksFolderImpl.setStatus(status);
135 bookmarksFolderImpl.setStatusByUserId(statusByUserId);
136
137 if (statusByUserName == null) {
138 bookmarksFolderImpl.setStatusByUserName(StringPool.BLANK);
139 }
140 else {
141 bookmarksFolderImpl.setStatusByUserName(statusByUserName);
142 }
143
144 if (statusDate == Long.MIN_VALUE) {
145 bookmarksFolderImpl.setStatusDate(null);
146 }
147 else {
148 bookmarksFolderImpl.setStatusDate(new Date(statusDate));
149 }
150
151 bookmarksFolderImpl.resetOriginalValues();
152
153 return bookmarksFolderImpl;
154 }
155
156 @Override
157 public void readExternal(ObjectInput objectInput) throws IOException {
158 uuid = objectInput.readUTF();
159 folderId = objectInput.readLong();
160 groupId = objectInput.readLong();
161 companyId = objectInput.readLong();
162 userId = objectInput.readLong();
163 userName = objectInput.readUTF();
164 createDate = objectInput.readLong();
165 modifiedDate = objectInput.readLong();
166 resourceBlockId = objectInput.readLong();
167 parentFolderId = objectInput.readLong();
168 name = objectInput.readUTF();
169 description = objectInput.readUTF();
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(folderId);
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 objectOutput.writeLong(resourceBlockId);
201 objectOutput.writeLong(parentFolderId);
202
203 if (name == null) {
204 objectOutput.writeUTF(StringPool.BLANK);
205 }
206 else {
207 objectOutput.writeUTF(name);
208 }
209
210 if (description == null) {
211 objectOutput.writeUTF(StringPool.BLANK);
212 }
213 else {
214 objectOutput.writeUTF(description);
215 }
216
217 objectOutput.writeInt(status);
218 objectOutput.writeLong(statusByUserId);
219
220 if (statusByUserName == null) {
221 objectOutput.writeUTF(StringPool.BLANK);
222 }
223 else {
224 objectOutput.writeUTF(statusByUserName);
225 }
226
227 objectOutput.writeLong(statusDate);
228 }
229
230 public String uuid;
231 public long folderId;
232 public long groupId;
233 public long companyId;
234 public long userId;
235 public String userName;
236 public long createDate;
237 public long modifiedDate;
238 public long resourceBlockId;
239 public long parentFolderId;
240 public String name;
241 public String description;
242 public int status;
243 public long statusByUserId;
244 public String statusByUserName;
245 public long statusDate;
246 }