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.MBThread;
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 MBThreadCacheModel implements CacheModel<MBThread>, Externalizable {
038 @Override
039 public String toString() {
040 StringBundler sb = new StringBundler(33);
041
042 sb.append("{threadId=");
043 sb.append(threadId);
044 sb.append(", groupId=");
045 sb.append(groupId);
046 sb.append(", companyId=");
047 sb.append(companyId);
048 sb.append(", categoryId=");
049 sb.append(categoryId);
050 sb.append(", rootMessageId=");
051 sb.append(rootMessageId);
052 sb.append(", rootMessageUserId=");
053 sb.append(rootMessageUserId);
054 sb.append(", messageCount=");
055 sb.append(messageCount);
056 sb.append(", viewCount=");
057 sb.append(viewCount);
058 sb.append(", lastPostByUserId=");
059 sb.append(lastPostByUserId);
060 sb.append(", lastPostDate=");
061 sb.append(lastPostDate);
062 sb.append(", priority=");
063 sb.append(priority);
064 sb.append(", question=");
065 sb.append(question);
066 sb.append(", status=");
067 sb.append(status);
068 sb.append(", statusByUserId=");
069 sb.append(statusByUserId);
070 sb.append(", statusByUserName=");
071 sb.append(statusByUserName);
072 sb.append(", statusDate=");
073 sb.append(statusDate);
074 sb.append("}");
075
076 return sb.toString();
077 }
078
079 public MBThread toEntityModel() {
080 MBThreadImpl mbThreadImpl = new MBThreadImpl();
081
082 mbThreadImpl.setThreadId(threadId);
083 mbThreadImpl.setGroupId(groupId);
084 mbThreadImpl.setCompanyId(companyId);
085 mbThreadImpl.setCategoryId(categoryId);
086 mbThreadImpl.setRootMessageId(rootMessageId);
087 mbThreadImpl.setRootMessageUserId(rootMessageUserId);
088 mbThreadImpl.setMessageCount(messageCount);
089 mbThreadImpl.setViewCount(viewCount);
090 mbThreadImpl.setLastPostByUserId(lastPostByUserId);
091
092 if (lastPostDate == Long.MIN_VALUE) {
093 mbThreadImpl.setLastPostDate(null);
094 }
095 else {
096 mbThreadImpl.setLastPostDate(new Date(lastPostDate));
097 }
098
099 mbThreadImpl.setPriority(priority);
100 mbThreadImpl.setQuestion(question);
101 mbThreadImpl.setStatus(status);
102 mbThreadImpl.setStatusByUserId(statusByUserId);
103
104 if (statusByUserName == null) {
105 mbThreadImpl.setStatusByUserName(StringPool.BLANK);
106 }
107 else {
108 mbThreadImpl.setStatusByUserName(statusByUserName);
109 }
110
111 if (statusDate == Long.MIN_VALUE) {
112 mbThreadImpl.setStatusDate(null);
113 }
114 else {
115 mbThreadImpl.setStatusDate(new Date(statusDate));
116 }
117
118 mbThreadImpl.resetOriginalValues();
119
120 return mbThreadImpl;
121 }
122
123 public void readExternal(ObjectInput objectInput) throws IOException {
124 threadId = objectInput.readLong();
125 groupId = objectInput.readLong();
126 companyId = objectInput.readLong();
127 categoryId = objectInput.readLong();
128 rootMessageId = objectInput.readLong();
129 rootMessageUserId = objectInput.readLong();
130 messageCount = objectInput.readInt();
131 viewCount = objectInput.readInt();
132 lastPostByUserId = objectInput.readLong();
133 lastPostDate = objectInput.readLong();
134 priority = objectInput.readDouble();
135 question = objectInput.readBoolean();
136 status = objectInput.readInt();
137 statusByUserId = objectInput.readLong();
138 statusByUserName = objectInput.readUTF();
139 statusDate = objectInput.readLong();
140 }
141
142 public void writeExternal(ObjectOutput objectOutput)
143 throws IOException {
144 objectOutput.writeLong(threadId);
145 objectOutput.writeLong(groupId);
146 objectOutput.writeLong(companyId);
147 objectOutput.writeLong(categoryId);
148 objectOutput.writeLong(rootMessageId);
149 objectOutput.writeLong(rootMessageUserId);
150 objectOutput.writeInt(messageCount);
151 objectOutput.writeInt(viewCount);
152 objectOutput.writeLong(lastPostByUserId);
153 objectOutput.writeLong(lastPostDate);
154 objectOutput.writeDouble(priority);
155 objectOutput.writeBoolean(question);
156 objectOutput.writeInt(status);
157 objectOutput.writeLong(statusByUserId);
158
159 if (statusByUserName == null) {
160 objectOutput.writeUTF(StringPool.BLANK);
161 }
162 else {
163 objectOutput.writeUTF(statusByUserName);
164 }
165
166 objectOutput.writeLong(statusDate);
167 }
168
169 public long threadId;
170 public long groupId;
171 public long companyId;
172 public long categoryId;
173 public long rootMessageId;
174 public long rootMessageUserId;
175 public int messageCount;
176 public int viewCount;
177 public long lastPostByUserId;
178 public long lastPostDate;
179 public double priority;
180 public boolean question;
181 public int status;
182 public long statusByUserId;
183 public String statusByUserName;
184 public long statusDate;
185 }