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