001
014
015 package com.liferay.portlet.polls.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.polls.model.PollsQuestion;
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 PollsQuestionCacheModel implements CacheModel<PollsQuestion>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(25);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", questionId=");
046 sb.append(questionId);
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(", title=");
060 sb.append(title);
061 sb.append(", description=");
062 sb.append(description);
063 sb.append(", expirationDate=");
064 sb.append(expirationDate);
065 sb.append(", lastVoteDate=");
066 sb.append(lastVoteDate);
067 sb.append("}");
068
069 return sb.toString();
070 }
071
072 @Override
073 public PollsQuestion toEntityModel() {
074 PollsQuestionImpl pollsQuestionImpl = new PollsQuestionImpl();
075
076 if (uuid == null) {
077 pollsQuestionImpl.setUuid(StringPool.BLANK);
078 }
079 else {
080 pollsQuestionImpl.setUuid(uuid);
081 }
082
083 pollsQuestionImpl.setQuestionId(questionId);
084 pollsQuestionImpl.setGroupId(groupId);
085 pollsQuestionImpl.setCompanyId(companyId);
086 pollsQuestionImpl.setUserId(userId);
087
088 if (userName == null) {
089 pollsQuestionImpl.setUserName(StringPool.BLANK);
090 }
091 else {
092 pollsQuestionImpl.setUserName(userName);
093 }
094
095 if (createDate == Long.MIN_VALUE) {
096 pollsQuestionImpl.setCreateDate(null);
097 }
098 else {
099 pollsQuestionImpl.setCreateDate(new Date(createDate));
100 }
101
102 if (modifiedDate == Long.MIN_VALUE) {
103 pollsQuestionImpl.setModifiedDate(null);
104 }
105 else {
106 pollsQuestionImpl.setModifiedDate(new Date(modifiedDate));
107 }
108
109 if (title == null) {
110 pollsQuestionImpl.setTitle(StringPool.BLANK);
111 }
112 else {
113 pollsQuestionImpl.setTitle(title);
114 }
115
116 if (description == null) {
117 pollsQuestionImpl.setDescription(StringPool.BLANK);
118 }
119 else {
120 pollsQuestionImpl.setDescription(description);
121 }
122
123 if (expirationDate == Long.MIN_VALUE) {
124 pollsQuestionImpl.setExpirationDate(null);
125 }
126 else {
127 pollsQuestionImpl.setExpirationDate(new Date(expirationDate));
128 }
129
130 if (lastVoteDate == Long.MIN_VALUE) {
131 pollsQuestionImpl.setLastVoteDate(null);
132 }
133 else {
134 pollsQuestionImpl.setLastVoteDate(new Date(lastVoteDate));
135 }
136
137 pollsQuestionImpl.resetOriginalValues();
138
139 return pollsQuestionImpl;
140 }
141
142 @Override
143 public void readExternal(ObjectInput objectInput) throws IOException {
144 uuid = objectInput.readUTF();
145 questionId = objectInput.readLong();
146 groupId = objectInput.readLong();
147 companyId = objectInput.readLong();
148 userId = objectInput.readLong();
149 userName = objectInput.readUTF();
150 createDate = objectInput.readLong();
151 modifiedDate = objectInput.readLong();
152 title = objectInput.readUTF();
153 description = objectInput.readUTF();
154 expirationDate = objectInput.readLong();
155 lastVoteDate = objectInput.readLong();
156 }
157
158 @Override
159 public void writeExternal(ObjectOutput objectOutput)
160 throws IOException {
161 if (uuid == null) {
162 objectOutput.writeUTF(StringPool.BLANK);
163 }
164 else {
165 objectOutput.writeUTF(uuid);
166 }
167
168 objectOutput.writeLong(questionId);
169 objectOutput.writeLong(groupId);
170 objectOutput.writeLong(companyId);
171 objectOutput.writeLong(userId);
172
173 if (userName == null) {
174 objectOutput.writeUTF(StringPool.BLANK);
175 }
176 else {
177 objectOutput.writeUTF(userName);
178 }
179
180 objectOutput.writeLong(createDate);
181 objectOutput.writeLong(modifiedDate);
182
183 if (title == null) {
184 objectOutput.writeUTF(StringPool.BLANK);
185 }
186 else {
187 objectOutput.writeUTF(title);
188 }
189
190 if (description == null) {
191 objectOutput.writeUTF(StringPool.BLANK);
192 }
193 else {
194 objectOutput.writeUTF(description);
195 }
196
197 objectOutput.writeLong(expirationDate);
198 objectOutput.writeLong(lastVoteDate);
199 }
200
201 public String uuid;
202 public long questionId;
203 public long groupId;
204 public long companyId;
205 public long userId;
206 public String userName;
207 public long createDate;
208 public long modifiedDate;
209 public String title;
210 public String description;
211 public long expirationDate;
212 public long lastVoteDate;
213 }