1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Account;
29  import com.liferay.portal.model.AccountSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="AccountModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>Account</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.service.model.Account
58   * @see com.liferay.portal.service.model.AccountModel
59   * @see com.liferay.portal.service.model.impl.AccountImpl
60   *
61   */
62  public class AccountModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "Account_";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "accountId", new Integer(Types.BIGINT) },
66              
67  
68              { "companyId", new Integer(Types.BIGINT) },
69              
70  
71              { "userId", new Integer(Types.BIGINT) },
72              
73  
74              { "userName", new Integer(Types.VARCHAR) },
75              
76  
77              { "createDate", new Integer(Types.TIMESTAMP) },
78              
79  
80              { "modifiedDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "parentAccountId", new Integer(Types.BIGINT) },
84              
85  
86              { "name", new Integer(Types.VARCHAR) },
87              
88  
89              { "legalName", new Integer(Types.VARCHAR) },
90              
91  
92              { "legalId", new Integer(Types.VARCHAR) },
93              
94  
95              { "legalType", new Integer(Types.VARCHAR) },
96              
97  
98              { "sicCode", new Integer(Types.VARCHAR) },
99              
100 
101             { "tickerSymbol", new Integer(Types.VARCHAR) },
102             
103 
104             { "industry", new Integer(Types.VARCHAR) },
105             
106 
107             { "type_", new Integer(Types.VARCHAR) },
108             
109 
110             { "size_", new Integer(Types.VARCHAR) }
111         };
112     public static final String TABLE_SQL_CREATE = "create table Account_ (accountId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentAccountId LONG,name VARCHAR(75) null,legalName VARCHAR(75) null,legalId VARCHAR(75) null,legalType VARCHAR(75) null,sicCode VARCHAR(75) null,tickerSymbol VARCHAR(75) null,industry VARCHAR(75) null,type_ VARCHAR(75) null,size_ VARCHAR(75) null)";
113     public static final String TABLE_SQL_DROP = "drop table Account_";
114     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
115                 "value.object.finder.cache.enabled.com.liferay.portal.model.Account"),
116             true);
117 
118     public static Account toModel(AccountSoap soapModel) {
119         Account model = new AccountImpl();
120 
121         model.setAccountId(soapModel.getAccountId());
122         model.setCompanyId(soapModel.getCompanyId());
123         model.setUserId(soapModel.getUserId());
124         model.setUserName(soapModel.getUserName());
125         model.setCreateDate(soapModel.getCreateDate());
126         model.setModifiedDate(soapModel.getModifiedDate());
127         model.setParentAccountId(soapModel.getParentAccountId());
128         model.setName(soapModel.getName());
129         model.setLegalName(soapModel.getLegalName());
130         model.setLegalId(soapModel.getLegalId());
131         model.setLegalType(soapModel.getLegalType());
132         model.setSicCode(soapModel.getSicCode());
133         model.setTickerSymbol(soapModel.getTickerSymbol());
134         model.setIndustry(soapModel.getIndustry());
135         model.setType(soapModel.getType());
136         model.setSize(soapModel.getSize());
137 
138         return model;
139     }
140 
141     public static List<Account> toModels(AccountSoap[] soapModels) {
142         List<Account> models = new ArrayList<Account>(soapModels.length);
143 
144         for (AccountSoap soapModel : soapModels) {
145             models.add(toModel(soapModel));
146         }
147 
148         return models;
149     }
150 
151     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
152                 "lock.expiration.time.com.liferay.portal.model.Account"));
153 
154     public AccountModelImpl() {
155     }
156 
157     public long getPrimaryKey() {
158         return _accountId;
159     }
160 
161     public void setPrimaryKey(long pk) {
162         setAccountId(pk);
163     }
164 
165     public Serializable getPrimaryKeyObj() {
166         return new Long(_accountId);
167     }
168 
169     public long getAccountId() {
170         return _accountId;
171     }
172 
173     public void setAccountId(long accountId) {
174         if (accountId != _accountId) {
175             _accountId = accountId;
176         }
177     }
178 
179     public long getCompanyId() {
180         return _companyId;
181     }
182 
183     public void setCompanyId(long companyId) {
184         if (companyId != _companyId) {
185             _companyId = companyId;
186         }
187     }
188 
189     public long getUserId() {
190         return _userId;
191     }
192 
193     public void setUserId(long userId) {
194         if (userId != _userId) {
195             _userId = userId;
196         }
197     }
198 
199     public String getUserName() {
200         return GetterUtil.getString(_userName);
201     }
202 
203     public void setUserName(String userName) {
204         if (((userName == null) && (_userName != null)) ||
205                 ((userName != null) && (_userName == null)) ||
206                 ((userName != null) && (_userName != null) &&
207                 !userName.equals(_userName))) {
208             _userName = userName;
209         }
210     }
211 
212     public Date getCreateDate() {
213         return _createDate;
214     }
215 
216     public void setCreateDate(Date createDate) {
217         if (((createDate == null) && (_createDate != null)) ||
218                 ((createDate != null) && (_createDate == null)) ||
219                 ((createDate != null) && (_createDate != null) &&
220                 !createDate.equals(_createDate))) {
221             _createDate = createDate;
222         }
223     }
224 
225     public Date getModifiedDate() {
226         return _modifiedDate;
227     }
228 
229     public void setModifiedDate(Date modifiedDate) {
230         if (((modifiedDate == null) && (_modifiedDate != null)) ||
231                 ((modifiedDate != null) && (_modifiedDate == null)) ||
232                 ((modifiedDate != null) && (_modifiedDate != null) &&
233                 !modifiedDate.equals(_modifiedDate))) {
234             _modifiedDate = modifiedDate;
235         }
236     }
237 
238     public long getParentAccountId() {
239         return _parentAccountId;
240     }
241 
242     public void setParentAccountId(long parentAccountId) {
243         if (parentAccountId != _parentAccountId) {
244             _parentAccountId = parentAccountId;
245         }
246     }
247 
248     public String getName() {
249         return GetterUtil.getString(_name);
250     }
251 
252     public void setName(String name) {
253         if (((name == null) && (_name != null)) ||
254                 ((name != null) && (_name == null)) ||
255                 ((name != null) && (_name != null) && !name.equals(_name))) {
256             _name = name;
257         }
258     }
259 
260     public String getLegalName() {
261         return GetterUtil.getString(_legalName);
262     }
263 
264     public void setLegalName(String legalName) {
265         if (((legalName == null) && (_legalName != null)) ||
266                 ((legalName != null) && (_legalName == null)) ||
267                 ((legalName != null) && (_legalName != null) &&
268                 !legalName.equals(_legalName))) {
269             _legalName = legalName;
270         }
271     }
272 
273     public String getLegalId() {
274         return GetterUtil.getString(_legalId);
275     }
276 
277     public void setLegalId(String legalId) {
278         if (((legalId == null) && (_legalId != null)) ||
279                 ((legalId != null) && (_legalId == null)) ||
280                 ((legalId != null) && (_legalId != null) &&
281                 !legalId.equals(_legalId))) {
282             _legalId = legalId;
283         }
284     }
285 
286     public String getLegalType() {
287         return GetterUtil.getString(_legalType);
288     }
289 
290     public void setLegalType(String legalType) {
291         if (((legalType == null) && (_legalType != null)) ||
292                 ((legalType != null) && (_legalType == null)) ||
293                 ((legalType != null) && (_legalType != null) &&
294                 !legalType.equals(_legalType))) {
295             _legalType = legalType;
296         }
297     }
298 
299     public String getSicCode() {
300         return GetterUtil.getString(_sicCode);
301     }
302 
303     public void setSicCode(String sicCode) {
304         if (((sicCode == null) && (_sicCode != null)) ||
305                 ((sicCode != null) && (_sicCode == null)) ||
306                 ((sicCode != null) && (_sicCode != null) &&
307                 !sicCode.equals(_sicCode))) {
308             _sicCode = sicCode;
309         }
310     }
311 
312     public String getTickerSymbol() {
313         return GetterUtil.getString(_tickerSymbol);
314     }
315 
316     public void setTickerSymbol(String tickerSymbol) {
317         if (((tickerSymbol == null) && (_tickerSymbol != null)) ||
318                 ((tickerSymbol != null) && (_tickerSymbol == null)) ||
319                 ((tickerSymbol != null) && (_tickerSymbol != null) &&
320                 !tickerSymbol.equals(_tickerSymbol))) {
321             _tickerSymbol = tickerSymbol;
322         }
323     }
324 
325     public String getIndustry() {
326         return GetterUtil.getString(_industry);
327     }
328 
329     public void setIndustry(String industry) {
330         if (((industry == null) && (_industry != null)) ||
331                 ((industry != null) && (_industry == null)) ||
332                 ((industry != null) && (_industry != null) &&
333                 !industry.equals(_industry))) {
334             _industry = industry;
335         }
336     }
337 
338     public String getType() {
339         return GetterUtil.getString(_type);
340     }
341 
342     public void setType(String type) {
343         if (((type == null) && (_type != null)) ||
344                 ((type != null) && (_type == null)) ||
345                 ((type != null) && (_type != null) && !type.equals(_type))) {
346             _type = type;
347         }
348     }
349 
350     public String getSize() {
351         return GetterUtil.getString(_size);
352     }
353 
354     public void setSize(String size) {
355         if (((size == null) && (_size != null)) ||
356                 ((size != null) && (_size == null)) ||
357                 ((size != null) && (_size != null) && !size.equals(_size))) {
358             _size = size;
359         }
360     }
361 
362     public Account toEscapedModel() {
363         if (isEscapedModel()) {
364             return (Account)this;
365         }
366         else {
367             Account model = new AccountImpl();
368 
369             model.setEscapedModel(true);
370 
371             model.setAccountId(getAccountId());
372             model.setCompanyId(getCompanyId());
373             model.setUserId(getUserId());
374             model.setUserName(HtmlUtil.escape(getUserName()));
375             model.setCreateDate(getCreateDate());
376             model.setModifiedDate(getModifiedDate());
377             model.setParentAccountId(getParentAccountId());
378             model.setName(HtmlUtil.escape(getName()));
379             model.setLegalName(HtmlUtil.escape(getLegalName()));
380             model.setLegalId(HtmlUtil.escape(getLegalId()));
381             model.setLegalType(HtmlUtil.escape(getLegalType()));
382             model.setSicCode(HtmlUtil.escape(getSicCode()));
383             model.setTickerSymbol(HtmlUtil.escape(getTickerSymbol()));
384             model.setIndustry(HtmlUtil.escape(getIndustry()));
385             model.setType(HtmlUtil.escape(getType()));
386             model.setSize(HtmlUtil.escape(getSize()));
387 
388             model = (Account)Proxy.newProxyInstance(Account.class.getClassLoader(),
389                     new Class[] { Account.class },
390                     new ReadOnlyBeanHandler(model));
391 
392             return model;
393         }
394     }
395 
396     public Object clone() {
397         AccountImpl clone = new AccountImpl();
398 
399         clone.setAccountId(getAccountId());
400         clone.setCompanyId(getCompanyId());
401         clone.setUserId(getUserId());
402         clone.setUserName(getUserName());
403         clone.setCreateDate(getCreateDate());
404         clone.setModifiedDate(getModifiedDate());
405         clone.setParentAccountId(getParentAccountId());
406         clone.setName(getName());
407         clone.setLegalName(getLegalName());
408         clone.setLegalId(getLegalId());
409         clone.setLegalType(getLegalType());
410         clone.setSicCode(getSicCode());
411         clone.setTickerSymbol(getTickerSymbol());
412         clone.setIndustry(getIndustry());
413         clone.setType(getType());
414         clone.setSize(getSize());
415 
416         return clone;
417     }
418 
419     public int compareTo(Object obj) {
420         if (obj == null) {
421             return -1;
422         }
423 
424         AccountImpl account = (AccountImpl)obj;
425 
426         long pk = account.getPrimaryKey();
427 
428         if (getPrimaryKey() < pk) {
429             return -1;
430         }
431         else if (getPrimaryKey() > pk) {
432             return 1;
433         }
434         else {
435             return 0;
436         }
437     }
438 
439     public boolean equals(Object obj) {
440         if (obj == null) {
441             return false;
442         }
443 
444         AccountImpl account = null;
445 
446         try {
447             account = (AccountImpl)obj;
448         }
449         catch (ClassCastException cce) {
450             return false;
451         }
452 
453         long pk = account.getPrimaryKey();
454 
455         if (getPrimaryKey() == pk) {
456             return true;
457         }
458         else {
459             return false;
460         }
461     }
462 
463     public int hashCode() {
464         return (int)getPrimaryKey();
465     }
466 
467     private long _accountId;
468     private long _companyId;
469     private long _userId;
470     private String _userName;
471     private Date _createDate;
472     private Date _modifiedDate;
473     private long _parentAccountId;
474     private String _name;
475     private String _legalName;
476     private String _legalId;
477     private String _legalType;
478     private String _sicCode;
479     private String _tickerSymbol;
480     private String _industry;
481     private String _type;
482     private String _size;
483 }