001
014
015 package com.liferay.portlet.bookmarks.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.model.CacheModel;
022
023 import com.liferay.portlet.bookmarks.model.BookmarksFolder;
024
025 import java.io.Externalizable;
026 import java.io.IOException;
027 import java.io.ObjectInput;
028 import java.io.ObjectOutput;
029
030 import java.util.Date;
031
032
039 @ProviderType
040 public class BookmarksFolderCacheModel implements CacheModel<BookmarksFolder>,
041 Externalizable {
042 @Override
043 public String toString() {
044 StringBundler sb = new StringBundler(35);
045
046 sb.append("{uuid=");
047 sb.append(uuid);
048 sb.append(", folderId=");
049 sb.append(folderId);
050 sb.append(", groupId=");
051 sb.append(groupId);
052 sb.append(", companyId=");
053 sb.append(companyId);
054 sb.append(", userId=");
055 sb.append(userId);
056 sb.append(", userName=");
057 sb.append(userName);
058 sb.append(", createDate=");
059 sb.append(createDate);
060 sb.append(", modifiedDate=");
061 sb.append(modifiedDate);
062 sb.append(", resourceBlockId=");
063 sb.append(resourceBlockId);
064 sb.append(", parentFolderId=");
065 sb.append(parentFolderId);
066 sb.append(", treePath=");
067 sb.append(treePath);
068 sb.append(", name=");
069 sb.append(name);
070 sb.append(", description=");
071 sb.append(description);
072 sb.append(", status=");
073 sb.append(status);
074 sb.append(", statusByUserId=");
075 sb.append(statusByUserId);
076 sb.append(", statusByUserName=");
077 sb.append(statusByUserName);
078 sb.append(", statusDate=");
079 sb.append(statusDate);
080 sb.append("}");
081
082 return sb.toString();
083 }
084
085 @Override
086 public BookmarksFolder toEntityModel() {
087 BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
088
089 if (uuid == null) {
090 bookmarksFolderImpl.setUuid(StringPool.BLANK);
091 }
092 else {
093 bookmarksFolderImpl.setUuid(uuid);
094 }
095
096 bookmarksFolderImpl.setFolderId(folderId);
097 bookmarksFolderImpl.setGroupId(groupId);
098 bookmarksFolderImpl.setCompanyId(companyId);
099 bookmarksFolderImpl.setUserId(userId);
100
101 if (userName == null) {
102 bookmarksFolderImpl.setUserName(StringPool.BLANK);
103 }
104 else {
105 bookmarksFolderImpl.setUserName(userName);
106 }
107
108 if (createDate == Long.MIN_VALUE) {
109 bookmarksFolderImpl.setCreateDate(null);
110 }
111 else {
112 bookmarksFolderImpl.setCreateDate(new Date(createDate));
113 }
114
115 if (modifiedDate == Long.MIN_VALUE) {
116 bookmarksFolderImpl.setModifiedDate(null);
117 }
118 else {
119 bookmarksFolderImpl.setModifiedDate(new Date(modifiedDate));
120 }
121
122 bookmarksFolderImpl.setResourceBlockId(resourceBlockId);
123 bookmarksFolderImpl.setParentFolderId(parentFolderId);
124
125 if (treePath == null) {
126 bookmarksFolderImpl.setTreePath(StringPool.BLANK);
127 }
128 else {
129 bookmarksFolderImpl.setTreePath(treePath);
130 }
131
132 if (name == null) {
133 bookmarksFolderImpl.setName(StringPool.BLANK);
134 }
135 else {
136 bookmarksFolderImpl.setName(name);
137 }
138
139 if (description == null) {
140 bookmarksFolderImpl.setDescription(StringPool.BLANK);
141 }
142 else {
143 bookmarksFolderImpl.setDescription(description);
144 }
145
146 bookmarksFolderImpl.setStatus(status);
147 bookmarksFolderImpl.setStatusByUserId(statusByUserId);
148
149 if (statusByUserName == null) {
150 bookmarksFolderImpl.setStatusByUserName(StringPool.BLANK);
151 }
152 else {
153 bookmarksFolderImpl.setStatusByUserName(statusByUserName);
154 }
155
156 if (statusDate == Long.MIN_VALUE) {
157 bookmarksFolderImpl.setStatusDate(null);
158 }
159 else {
160 bookmarksFolderImpl.setStatusDate(new Date(statusDate));
161 }
162
163 bookmarksFolderImpl.resetOriginalValues();
164
165 return bookmarksFolderImpl;
166 }
167
168 @Override
169 public void readExternal(ObjectInput objectInput) throws IOException {
170 uuid = objectInput.readUTF();
171 folderId = objectInput.readLong();
172 groupId = objectInput.readLong();
173 companyId = objectInput.readLong();
174 userId = objectInput.readLong();
175 userName = objectInput.readUTF();
176 createDate = objectInput.readLong();
177 modifiedDate = objectInput.readLong();
178 resourceBlockId = objectInput.readLong();
179 parentFolderId = objectInput.readLong();
180 treePath = objectInput.readUTF();
181 name = objectInput.readUTF();
182 description = objectInput.readUTF();
183 status = objectInput.readInt();
184 statusByUserId = objectInput.readLong();
185 statusByUserName = objectInput.readUTF();
186 statusDate = objectInput.readLong();
187 }
188
189 @Override
190 public void writeExternal(ObjectOutput objectOutput)
191 throws IOException {
192 if (uuid == null) {
193 objectOutput.writeUTF(StringPool.BLANK);
194 }
195 else {
196 objectOutput.writeUTF(uuid);
197 }
198
199 objectOutput.writeLong(folderId);
200 objectOutput.writeLong(groupId);
201 objectOutput.writeLong(companyId);
202 objectOutput.writeLong(userId);
203
204 if (userName == null) {
205 objectOutput.writeUTF(StringPool.BLANK);
206 }
207 else {
208 objectOutput.writeUTF(userName);
209 }
210
211 objectOutput.writeLong(createDate);
212 objectOutput.writeLong(modifiedDate);
213 objectOutput.writeLong(resourceBlockId);
214 objectOutput.writeLong(parentFolderId);
215
216 if (treePath == null) {
217 objectOutput.writeUTF(StringPool.BLANK);
218 }
219 else {
220 objectOutput.writeUTF(treePath);
221 }
222
223 if (name == null) {
224 objectOutput.writeUTF(StringPool.BLANK);
225 }
226 else {
227 objectOutput.writeUTF(name);
228 }
229
230 if (description == null) {
231 objectOutput.writeUTF(StringPool.BLANK);
232 }
233 else {
234 objectOutput.writeUTF(description);
235 }
236
237 objectOutput.writeInt(status);
238 objectOutput.writeLong(statusByUserId);
239
240 if (statusByUserName == null) {
241 objectOutput.writeUTF(StringPool.BLANK);
242 }
243 else {
244 objectOutput.writeUTF(statusByUserName);
245 }
246
247 objectOutput.writeLong(statusDate);
248 }
249
250 public String uuid;
251 public long folderId;
252 public long groupId;
253 public long companyId;
254 public long userId;
255 public String userName;
256 public long createDate;
257 public long modifiedDate;
258 public long resourceBlockId;
259 public long parentFolderId;
260 public String treePath;
261 public String name;
262 public String description;
263 public int status;
264 public long statusByUserId;
265 public String statusByUserName;
266 public long statusDate;
267 }