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