1   /**
2    * Copyright (c) 2000-2009 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  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="AccountModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>Account</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.model.Account
60   * @see com.liferay.portal.model.AccountModel
61   * @see com.liferay.portal.model.impl.AccountImpl
62   *
63   */
64  public class AccountModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "Account_";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "accountId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "parentAccountId", new Integer(Types.BIGINT) },
86              
87  
88              { "name", new Integer(Types.VARCHAR) },
89              
90  
91              { "legalName", new Integer(Types.VARCHAR) },
92              
93  
94              { "legalId", new Integer(Types.VARCHAR) },
95              
96  
97              { "legalType", new Integer(Types.VARCHAR) },
98              
99  
100             { "sicCode", new Integer(Types.VARCHAR) },
101             
102 
103             { "tickerSymbol", new Integer(Types.VARCHAR) },
104             
105 
106             { "industry", new Integer(Types.VARCHAR) },
107             
108 
109             { "type_", new Integer(Types.VARCHAR) },
110             
111 
112             { "size_", new Integer(Types.VARCHAR) }
113         };
114     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)";
115     public static final String TABLE_SQL_DROP = "drop table Account_";
116     public static final String DATA_SOURCE = "liferayDataSource";
117     public static final String SESSION_FACTORY = "liferaySessionFactory";
118     public static final String TX_MANAGER = "liferayTransactionManager";
119     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
120                 "value.object.finder.cache.enabled.com.liferay.portal.model.Account"),
121             true);
122 
123     public static Account toModel(AccountSoap soapModel) {
124         Account model = new AccountImpl();
125 
126         model.setAccountId(soapModel.getAccountId());
127         model.setCompanyId(soapModel.getCompanyId());
128         model.setUserId(soapModel.getUserId());
129         model.setUserName(soapModel.getUserName());
130         model.setCreateDate(soapModel.getCreateDate());
131         model.setModifiedDate(soapModel.getModifiedDate());
132         model.setParentAccountId(soapModel.getParentAccountId());
133         model.setName(soapModel.getName());
134         model.setLegalName(soapModel.getLegalName());
135         model.setLegalId(soapModel.getLegalId());
136         model.setLegalType(soapModel.getLegalType());
137         model.setSicCode(soapModel.getSicCode());
138         model.setTickerSymbol(soapModel.getTickerSymbol());
139         model.setIndustry(soapModel.getIndustry());
140         model.setType(soapModel.getType());
141         model.setSize(soapModel.getSize());
142 
143         return model;
144     }
145 
146     public static List<Account> toModels(AccountSoap[] soapModels) {
147         List<Account> models = new ArrayList<Account>(soapModels.length);
148 
149         for (AccountSoap soapModel : soapModels) {
150             models.add(toModel(soapModel));
151         }
152 
153         return models;
154     }
155 
156     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
157                 "lock.expiration.time.com.liferay.portal.model.Account"));
158 
159     public AccountModelImpl() {
160     }
161 
162     public long getPrimaryKey() {
163         return _accountId;
164     }
165 
166     public void setPrimaryKey(long pk) {
167         setAccountId(pk);
168     }
169 
170     public Serializable getPrimaryKeyObj() {
171         return new Long(_accountId);
172     }
173 
174     public long getAccountId() {
175         return _accountId;
176     }
177 
178     public void setAccountId(long accountId) {
179         if (accountId != _accountId) {
180             _accountId = accountId;
181         }
182     }
183 
184     public long getCompanyId() {
185         return _companyId;
186     }
187 
188     public void setCompanyId(long companyId) {
189         if (companyId != _companyId) {
190             _companyId = companyId;
191         }
192     }
193 
194     public long getUserId() {
195         return _userId;
196     }
197 
198     public void setUserId(long userId) {
199         if (userId != _userId) {
200             _userId = userId;
201         }
202     }
203 
204     public String getUserName() {
205         return GetterUtil.getString(_userName);
206     }
207 
208     public void setUserName(String userName) {
209         if (((userName == null) && (_userName != null)) ||
210                 ((userName != null) && (_userName == null)) ||
211                 ((userName != null) && (_userName != null) &&
212                 !userName.equals(_userName))) {
213             _userName = userName;
214         }
215     }
216 
217     public Date getCreateDate() {
218         return _createDate;
219     }
220 
221     public void setCreateDate(Date createDate) {
222         if (((createDate == null) && (_createDate != null)) ||
223                 ((createDate != null) && (_createDate == null)) ||
224                 ((createDate != null) && (_createDate != null) &&
225                 !createDate.equals(_createDate))) {
226             _createDate = createDate;
227         }
228     }
229 
230     public Date getModifiedDate() {
231         return _modifiedDate;
232     }
233 
234     public void setModifiedDate(Date modifiedDate) {
235         if (((modifiedDate == null) && (_modifiedDate != null)) ||
236                 ((modifiedDate != null) && (_modifiedDate == null)) ||
237                 ((modifiedDate != null) && (_modifiedDate != null) &&
238                 !modifiedDate.equals(_modifiedDate))) {
239             _modifiedDate = modifiedDate;
240         }
241     }
242 
243     public long getParentAccountId() {
244         return _parentAccountId;
245     }
246 
247     public void setParentAccountId(long parentAccountId) {
248         if (parentAccountId != _parentAccountId) {
249             _parentAccountId = parentAccountId;
250         }
251     }
252 
253     public String getName() {
254         return GetterUtil.getString(_name);
255     }
256 
257     public void setName(String name) {
258         if (((name == null) && (_name != null)) ||
259                 ((name != null) && (_name == null)) ||
260                 ((name != null) && (_name != null) && !name.equals(_name))) {
261             _name = name;
262         }
263     }
264 
265     public String getLegalName() {
266         return GetterUtil.getString(_legalName);
267     }
268 
269     public void setLegalName(String legalName) {
270         if (((legalName == null) && (_legalName != null)) ||
271                 ((legalName != null) && (_legalName == null)) ||
272                 ((legalName != null) && (_legalName != null) &&
273                 !legalName.equals(_legalName))) {
274             _legalName = legalName;
275         }
276     }
277 
278     public String getLegalId() {
279         return GetterUtil.getString(_legalId);
280     }
281 
282     public void setLegalId(String legalId) {
283         if (((legalId == null) && (_legalId != null)) ||
284                 ((legalId != null) && (_legalId == null)) ||
285                 ((legalId != null) && (_legalId != null) &&
286                 !legalId.equals(_legalId))) {
287             _legalId = legalId;
288         }
289     }
290 
291     public String getLegalType() {
292         return GetterUtil.getString(_legalType);
293     }
294 
295     public void setLegalType(String legalType) {
296         if (((legalType == null) && (_legalType != null)) ||
297                 ((legalType != null) && (_legalType == null)) ||
298                 ((legalType != null) && (_legalType != null) &&
299                 !legalType.equals(_legalType))) {
300             _legalType = legalType;
301         }
302     }
303 
304     public String getSicCode() {
305         return GetterUtil.getString(_sicCode);
306     }
307 
308     public void setSicCode(String sicCode) {
309         if (((sicCode == null) && (_sicCode != null)) ||
310                 ((sicCode != null) && (_sicCode == null)) ||
311                 ((sicCode != null) && (_sicCode != null) &&
312                 !sicCode.equals(_sicCode))) {
313             _sicCode = sicCode;
314         }
315     }
316 
317     public String getTickerSymbol() {
318         return GetterUtil.getString(_tickerSymbol);
319     }
320 
321     public void setTickerSymbol(String tickerSymbol) {
322         if (((tickerSymbol == null) && (_tickerSymbol != null)) ||
323                 ((tickerSymbol != null) && (_tickerSymbol == null)) ||
324                 ((tickerSymbol != null) && (_tickerSymbol != null) &&
325                 !tickerSymbol.equals(_tickerSymbol))) {
326             _tickerSymbol = tickerSymbol;
327         }
328     }
329 
330     public String getIndustry() {
331         return GetterUtil.getString(_industry);
332     }
333 
334     public void setIndustry(String industry) {
335         if (((industry == null) && (_industry != null)) ||
336                 ((industry != null) && (_industry == null)) ||
337                 ((industry != null) && (_industry != null) &&
338                 !industry.equals(_industry))) {
339             _industry = industry;
340         }
341     }
342 
343     public String getType() {
344         return GetterUtil.getString(_type);
345     }
346 
347     public void setType(String type) {
348         if (((type == null) && (_type != null)) ||
349                 ((type != null) && (_type == null)) ||
350                 ((type != null) && (_type != null) && !type.equals(_type))) {
351             _type = type;
352         }
353     }
354 
355     public String getSize() {
356         return GetterUtil.getString(_size);
357     }
358 
359     public void setSize(String size) {
360         if (((size == null) && (_size != null)) ||
361                 ((size != null) && (_size == null)) ||
362                 ((size != null) && (_size != null) && !size.equals(_size))) {
363             _size = size;
364         }
365     }
366 
367     public Account toEscapedModel() {
368         if (isEscapedModel()) {
369             return (Account)this;
370         }
371         else {
372             Account model = new AccountImpl();
373 
374             model.setNew(isNew());
375             model.setEscapedModel(true);
376 
377             model.setAccountId(getAccountId());
378             model.setCompanyId(getCompanyId());
379             model.setUserId(getUserId());
380             model.setUserName(HtmlUtil.escape(getUserName()));
381             model.setCreateDate(getCreateDate());
382             model.setModifiedDate(getModifiedDate());
383             model.setParentAccountId(getParentAccountId());
384             model.setName(HtmlUtil.escape(getName()));
385             model.setLegalName(HtmlUtil.escape(getLegalName()));
386             model.setLegalId(HtmlUtil.escape(getLegalId()));
387             model.setLegalType(HtmlUtil.escape(getLegalType()));
388             model.setSicCode(HtmlUtil.escape(getSicCode()));
389             model.setTickerSymbol(HtmlUtil.escape(getTickerSymbol()));
390             model.setIndustry(HtmlUtil.escape(getIndustry()));
391             model.setType(HtmlUtil.escape(getType()));
392             model.setSize(HtmlUtil.escape(getSize()));
393 
394             model = (Account)Proxy.newProxyInstance(Account.class.getClassLoader(),
395                     new Class[] { Account.class },
396                     new ReadOnlyBeanHandler(model));
397 
398             return model;
399         }
400     }
401 
402     public ExpandoBridge getExpandoBridge() {
403         if (_expandoBridge == null) {
404             _expandoBridge = new ExpandoBridgeImpl(Account.class.getName(),
405                     getPrimaryKey());
406         }
407 
408         return _expandoBridge;
409     }
410 
411     public Object clone() {
412         AccountImpl clone = new AccountImpl();
413 
414         clone.setAccountId(getAccountId());
415         clone.setCompanyId(getCompanyId());
416         clone.setUserId(getUserId());
417         clone.setUserName(getUserName());
418         clone.setCreateDate(getCreateDate());
419         clone.setModifiedDate(getModifiedDate());
420         clone.setParentAccountId(getParentAccountId());
421         clone.setName(getName());
422         clone.setLegalName(getLegalName());
423         clone.setLegalId(getLegalId());
424         clone.setLegalType(getLegalType());
425         clone.setSicCode(getSicCode());
426         clone.setTickerSymbol(getTickerSymbol());
427         clone.setIndustry(getIndustry());
428         clone.setType(getType());
429         clone.setSize(getSize());
430 
431         return clone;
432     }
433 
434     public int compareTo(Object obj) {
435         if (obj == null) {
436             return -1;
437         }
438 
439         AccountImpl account = (AccountImpl)obj;
440 
441         long pk = account.getPrimaryKey();
442 
443         if (getPrimaryKey() < pk) {
444             return -1;
445         }
446         else if (getPrimaryKey() > pk) {
447             return 1;
448         }
449         else {
450             return 0;
451         }
452     }
453 
454     public boolean equals(Object obj) {
455         if (obj == null) {
456             return false;
457         }
458 
459         AccountImpl account = null;
460 
461         try {
462             account = (AccountImpl)obj;
463         }
464         catch (ClassCastException cce) {
465             return false;
466         }
467 
468         long pk = account.getPrimaryKey();
469 
470         if (getPrimaryKey() == pk) {
471             return true;
472         }
473         else {
474             return false;
475         }
476     }
477 
478     public int hashCode() {
479         return (int)getPrimaryKey();
480     }
481 
482     private long _accountId;
483     private long _companyId;
484     private long _userId;
485     private String _userName;
486     private Date _createDate;
487     private Date _modifiedDate;
488     private long _parentAccountId;
489     private String _name;
490     private String _legalName;
491     private String _legalId;
492     private String _legalType;
493     private String _sicCode;
494     private String _tickerSymbol;
495     private String _industry;
496     private String _type;
497     private String _size;
498     private transient ExpandoBridge _expandoBridge;
499 }