001
014
015 package com.liferay.portal.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.Account;
020 import com.liferay.portal.model.CacheModel;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027 import java.util.Date;
028
029
036 public class AccountCacheModel implements CacheModel<Account>, Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(33);
040
041 sb.append("{accountId=");
042 sb.append(accountId);
043 sb.append(", companyId=");
044 sb.append(companyId);
045 sb.append(", userId=");
046 sb.append(userId);
047 sb.append(", userName=");
048 sb.append(userName);
049 sb.append(", createDate=");
050 sb.append(createDate);
051 sb.append(", modifiedDate=");
052 sb.append(modifiedDate);
053 sb.append(", parentAccountId=");
054 sb.append(parentAccountId);
055 sb.append(", name=");
056 sb.append(name);
057 sb.append(", legalName=");
058 sb.append(legalName);
059 sb.append(", legalId=");
060 sb.append(legalId);
061 sb.append(", legalType=");
062 sb.append(legalType);
063 sb.append(", sicCode=");
064 sb.append(sicCode);
065 sb.append(", tickerSymbol=");
066 sb.append(tickerSymbol);
067 sb.append(", industry=");
068 sb.append(industry);
069 sb.append(", type=");
070 sb.append(type);
071 sb.append(", size=");
072 sb.append(size);
073 sb.append("}");
074
075 return sb.toString();
076 }
077
078 @Override
079 public Account toEntityModel() {
080 AccountImpl accountImpl = new AccountImpl();
081
082 accountImpl.setAccountId(accountId);
083 accountImpl.setCompanyId(companyId);
084 accountImpl.setUserId(userId);
085
086 if (userName == null) {
087 accountImpl.setUserName(StringPool.BLANK);
088 }
089 else {
090 accountImpl.setUserName(userName);
091 }
092
093 if (createDate == Long.MIN_VALUE) {
094 accountImpl.setCreateDate(null);
095 }
096 else {
097 accountImpl.setCreateDate(new Date(createDate));
098 }
099
100 if (modifiedDate == Long.MIN_VALUE) {
101 accountImpl.setModifiedDate(null);
102 }
103 else {
104 accountImpl.setModifiedDate(new Date(modifiedDate));
105 }
106
107 accountImpl.setParentAccountId(parentAccountId);
108
109 if (name == null) {
110 accountImpl.setName(StringPool.BLANK);
111 }
112 else {
113 accountImpl.setName(name);
114 }
115
116 if (legalName == null) {
117 accountImpl.setLegalName(StringPool.BLANK);
118 }
119 else {
120 accountImpl.setLegalName(legalName);
121 }
122
123 if (legalId == null) {
124 accountImpl.setLegalId(StringPool.BLANK);
125 }
126 else {
127 accountImpl.setLegalId(legalId);
128 }
129
130 if (legalType == null) {
131 accountImpl.setLegalType(StringPool.BLANK);
132 }
133 else {
134 accountImpl.setLegalType(legalType);
135 }
136
137 if (sicCode == null) {
138 accountImpl.setSicCode(StringPool.BLANK);
139 }
140 else {
141 accountImpl.setSicCode(sicCode);
142 }
143
144 if (tickerSymbol == null) {
145 accountImpl.setTickerSymbol(StringPool.BLANK);
146 }
147 else {
148 accountImpl.setTickerSymbol(tickerSymbol);
149 }
150
151 if (industry == null) {
152 accountImpl.setIndustry(StringPool.BLANK);
153 }
154 else {
155 accountImpl.setIndustry(industry);
156 }
157
158 if (type == null) {
159 accountImpl.setType(StringPool.BLANK);
160 }
161 else {
162 accountImpl.setType(type);
163 }
164
165 if (size == null) {
166 accountImpl.setSize(StringPool.BLANK);
167 }
168 else {
169 accountImpl.setSize(size);
170 }
171
172 accountImpl.resetOriginalValues();
173
174 return accountImpl;
175 }
176
177 @Override
178 public void readExternal(ObjectInput objectInput) throws IOException {
179 accountId = objectInput.readLong();
180 companyId = objectInput.readLong();
181 userId = objectInput.readLong();
182 userName = objectInput.readUTF();
183 createDate = objectInput.readLong();
184 modifiedDate = objectInput.readLong();
185 parentAccountId = objectInput.readLong();
186 name = objectInput.readUTF();
187 legalName = objectInput.readUTF();
188 legalId = objectInput.readUTF();
189 legalType = objectInput.readUTF();
190 sicCode = objectInput.readUTF();
191 tickerSymbol = objectInput.readUTF();
192 industry = objectInput.readUTF();
193 type = objectInput.readUTF();
194 size = objectInput.readUTF();
195 }
196
197 @Override
198 public void writeExternal(ObjectOutput objectOutput)
199 throws IOException {
200 objectOutput.writeLong(accountId);
201 objectOutput.writeLong(companyId);
202 objectOutput.writeLong(userId);
203
204 if (userName == null) {
205 objectOutput.writeUTF(StringPool.BLANK);
206 }
207 else {
208 objectOutput.writeUTF(userName);
209 }
210
211 objectOutput.writeLong(createDate);
212 objectOutput.writeLong(modifiedDate);
213 objectOutput.writeLong(parentAccountId);
214
215 if (name == null) {
216 objectOutput.writeUTF(StringPool.BLANK);
217 }
218 else {
219 objectOutput.writeUTF(name);
220 }
221
222 if (legalName == null) {
223 objectOutput.writeUTF(StringPool.BLANK);
224 }
225 else {
226 objectOutput.writeUTF(legalName);
227 }
228
229 if (legalId == null) {
230 objectOutput.writeUTF(StringPool.BLANK);
231 }
232 else {
233 objectOutput.writeUTF(legalId);
234 }
235
236 if (legalType == null) {
237 objectOutput.writeUTF(StringPool.BLANK);
238 }
239 else {
240 objectOutput.writeUTF(legalType);
241 }
242
243 if (sicCode == null) {
244 objectOutput.writeUTF(StringPool.BLANK);
245 }
246 else {
247 objectOutput.writeUTF(sicCode);
248 }
249
250 if (tickerSymbol == null) {
251 objectOutput.writeUTF(StringPool.BLANK);
252 }
253 else {
254 objectOutput.writeUTF(tickerSymbol);
255 }
256
257 if (industry == null) {
258 objectOutput.writeUTF(StringPool.BLANK);
259 }
260 else {
261 objectOutput.writeUTF(industry);
262 }
263
264 if (type == null) {
265 objectOutput.writeUTF(StringPool.BLANK);
266 }
267 else {
268 objectOutput.writeUTF(type);
269 }
270
271 if (size == null) {
272 objectOutput.writeUTF(StringPool.BLANK);
273 }
274 else {
275 objectOutput.writeUTF(size);
276 }
277 }
278
279 public long accountId;
280 public long companyId;
281 public long userId;
282 public String userName;
283 public long createDate;
284 public long modifiedDate;
285 public long parentAccountId;
286 public String name;
287 public String legalName;
288 public String legalId;
289 public String legalType;
290 public String sicCode;
291 public String tickerSymbol;
292 public String industry;
293 public String type;
294 public String size;
295 }