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(31);
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("}");
074
075 return sb.toString();
076 }
077
078 public MBCategory toEntityModel() {
079 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
080
081 if (uuid == null) {
082 mbCategoryImpl.setUuid(StringPool.BLANK);
083 }
084 else {
085 mbCategoryImpl.setUuid(uuid);
086 }
087
088 mbCategoryImpl.setCategoryId(categoryId);
089 mbCategoryImpl.setGroupId(groupId);
090 mbCategoryImpl.setCompanyId(companyId);
091 mbCategoryImpl.setUserId(userId);
092
093 if (userName == null) {
094 mbCategoryImpl.setUserName(StringPool.BLANK);
095 }
096 else {
097 mbCategoryImpl.setUserName(userName);
098 }
099
100 if (createDate == Long.MIN_VALUE) {
101 mbCategoryImpl.setCreateDate(null);
102 }
103 else {
104 mbCategoryImpl.setCreateDate(new Date(createDate));
105 }
106
107 if (modifiedDate == Long.MIN_VALUE) {
108 mbCategoryImpl.setModifiedDate(null);
109 }
110 else {
111 mbCategoryImpl.setModifiedDate(new Date(modifiedDate));
112 }
113
114 mbCategoryImpl.setParentCategoryId(parentCategoryId);
115
116 if (name == null) {
117 mbCategoryImpl.setName(StringPool.BLANK);
118 }
119 else {
120 mbCategoryImpl.setName(name);
121 }
122
123 if (description == null) {
124 mbCategoryImpl.setDescription(StringPool.BLANK);
125 }
126 else {
127 mbCategoryImpl.setDescription(description);
128 }
129
130 if (displayStyle == null) {
131 mbCategoryImpl.setDisplayStyle(StringPool.BLANK);
132 }
133 else {
134 mbCategoryImpl.setDisplayStyle(displayStyle);
135 }
136
137 mbCategoryImpl.setThreadCount(threadCount);
138 mbCategoryImpl.setMessageCount(messageCount);
139
140 if (lastPostDate == Long.MIN_VALUE) {
141 mbCategoryImpl.setLastPostDate(null);
142 }
143 else {
144 mbCategoryImpl.setLastPostDate(new Date(lastPostDate));
145 }
146
147 mbCategoryImpl.resetOriginalValues();
148
149 return mbCategoryImpl;
150 }
151
152 public void readExternal(ObjectInput objectInput) throws IOException {
153 uuid = objectInput.readUTF();
154 categoryId = objectInput.readLong();
155 groupId = objectInput.readLong();
156 companyId = objectInput.readLong();
157 userId = objectInput.readLong();
158 userName = objectInput.readUTF();
159 createDate = objectInput.readLong();
160 modifiedDate = objectInput.readLong();
161 parentCategoryId = objectInput.readLong();
162 name = objectInput.readUTF();
163 description = objectInput.readUTF();
164 displayStyle = objectInput.readUTF();
165 threadCount = objectInput.readInt();
166 messageCount = objectInput.readInt();
167 lastPostDate = objectInput.readLong();
168 }
169
170 public void writeExternal(ObjectOutput objectOutput)
171 throws IOException {
172 if (uuid == null) {
173 objectOutput.writeUTF(StringPool.BLANK);
174 }
175 else {
176 objectOutput.writeUTF(uuid);
177 }
178
179 objectOutput.writeLong(categoryId);
180 objectOutput.writeLong(groupId);
181 objectOutput.writeLong(companyId);
182 objectOutput.writeLong(userId);
183
184 if (userName == null) {
185 objectOutput.writeUTF(StringPool.BLANK);
186 }
187 else {
188 objectOutput.writeUTF(userName);
189 }
190
191 objectOutput.writeLong(createDate);
192 objectOutput.writeLong(modifiedDate);
193 objectOutput.writeLong(parentCategoryId);
194
195 if (name == null) {
196 objectOutput.writeUTF(StringPool.BLANK);
197 }
198 else {
199 objectOutput.writeUTF(name);
200 }
201
202 if (description == null) {
203 objectOutput.writeUTF(StringPool.BLANK);
204 }
205 else {
206 objectOutput.writeUTF(description);
207 }
208
209 if (displayStyle == null) {
210 objectOutput.writeUTF(StringPool.BLANK);
211 }
212 else {
213 objectOutput.writeUTF(displayStyle);
214 }
215
216 objectOutput.writeInt(threadCount);
217 objectOutput.writeInt(messageCount);
218 objectOutput.writeLong(lastPostDate);
219 }
220
221 public String uuid;
222 public long categoryId;
223 public long groupId;
224 public long companyId;
225 public long userId;
226 public String userName;
227 public long createDate;
228 public long modifiedDate;
229 public long parentCategoryId;
230 public String name;
231 public String description;
232 public String displayStyle;
233 public int threadCount;
234 public int messageCount;
235 public long lastPostDate;
236 }