1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Account;
26  import com.liferay.portal.model.AccountSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="AccountModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Account</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.model.Account
54   * @see com.liferay.portal.model.AccountModel
55   * @see com.liferay.portal.model.impl.AccountImpl
56   *
57   */
58  public class AccountModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Account_";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "accountId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "userId", new Integer(Types.BIGINT) },
68              
69  
70              { "userName", new Integer(Types.VARCHAR) },
71              
72  
73              { "createDate", new Integer(Types.TIMESTAMP) },
74              
75  
76              { "modifiedDate", new Integer(Types.TIMESTAMP) },
77              
78  
79              { "parentAccountId", new Integer(Types.BIGINT) },
80              
81  
82              { "name", new Integer(Types.VARCHAR) },
83              
84  
85              { "legalName", new Integer(Types.VARCHAR) },
86              
87  
88              { "legalId", new Integer(Types.VARCHAR) },
89              
90  
91              { "legalType", new Integer(Types.VARCHAR) },
92              
93  
94              { "sicCode", new Integer(Types.VARCHAR) },
95              
96  
97              { "tickerSymbol", new Integer(Types.VARCHAR) },
98              
99  
100             { "industry", new Integer(Types.VARCHAR) },
101             
102 
103             { "type_", new Integer(Types.VARCHAR) },
104             
105 
106             { "size_", new Integer(Types.VARCHAR) }
107         };
108     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)";
109     public static final String TABLE_SQL_DROP = "drop table Account_";
110     public static final String DATA_SOURCE = "liferayDataSource";
111     public static final String SESSION_FACTORY = "liferaySessionFactory";
112     public static final String TX_MANAGER = "liferayTransactionManager";
113     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
114                 "value.object.finder.cache.enabled.com.liferay.portal.model.Account"),
115             true);
116 
117     public static Account toModel(AccountSoap soapModel) {
118         Account model = new AccountImpl();
119 
120         model.setAccountId(soapModel.getAccountId());
121         model.setCompanyId(soapModel.getCompanyId());
122         model.setUserId(soapModel.getUserId());
123         model.setUserName(soapModel.getUserName());
124         model.setCreateDate(soapModel.getCreateDate());
125         model.setModifiedDate(soapModel.getModifiedDate());
126         model.setParentAccountId(soapModel.getParentAccountId());
127         model.setName(soapModel.getName());
128         model.setLegalName(soapModel.getLegalName());
129         model.setLegalId(soapModel.getLegalId());
130         model.setLegalType(soapModel.getLegalType());
131         model.setSicCode(soapModel.getSicCode());
132         model.setTickerSymbol(soapModel.getTickerSymbol());
133         model.setIndustry(soapModel.getIndustry());
134         model.setType(soapModel.getType());
135         model.setSize(soapModel.getSize());
136 
137         return model;
138     }
139 
140     public static List<Account> toModels(AccountSoap[] soapModels) {
141         List<Account> models = new ArrayList<Account>(soapModels.length);
142 
143         for (AccountSoap soapModel : soapModels) {
144             models.add(toModel(soapModel));
145         }
146 
147         return models;
148     }
149 
150     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
151                 "lock.expiration.time.com.liferay.portal.model.Account"));
152 
153     public AccountModelImpl() {
154     }
155 
156     public long getPrimaryKey() {
157         return _accountId;
158     }
159 
160     public void setPrimaryKey(long pk) {
161         setAccountId(pk);
162     }
163 
164     public Serializable getPrimaryKeyObj() {
165         return new Long(_accountId);
166     }
167 
168     public long getAccountId() {
169         return _accountId;
170     }
171 
172     public void setAccountId(long accountId) {
173         if (accountId != _accountId) {
174             _accountId = accountId;
175         }
176     }
177 
178     public long getCompanyId() {
179         return _companyId;
180     }
181 
182     public void setCompanyId(long companyId) {
183         if (companyId != _companyId) {
184             _companyId = companyId;
185         }
186     }
187 
188     public long getUserId() {
189         return _userId;
190     }
191 
192     public void setUserId(long userId) {
193         if (userId != _userId) {
194             _userId = userId;
195         }
196     }
197 
198     public String getUserName() {
199         return GetterUtil.getString(_userName);
200     }
201 
202     public void setUserName(String userName) {
203         if (((userName == null) && (_userName != null)) ||
204                 ((userName != null) && (_userName == null)) ||
205                 ((userName != null) && (_userName != null) &&
206                 !userName.equals(_userName))) {
207             _userName = userName;
208         }
209     }
210 
211     public Date getCreateDate() {
212         return _createDate;
213     }
214 
215     public void setCreateDate(Date createDate) {
216         if (((createDate == null) && (_createDate != null)) ||
217                 ((createDate != null) && (_createDate == null)) ||
218                 ((createDate != null) && (_createDate != null) &&
219                 !createDate.equals(_createDate))) {
220             _createDate = createDate;
221         }
222     }
223 
224     public Date getModifiedDate() {
225         return _modifiedDate;
226     }
227 
228     public void setModifiedDate(Date modifiedDate) {
229         if (((modifiedDate == null) && (_modifiedDate != null)) ||
230                 ((modifiedDate != null) && (_modifiedDate == null)) ||
231                 ((modifiedDate != null) && (_modifiedDate != null) &&
232                 !modifiedDate.equals(_modifiedDate))) {
233             _modifiedDate = modifiedDate;
234         }
235     }
236 
237     public long getParentAccountId() {
238         return _parentAccountId;
239     }
240 
241     public void setParentAccountId(long parentAccountId) {
242         if (parentAccountId != _parentAccountId) {
243             _parentAccountId = parentAccountId;
244         }
245     }
246 
247     public String getName() {
248         return GetterUtil.getString(_name);
249     }
250 
251     public void setName(String name) {
252         if (((name == null) && (_name != null)) ||
253                 ((name != null) && (_name == null)) ||
254                 ((name != null) && (_name != null) && !name.equals(_name))) {
255             _name = name;
256         }
257     }
258 
259     public String getLegalName() {
260         return GetterUtil.getString(_legalName);
261     }
262 
263     public void setLegalName(String legalName) {
264         if (((legalName == null) && (_legalName != null)) ||
265                 ((legalName != null) && (_legalName == null)) ||
266                 ((legalName != null) && (_legalName != null) &&
267                 !legalName.equals(_legalName))) {
268             _legalName = legalName;
269         }
270     }
271 
272     public String getLegalId() {
273         return GetterUtil.getString(_legalId);
274     }
275 
276     public void setLegalId(String legalId) {
277         if (((legalId == null) && (_legalId != null)) ||
278                 ((legalId != null) && (_legalId == null)) ||
279                 ((legalId != null) && (_legalId != null) &&
280                 !legalId.equals(_legalId))) {
281             _legalId = legalId;
282         }
283     }
284 
285     public String getLegalType() {
286         return GetterUtil.getString(_legalType);
287     }
288 
289     public void setLegalType(String legalType) {
290         if (((legalType == null) && (_legalType != null)) ||
291                 ((legalType != null) && (_legalType == null)) ||
292                 ((legalType != null) && (_legalType != null) &&
293                 !legalType.equals(_legalType))) {
294             _legalType = legalType;
295         }
296     }
297 
298     public String getSicCode() {
299         return GetterUtil.getString(_sicCode);
300     }
301 
302     public void setSicCode(String sicCode) {
303         if (((sicCode == null) && (_sicCode != null)) ||
304                 ((sicCode != null) && (_sicCode == null)) ||
305                 ((sicCode != null) && (_sicCode != null) &&
306                 !sicCode.equals(_sicCode))) {
307             _sicCode = sicCode;
308         }
309     }
310 
311     public String getTickerSymbol() {
312         return GetterUtil.getString(_tickerSymbol);
313     }
314 
315     public void setTickerSymbol(String tickerSymbol) {
316         if (((tickerSymbol == null) && (_tickerSymbol != null)) ||
317                 ((tickerSymbol != null) && (_tickerSymbol == null)) ||
318                 ((tickerSymbol != null) && (_tickerSymbol != null) &&
319                 !tickerSymbol.equals(_tickerSymbol))) {
320             _tickerSymbol = tickerSymbol;
321         }
322     }
323 
324     public String getIndustry() {
325         return GetterUtil.getString(_industry);
326     }
327 
328     public void setIndustry(String industry) {
329         if (((industry == null) && (_industry != null)) ||
330                 ((industry != null) && (_industry == null)) ||
331                 ((industry != null) && (_industry != null) &&
332                 !industry.equals(_industry))) {
333             _industry = industry;
334         }
335     }
336 
337     public String getType() {
338         return GetterUtil.getString(_type);
339     }
340 
341     public void setType(String type) {
342         if (((type == null) && (_type != null)) ||
343                 ((type != null) && (_type == null)) ||
344                 ((type != null) && (_type != null) && !type.equals(_type))) {
345             _type = type;
346         }
347     }
348 
349     public String getSize() {
350         return GetterUtil.getString(_size);
351     }
352 
353     public void setSize(String size) {
354         if (((size == null) && (_size != null)) ||
355                 ((size != null) && (_size == null)) ||
356                 ((size != null) && (_size != null) && !size.equals(_size))) {
357             _size = size;
358         }
359     }
360 
361     public Account toEscapedModel() {
362         if (isEscapedModel()) {
363             return (Account)this;
364         }
365         else {
366             Account model = new AccountImpl();
367 
368             model.setNew(isNew());
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 }