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.PollsVote;
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 PollsVoteCacheModel implements CacheModel<PollsVote>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(23);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", voteId=");
046 sb.append(voteId);
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(", questionId=");
060 sb.append(questionId);
061 sb.append(", choiceId=");
062 sb.append(choiceId);
063 sb.append(", voteDate=");
064 sb.append(voteDate);
065 sb.append("}");
066
067 return sb.toString();
068 }
069
070 @Override
071 public PollsVote toEntityModel() {
072 PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
073
074 if (uuid == null) {
075 pollsVoteImpl.setUuid(StringPool.BLANK);
076 }
077 else {
078 pollsVoteImpl.setUuid(uuid);
079 }
080
081 pollsVoteImpl.setVoteId(voteId);
082 pollsVoteImpl.setGroupId(groupId);
083 pollsVoteImpl.setCompanyId(companyId);
084 pollsVoteImpl.setUserId(userId);
085
086 if (userName == null) {
087 pollsVoteImpl.setUserName(StringPool.BLANK);
088 }
089 else {
090 pollsVoteImpl.setUserName(userName);
091 }
092
093 if (createDate == Long.MIN_VALUE) {
094 pollsVoteImpl.setCreateDate(null);
095 }
096 else {
097 pollsVoteImpl.setCreateDate(new Date(createDate));
098 }
099
100 if (modifiedDate == Long.MIN_VALUE) {
101 pollsVoteImpl.setModifiedDate(null);
102 }
103 else {
104 pollsVoteImpl.setModifiedDate(new Date(modifiedDate));
105 }
106
107 pollsVoteImpl.setQuestionId(questionId);
108 pollsVoteImpl.setChoiceId(choiceId);
109
110 if (voteDate == Long.MIN_VALUE) {
111 pollsVoteImpl.setVoteDate(null);
112 }
113 else {
114 pollsVoteImpl.setVoteDate(new Date(voteDate));
115 }
116
117 pollsVoteImpl.resetOriginalValues();
118
119 return pollsVoteImpl;
120 }
121
122 @Override
123 public void readExternal(ObjectInput objectInput) throws IOException {
124 uuid = objectInput.readUTF();
125 voteId = objectInput.readLong();
126 groupId = objectInput.readLong();
127 companyId = objectInput.readLong();
128 userId = objectInput.readLong();
129 userName = objectInput.readUTF();
130 createDate = objectInput.readLong();
131 modifiedDate = objectInput.readLong();
132 questionId = objectInput.readLong();
133 choiceId = objectInput.readLong();
134 voteDate = objectInput.readLong();
135 }
136
137 @Override
138 public void writeExternal(ObjectOutput objectOutput)
139 throws IOException {
140 if (uuid == null) {
141 objectOutput.writeUTF(StringPool.BLANK);
142 }
143 else {
144 objectOutput.writeUTF(uuid);
145 }
146
147 objectOutput.writeLong(voteId);
148 objectOutput.writeLong(groupId);
149 objectOutput.writeLong(companyId);
150 objectOutput.writeLong(userId);
151
152 if (userName == null) {
153 objectOutput.writeUTF(StringPool.BLANK);
154 }
155 else {
156 objectOutput.writeUTF(userName);
157 }
158
159 objectOutput.writeLong(createDate);
160 objectOutput.writeLong(modifiedDate);
161 objectOutput.writeLong(questionId);
162 objectOutput.writeLong(choiceId);
163 objectOutput.writeLong(voteDate);
164 }
165
166 public String uuid;
167 public long voteId;
168 public long groupId;
169 public long companyId;
170 public long userId;
171 public String userName;
172 public long createDate;
173 public long modifiedDate;
174 public long questionId;
175 public long choiceId;
176 public long voteDate;
177 }