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