001
014
015 package com.liferay.portlet.messageboards.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.messageboards.model.MBCategory;
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 MBCategoryCacheModel implements CacheModel<MBCategory>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(39);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", categoryId=");
046 sb.append(categoryId);
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(", parentCategoryId=");
060 sb.append(parentCategoryId);
061 sb.append(", name=");
062 sb.append(name);
063 sb.append(", description=");
064 sb.append(description);
065 sb.append(", displayStyle=");
066 sb.append(displayStyle);
067 sb.append(", threadCount=");
068 sb.append(threadCount);
069 sb.append(", messageCount=");
070 sb.append(messageCount);
071 sb.append(", lastPostDate=");
072 sb.append(lastPostDate);
073 sb.append(", status=");
074 sb.append(status);
075 sb.append(", statusByUserId=");
076 sb.append(statusByUserId);
077 sb.append(", statusByUserName=");
078 sb.append(statusByUserName);
079 sb.append(", statusDate=");
080 sb.append(statusDate);
081 sb.append("}");
082
083 return sb.toString();
084 }
085
086 @Override
087 public MBCategory toEntityModel() {
088 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
089
090 if (uuid == null) {
091 mbCategoryImpl.setUuid(StringPool.BLANK);
092 }
093 else {
094 mbCategoryImpl.setUuid(uuid);
095 }
096
097 mbCategoryImpl.setCategoryId(categoryId);
098 mbCategoryImpl.setGroupId(groupId);
099 mbCategoryImpl.setCompanyId(companyId);
100 mbCategoryImpl.setUserId(userId);
101
102 if (userName == null) {
103 mbCategoryImpl.setUserName(StringPool.BLANK);
104 }
105 else {
106 mbCategoryImpl.setUserName(userName);
107 }
108
109 if (createDate == Long.MIN_VALUE) {
110 mbCategoryImpl.setCreateDate(null);
111 }
112 else {
113 mbCategoryImpl.setCreateDate(new Date(createDate));
114 }
115
116 if (modifiedDate == Long.MIN_VALUE) {
117 mbCategoryImpl.setModifiedDate(null);
118 }
119 else {
120 mbCategoryImpl.setModifiedDate(new Date(modifiedDate));
121 }
122
123 mbCategoryImpl.setParentCategoryId(parentCategoryId);
124
125 if (name == null) {
126 mbCategoryImpl.setName(StringPool.BLANK);
127 }
128 else {
129 mbCategoryImpl.setName(name);
130 }
131
132 if (description == null) {
133 mbCategoryImpl.setDescription(StringPool.BLANK);
134 }
135 else {
136 mbCategoryImpl.setDescription(description);
137 }
138
139 if (displayStyle == null) {
140 mbCategoryImpl.setDisplayStyle(StringPool.BLANK);
141 }
142 else {
143 mbCategoryImpl.setDisplayStyle(displayStyle);
144 }
145
146 mbCategoryImpl.setThreadCount(threadCount);
147 mbCategoryImpl.setMessageCount(messageCount);
148
149 if (lastPostDate == Long.MIN_VALUE) {
150 mbCategoryImpl.setLastPostDate(null);
151 }
152 else {
153 mbCategoryImpl.setLastPostDate(new Date(lastPostDate));
154 }
155
156 mbCategoryImpl.setStatus(status);
157 mbCategoryImpl.setStatusByUserId(statusByUserId);
158
159 if (statusByUserName == null) {
160 mbCategoryImpl.setStatusByUserName(StringPool.BLANK);
161 }
162 else {
163 mbCategoryImpl.setStatusByUserName(statusByUserName);
164 }
165
166 if (statusDate == Long.MIN_VALUE) {
167 mbCategoryImpl.setStatusDate(null);
168 }
169 else {
170 mbCategoryImpl.setStatusDate(new Date(statusDate));
171 }
172
173 mbCategoryImpl.resetOriginalValues();
174
175 return mbCategoryImpl;
176 }
177
178 @Override
179 public void readExternal(ObjectInput objectInput) throws IOException {
180 uuid = objectInput.readUTF();
181 categoryId = objectInput.readLong();
182 groupId = objectInput.readLong();
183 companyId = objectInput.readLong();
184 userId = objectInput.readLong();
185 userName = objectInput.readUTF();
186 createDate = objectInput.readLong();
187 modifiedDate = objectInput.readLong();
188 parentCategoryId = objectInput.readLong();
189 name = objectInput.readUTF();
190 description = objectInput.readUTF();
191 displayStyle = objectInput.readUTF();
192 threadCount = objectInput.readInt();
193 messageCount = objectInput.readInt();
194 lastPostDate = objectInput.readLong();
195 status = objectInput.readInt();
196 statusByUserId = objectInput.readLong();
197 statusByUserName = objectInput.readUTF();
198 statusDate = objectInput.readLong();
199 }
200
201 @Override
202 public void writeExternal(ObjectOutput objectOutput)
203 throws IOException {
204 if (uuid == null) {
205 objectOutput.writeUTF(StringPool.BLANK);
206 }
207 else {
208 objectOutput.writeUTF(uuid);
209 }
210
211 objectOutput.writeLong(categoryId);
212 objectOutput.writeLong(groupId);
213 objectOutput.writeLong(companyId);
214 objectOutput.writeLong(userId);
215
216 if (userName == null) {
217 objectOutput.writeUTF(StringPool.BLANK);
218 }
219 else {
220 objectOutput.writeUTF(userName);
221 }
222
223 objectOutput.writeLong(createDate);
224 objectOutput.writeLong(modifiedDate);
225 objectOutput.writeLong(parentCategoryId);
226
227 if (name == null) {
228 objectOutput.writeUTF(StringPool.BLANK);
229 }
230 else {
231 objectOutput.writeUTF(name);
232 }
233
234 if (description == null) {
235 objectOutput.writeUTF(StringPool.BLANK);
236 }
237 else {
238 objectOutput.writeUTF(description);
239 }
240
241 if (displayStyle == null) {
242 objectOutput.writeUTF(StringPool.BLANK);
243 }
244 else {
245 objectOutput.writeUTF(displayStyle);
246 }
247
248 objectOutput.writeInt(threadCount);
249 objectOutput.writeInt(messageCount);
250 objectOutput.writeLong(lastPostDate);
251 objectOutput.writeInt(status);
252 objectOutput.writeLong(statusByUserId);
253
254 if (statusByUserName == null) {
255 objectOutput.writeUTF(StringPool.BLANK);
256 }
257 else {
258 objectOutput.writeUTF(statusByUserName);
259 }
260
261 objectOutput.writeLong(statusDate);
262 }
263
264 public String uuid;
265 public long categoryId;
266 public long groupId;
267 public long companyId;
268 public long userId;
269 public String userName;
270 public long createDate;
271 public long modifiedDate;
272 public long parentCategoryId;
273 public String name;
274 public String description;
275 public String displayStyle;
276 public int threadCount;
277 public int messageCount;
278 public long lastPostDate;
279 public int status;
280 public long statusByUserId;
281 public String statusByUserName;
282 public long statusDate;
283 }