001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.Account;
025    import com.liferay.portal.model.AccountModel;
026    import com.liferay.portal.model.AccountSoap;
027    import com.liferay.portal.model.CacheModel;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the Account service. Represents a row in the "Account_" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portal.model.AccountModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AccountImpl}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see AccountImpl
051     * @see com.liferay.portal.model.Account
052     * @see com.liferay.portal.model.AccountModel
053     * @generated
054     */
055    @JSON(strict = true)
056    public class AccountModelImpl extends BaseModelImpl<Account>
057            implements AccountModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a account model instance should use the {@link com.liferay.portal.model.Account} interface instead.
062             */
063            public static final String TABLE_NAME = "Account_";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "accountId", Types.BIGINT },
066                            { "companyId", Types.BIGINT },
067                            { "userId", Types.BIGINT },
068                            { "userName", Types.VARCHAR },
069                            { "createDate", Types.TIMESTAMP },
070                            { "modifiedDate", Types.TIMESTAMP },
071                            { "parentAccountId", Types.BIGINT },
072                            { "name", Types.VARCHAR },
073                            { "legalName", Types.VARCHAR },
074                            { "legalId", Types.VARCHAR },
075                            { "legalType", Types.VARCHAR },
076                            { "sicCode", Types.VARCHAR },
077                            { "tickerSymbol", Types.VARCHAR },
078                            { "industry", Types.VARCHAR },
079                            { "type_", Types.VARCHAR },
080                            { "size_", Types.VARCHAR }
081                    };
082            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)";
083            public static final String TABLE_SQL_DROP = "drop table Account_";
084            public static final String DATA_SOURCE = "liferayDataSource";
085            public static final String SESSION_FACTORY = "liferaySessionFactory";
086            public static final String TX_MANAGER = "liferayTransactionManager";
087            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Account"),
089                            true);
090            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Account"),
092                            true);
093            public static final boolean COLUMN_BITMASK_ENABLED = false;
094    
095            /**
096             * Converts the soap model instance into a normal model instance.
097             *
098             * @param soapModel the soap model instance to convert
099             * @return the normal model instance
100             */
101            public static Account toModel(AccountSoap soapModel) {
102                    Account model = new AccountImpl();
103    
104                    model.setAccountId(soapModel.getAccountId());
105                    model.setCompanyId(soapModel.getCompanyId());
106                    model.setUserId(soapModel.getUserId());
107                    model.setUserName(soapModel.getUserName());
108                    model.setCreateDate(soapModel.getCreateDate());
109                    model.setModifiedDate(soapModel.getModifiedDate());
110                    model.setParentAccountId(soapModel.getParentAccountId());
111                    model.setName(soapModel.getName());
112                    model.setLegalName(soapModel.getLegalName());
113                    model.setLegalId(soapModel.getLegalId());
114                    model.setLegalType(soapModel.getLegalType());
115                    model.setSicCode(soapModel.getSicCode());
116                    model.setTickerSymbol(soapModel.getTickerSymbol());
117                    model.setIndustry(soapModel.getIndustry());
118                    model.setType(soapModel.getType());
119                    model.setSize(soapModel.getSize());
120    
121                    return model;
122            }
123    
124            /**
125             * Converts the soap model instances into normal model instances.
126             *
127             * @param soapModels the soap model instances to convert
128             * @return the normal model instances
129             */
130            public static List<Account> toModels(AccountSoap[] soapModels) {
131                    List<Account> models = new ArrayList<Account>(soapModels.length);
132    
133                    for (AccountSoap soapModel : soapModels) {
134                            models.add(toModel(soapModel));
135                    }
136    
137                    return models;
138            }
139    
140            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
141                                    "lock.expiration.time.com.liferay.portal.model.Account"));
142    
143            public AccountModelImpl() {
144            }
145    
146            public long getPrimaryKey() {
147                    return _accountId;
148            }
149    
150            public void setPrimaryKey(long primaryKey) {
151                    setAccountId(primaryKey);
152            }
153    
154            public Serializable getPrimaryKeyObj() {
155                    return new Long(_accountId);
156            }
157    
158            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
159                    setPrimaryKey(((Long)primaryKeyObj).longValue());
160            }
161    
162            public Class<?> getModelClass() {
163                    return Account.class;
164            }
165    
166            public String getModelClassName() {
167                    return Account.class.getName();
168            }
169    
170            @JSON
171            public long getAccountId() {
172                    return _accountId;
173            }
174    
175            public void setAccountId(long accountId) {
176                    _accountId = accountId;
177            }
178    
179            @JSON
180            public long getCompanyId() {
181                    return _companyId;
182            }
183    
184            public void setCompanyId(long companyId) {
185                    _companyId = companyId;
186            }
187    
188            @JSON
189            public long getUserId() {
190                    return _userId;
191            }
192    
193            public void setUserId(long userId) {
194                    _userId = userId;
195            }
196    
197            public String getUserUuid() throws SystemException {
198                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
199            }
200    
201            public void setUserUuid(String userUuid) {
202                    _userUuid = userUuid;
203            }
204    
205            @JSON
206            public String getUserName() {
207                    if (_userName == null) {
208                            return StringPool.BLANK;
209                    }
210                    else {
211                            return _userName;
212                    }
213            }
214    
215            public void setUserName(String userName) {
216                    _userName = userName;
217            }
218    
219            @JSON
220            public Date getCreateDate() {
221                    return _createDate;
222            }
223    
224            public void setCreateDate(Date createDate) {
225                    _createDate = createDate;
226            }
227    
228            @JSON
229            public Date getModifiedDate() {
230                    return _modifiedDate;
231            }
232    
233            public void setModifiedDate(Date modifiedDate) {
234                    _modifiedDate = modifiedDate;
235            }
236    
237            @JSON
238            public long getParentAccountId() {
239                    return _parentAccountId;
240            }
241    
242            public void setParentAccountId(long parentAccountId) {
243                    _parentAccountId = parentAccountId;
244            }
245    
246            @JSON
247            public String getName() {
248                    if (_name == null) {
249                            return StringPool.BLANK;
250                    }
251                    else {
252                            return _name;
253                    }
254            }
255    
256            public void setName(String name) {
257                    _name = name;
258            }
259    
260            @JSON
261            public String getLegalName() {
262                    if (_legalName == null) {
263                            return StringPool.BLANK;
264                    }
265                    else {
266                            return _legalName;
267                    }
268            }
269    
270            public void setLegalName(String legalName) {
271                    _legalName = legalName;
272            }
273    
274            @JSON
275            public String getLegalId() {
276                    if (_legalId == null) {
277                            return StringPool.BLANK;
278                    }
279                    else {
280                            return _legalId;
281                    }
282            }
283    
284            public void setLegalId(String legalId) {
285                    _legalId = legalId;
286            }
287    
288            @JSON
289            public String getLegalType() {
290                    if (_legalType == null) {
291                            return StringPool.BLANK;
292                    }
293                    else {
294                            return _legalType;
295                    }
296            }
297    
298            public void setLegalType(String legalType) {
299                    _legalType = legalType;
300            }
301    
302            @JSON
303            public String getSicCode() {
304                    if (_sicCode == null) {
305                            return StringPool.BLANK;
306                    }
307                    else {
308                            return _sicCode;
309                    }
310            }
311    
312            public void setSicCode(String sicCode) {
313                    _sicCode = sicCode;
314            }
315    
316            @JSON
317            public String getTickerSymbol() {
318                    if (_tickerSymbol == null) {
319                            return StringPool.BLANK;
320                    }
321                    else {
322                            return _tickerSymbol;
323                    }
324            }
325    
326            public void setTickerSymbol(String tickerSymbol) {
327                    _tickerSymbol = tickerSymbol;
328            }
329    
330            @JSON
331            public String getIndustry() {
332                    if (_industry == null) {
333                            return StringPool.BLANK;
334                    }
335                    else {
336                            return _industry;
337                    }
338            }
339    
340            public void setIndustry(String industry) {
341                    _industry = industry;
342            }
343    
344            @JSON
345            public String getType() {
346                    if (_type == null) {
347                            return StringPool.BLANK;
348                    }
349                    else {
350                            return _type;
351                    }
352            }
353    
354            public void setType(String type) {
355                    _type = type;
356            }
357    
358            @JSON
359            public String getSize() {
360                    if (_size == null) {
361                            return StringPool.BLANK;
362                    }
363                    else {
364                            return _size;
365                    }
366            }
367    
368            public void setSize(String size) {
369                    _size = size;
370            }
371    
372            @Override
373            public Account toEscapedModel() {
374                    if (_escapedModelProxy == null) {
375                            _escapedModelProxy = (Account)ProxyUtil.newProxyInstance(_classLoader,
376                                            _escapedModelProxyInterfaces,
377                                            new AutoEscapeBeanHandler(this));
378                    }
379    
380                    return _escapedModelProxy;
381            }
382    
383            @Override
384            public ExpandoBridge getExpandoBridge() {
385                    if (_expandoBridge == null) {
386                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
387                                            Account.class.getName(), getPrimaryKey());
388                    }
389    
390                    return _expandoBridge;
391            }
392    
393            @Override
394            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
395                    getExpandoBridge().setAttributes(serviceContext);
396            }
397    
398            @Override
399            public Object clone() {
400                    AccountImpl accountImpl = new AccountImpl();
401    
402                    accountImpl.setAccountId(getAccountId());
403                    accountImpl.setCompanyId(getCompanyId());
404                    accountImpl.setUserId(getUserId());
405                    accountImpl.setUserName(getUserName());
406                    accountImpl.setCreateDate(getCreateDate());
407                    accountImpl.setModifiedDate(getModifiedDate());
408                    accountImpl.setParentAccountId(getParentAccountId());
409                    accountImpl.setName(getName());
410                    accountImpl.setLegalName(getLegalName());
411                    accountImpl.setLegalId(getLegalId());
412                    accountImpl.setLegalType(getLegalType());
413                    accountImpl.setSicCode(getSicCode());
414                    accountImpl.setTickerSymbol(getTickerSymbol());
415                    accountImpl.setIndustry(getIndustry());
416                    accountImpl.setType(getType());
417                    accountImpl.setSize(getSize());
418    
419                    accountImpl.resetOriginalValues();
420    
421                    return accountImpl;
422            }
423    
424            public int compareTo(Account account) {
425                    long primaryKey = account.getPrimaryKey();
426    
427                    if (getPrimaryKey() < primaryKey) {
428                            return -1;
429                    }
430                    else if (getPrimaryKey() > primaryKey) {
431                            return 1;
432                    }
433                    else {
434                            return 0;
435                    }
436            }
437    
438            @Override
439            public boolean equals(Object obj) {
440                    if (obj == null) {
441                            return false;
442                    }
443    
444                    Account account = null;
445    
446                    try {
447                            account = (Account)obj;
448                    }
449                    catch (ClassCastException cce) {
450                            return false;
451                    }
452    
453                    long primaryKey = account.getPrimaryKey();
454    
455                    if (getPrimaryKey() == primaryKey) {
456                            return true;
457                    }
458                    else {
459                            return false;
460                    }
461            }
462    
463            @Override
464            public int hashCode() {
465                    return (int)getPrimaryKey();
466            }
467    
468            @Override
469            public void resetOriginalValues() {
470            }
471    
472            @Override
473            public CacheModel<Account> toCacheModel() {
474                    AccountCacheModel accountCacheModel = new AccountCacheModel();
475    
476                    accountCacheModel.accountId = getAccountId();
477    
478                    accountCacheModel.companyId = getCompanyId();
479    
480                    accountCacheModel.userId = getUserId();
481    
482                    accountCacheModel.userName = getUserName();
483    
484                    String userName = accountCacheModel.userName;
485    
486                    if ((userName != null) && (userName.length() == 0)) {
487                            accountCacheModel.userName = null;
488                    }
489    
490                    Date createDate = getCreateDate();
491    
492                    if (createDate != null) {
493                            accountCacheModel.createDate = createDate.getTime();
494                    }
495                    else {
496                            accountCacheModel.createDate = Long.MIN_VALUE;
497                    }
498    
499                    Date modifiedDate = getModifiedDate();
500    
501                    if (modifiedDate != null) {
502                            accountCacheModel.modifiedDate = modifiedDate.getTime();
503                    }
504                    else {
505                            accountCacheModel.modifiedDate = Long.MIN_VALUE;
506                    }
507    
508                    accountCacheModel.parentAccountId = getParentAccountId();
509    
510                    accountCacheModel.name = getName();
511    
512                    String name = accountCacheModel.name;
513    
514                    if ((name != null) && (name.length() == 0)) {
515                            accountCacheModel.name = null;
516                    }
517    
518                    accountCacheModel.legalName = getLegalName();
519    
520                    String legalName = accountCacheModel.legalName;
521    
522                    if ((legalName != null) && (legalName.length() == 0)) {
523                            accountCacheModel.legalName = null;
524                    }
525    
526                    accountCacheModel.legalId = getLegalId();
527    
528                    String legalId = accountCacheModel.legalId;
529    
530                    if ((legalId != null) && (legalId.length() == 0)) {
531                            accountCacheModel.legalId = null;
532                    }
533    
534                    accountCacheModel.legalType = getLegalType();
535    
536                    String legalType = accountCacheModel.legalType;
537    
538                    if ((legalType != null) && (legalType.length() == 0)) {
539                            accountCacheModel.legalType = null;
540                    }
541    
542                    accountCacheModel.sicCode = getSicCode();
543    
544                    String sicCode = accountCacheModel.sicCode;
545    
546                    if ((sicCode != null) && (sicCode.length() == 0)) {
547                            accountCacheModel.sicCode = null;
548                    }
549    
550                    accountCacheModel.tickerSymbol = getTickerSymbol();
551    
552                    String tickerSymbol = accountCacheModel.tickerSymbol;
553    
554                    if ((tickerSymbol != null) && (tickerSymbol.length() == 0)) {
555                            accountCacheModel.tickerSymbol = null;
556                    }
557    
558                    accountCacheModel.industry = getIndustry();
559    
560                    String industry = accountCacheModel.industry;
561    
562                    if ((industry != null) && (industry.length() == 0)) {
563                            accountCacheModel.industry = null;
564                    }
565    
566                    accountCacheModel.type = getType();
567    
568                    String type = accountCacheModel.type;
569    
570                    if ((type != null) && (type.length() == 0)) {
571                            accountCacheModel.type = null;
572                    }
573    
574                    accountCacheModel.size = getSize();
575    
576                    String size = accountCacheModel.size;
577    
578                    if ((size != null) && (size.length() == 0)) {
579                            accountCacheModel.size = null;
580                    }
581    
582                    return accountCacheModel;
583            }
584    
585            @Override
586            public String toString() {
587                    StringBundler sb = new StringBundler(33);
588    
589                    sb.append("{accountId=");
590                    sb.append(getAccountId());
591                    sb.append(", companyId=");
592                    sb.append(getCompanyId());
593                    sb.append(", userId=");
594                    sb.append(getUserId());
595                    sb.append(", userName=");
596                    sb.append(getUserName());
597                    sb.append(", createDate=");
598                    sb.append(getCreateDate());
599                    sb.append(", modifiedDate=");
600                    sb.append(getModifiedDate());
601                    sb.append(", parentAccountId=");
602                    sb.append(getParentAccountId());
603                    sb.append(", name=");
604                    sb.append(getName());
605                    sb.append(", legalName=");
606                    sb.append(getLegalName());
607                    sb.append(", legalId=");
608                    sb.append(getLegalId());
609                    sb.append(", legalType=");
610                    sb.append(getLegalType());
611                    sb.append(", sicCode=");
612                    sb.append(getSicCode());
613                    sb.append(", tickerSymbol=");
614                    sb.append(getTickerSymbol());
615                    sb.append(", industry=");
616                    sb.append(getIndustry());
617                    sb.append(", type=");
618                    sb.append(getType());
619                    sb.append(", size=");
620                    sb.append(getSize());
621                    sb.append("}");
622    
623                    return sb.toString();
624            }
625    
626            public String toXmlString() {
627                    StringBundler sb = new StringBundler(52);
628    
629                    sb.append("<model><model-name>");
630                    sb.append("com.liferay.portal.model.Account");
631                    sb.append("</model-name>");
632    
633                    sb.append(
634                            "<column><column-name>accountId</column-name><column-value><![CDATA[");
635                    sb.append(getAccountId());
636                    sb.append("]]></column-value></column>");
637                    sb.append(
638                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
639                    sb.append(getCompanyId());
640                    sb.append("]]></column-value></column>");
641                    sb.append(
642                            "<column><column-name>userId</column-name><column-value><![CDATA[");
643                    sb.append(getUserId());
644                    sb.append("]]></column-value></column>");
645                    sb.append(
646                            "<column><column-name>userName</column-name><column-value><![CDATA[");
647                    sb.append(getUserName());
648                    sb.append("]]></column-value></column>");
649                    sb.append(
650                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
651                    sb.append(getCreateDate());
652                    sb.append("]]></column-value></column>");
653                    sb.append(
654                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
655                    sb.append(getModifiedDate());
656                    sb.append("]]></column-value></column>");
657                    sb.append(
658                            "<column><column-name>parentAccountId</column-name><column-value><![CDATA[");
659                    sb.append(getParentAccountId());
660                    sb.append("]]></column-value></column>");
661                    sb.append(
662                            "<column><column-name>name</column-name><column-value><![CDATA[");
663                    sb.append(getName());
664                    sb.append("]]></column-value></column>");
665                    sb.append(
666                            "<column><column-name>legalName</column-name><column-value><![CDATA[");
667                    sb.append(getLegalName());
668                    sb.append("]]></column-value></column>");
669                    sb.append(
670                            "<column><column-name>legalId</column-name><column-value><![CDATA[");
671                    sb.append(getLegalId());
672                    sb.append("]]></column-value></column>");
673                    sb.append(
674                            "<column><column-name>legalType</column-name><column-value><![CDATA[");
675                    sb.append(getLegalType());
676                    sb.append("]]></column-value></column>");
677                    sb.append(
678                            "<column><column-name>sicCode</column-name><column-value><![CDATA[");
679                    sb.append(getSicCode());
680                    sb.append("]]></column-value></column>");
681                    sb.append(
682                            "<column><column-name>tickerSymbol</column-name><column-value><![CDATA[");
683                    sb.append(getTickerSymbol());
684                    sb.append("]]></column-value></column>");
685                    sb.append(
686                            "<column><column-name>industry</column-name><column-value><![CDATA[");
687                    sb.append(getIndustry());
688                    sb.append("]]></column-value></column>");
689                    sb.append(
690                            "<column><column-name>type</column-name><column-value><![CDATA[");
691                    sb.append(getType());
692                    sb.append("]]></column-value></column>");
693                    sb.append(
694                            "<column><column-name>size</column-name><column-value><![CDATA[");
695                    sb.append(getSize());
696                    sb.append("]]></column-value></column>");
697    
698                    sb.append("</model>");
699    
700                    return sb.toString();
701            }
702    
703            private static ClassLoader _classLoader = Account.class.getClassLoader();
704            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
705                            Account.class
706                    };
707            private long _accountId;
708            private long _companyId;
709            private long _userId;
710            private String _userUuid;
711            private String _userName;
712            private Date _createDate;
713            private Date _modifiedDate;
714            private long _parentAccountId;
715            private String _name;
716            private String _legalName;
717            private String _legalId;
718            private String _legalType;
719            private String _sicCode;
720            private String _tickerSymbol;
721            private String _industry;
722            private String _type;
723            private String _size;
724            private transient ExpandoBridge _expandoBridge;
725            private Account _escapedModelProxy;
726    }