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