001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.json.JSON;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.Company;
027    import com.liferay.portal.model.CompanyModel;
028    import com.liferay.portal.model.CompanySoap;
029    import com.liferay.portal.service.ServiceContext;
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.HashMap;
040    import java.util.List;
041    import java.util.Map;
042    
043    /**
044     * The base model implementation for the Company service. Represents a row in the "Company" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link CompanyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CompanyImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see CompanyImpl
052     * @see Company
053     * @see CompanyModel
054     * @generated
055     */
056    @JSON(strict = true)
057    @ProviderType
058    public class CompanyModelImpl extends BaseModelImpl<Company>
059            implements CompanyModel {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. All methods that expect a company model instance should use the {@link Company} interface instead.
064             */
065            public static final String TABLE_NAME = "Company";
066            public static final Object[][] TABLE_COLUMNS = {
067                            { "mvccVersion", Types.BIGINT },
068                            { "companyId", Types.BIGINT },
069                            { "accountId", Types.BIGINT },
070                            { "webId", Types.VARCHAR },
071                            { "key_", Types.CLOB },
072                            { "mx", Types.VARCHAR },
073                            { "homeURL", Types.VARCHAR },
074                            { "logoId", Types.BIGINT },
075                            { "system", Types.BOOLEAN },
076                            { "maxUsers", Types.INTEGER },
077                            { "active_", Types.BOOLEAN }
078                    };
079            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
080    
081            static {
082                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
083                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
084                    TABLE_COLUMNS_MAP.put("accountId", Types.BIGINT);
085                    TABLE_COLUMNS_MAP.put("webId", Types.VARCHAR);
086                    TABLE_COLUMNS_MAP.put("key_", Types.CLOB);
087                    TABLE_COLUMNS_MAP.put("mx", Types.VARCHAR);
088                    TABLE_COLUMNS_MAP.put("homeURL", Types.VARCHAR);
089                    TABLE_COLUMNS_MAP.put("logoId", Types.BIGINT);
090                    TABLE_COLUMNS_MAP.put("system", Types.BOOLEAN);
091                    TABLE_COLUMNS_MAP.put("maxUsers", Types.INTEGER);
092                    TABLE_COLUMNS_MAP.put("active_", Types.BOOLEAN);
093            }
094    
095            public static final String TABLE_SQL_CREATE = "create table Company (mvccVersion LONG default 0,companyId LONG not null primary key,accountId LONG,webId VARCHAR(75) null,key_ TEXT null,mx VARCHAR(75) null,homeURL STRING null,logoId LONG,system BOOLEAN,maxUsers INTEGER,active_ BOOLEAN)";
096            public static final String TABLE_SQL_DROP = "drop table Company";
097            public static final String ORDER_BY_JPQL = " ORDER BY company.companyId ASC";
098            public static final String ORDER_BY_SQL = " ORDER BY Company.companyId ASC";
099            public static final String DATA_SOURCE = "liferayDataSource";
100            public static final String SESSION_FACTORY = "liferaySessionFactory";
101            public static final String TX_MANAGER = "liferayTransactionManager";
102            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Company"),
104                            true);
105            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Company"),
107                            true);
108            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
109                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.Company"),
110                            true);
111            public static final long LOGOID_COLUMN_BITMASK = 1L;
112            public static final long MX_COLUMN_BITMASK = 2L;
113            public static final long SYSTEM_COLUMN_BITMASK = 4L;
114            public static final long WEBID_COLUMN_BITMASK = 8L;
115            public static final long COMPANYID_COLUMN_BITMASK = 16L;
116    
117            /**
118             * Converts the soap model instance into a normal model instance.
119             *
120             * @param soapModel the soap model instance to convert
121             * @return the normal model instance
122             */
123            public static Company toModel(CompanySoap soapModel) {
124                    if (soapModel == null) {
125                            return null;
126                    }
127    
128                    Company model = new CompanyImpl();
129    
130                    model.setMvccVersion(soapModel.getMvccVersion());
131                    model.setCompanyId(soapModel.getCompanyId());
132                    model.setAccountId(soapModel.getAccountId());
133                    model.setWebId(soapModel.getWebId());
134                    model.setKey(soapModel.getKey());
135                    model.setMx(soapModel.getMx());
136                    model.setHomeURL(soapModel.getHomeURL());
137                    model.setLogoId(soapModel.getLogoId());
138                    model.setSystem(soapModel.getSystem());
139                    model.setMaxUsers(soapModel.getMaxUsers());
140                    model.setActive(soapModel.getActive());
141    
142                    return model;
143            }
144    
145            /**
146             * Converts the soap model instances into normal model instances.
147             *
148             * @param soapModels the soap model instances to convert
149             * @return the normal model instances
150             */
151            public static List<Company> toModels(CompanySoap[] soapModels) {
152                    if (soapModels == null) {
153                            return null;
154                    }
155    
156                    List<Company> models = new ArrayList<Company>(soapModels.length);
157    
158                    for (CompanySoap soapModel : soapModels) {
159                            models.add(toModel(soapModel));
160                    }
161    
162                    return models;
163            }
164    
165            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
166                                    "lock.expiration.time.com.liferay.portal.model.Company"));
167    
168            public CompanyModelImpl() {
169            }
170    
171            @Override
172            public long getPrimaryKey() {
173                    return _companyId;
174            }
175    
176            @Override
177            public void setPrimaryKey(long primaryKey) {
178                    setCompanyId(primaryKey);
179            }
180    
181            @Override
182            public Serializable getPrimaryKeyObj() {
183                    return _companyId;
184            }
185    
186            @Override
187            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
188                    setPrimaryKey(((Long)primaryKeyObj).longValue());
189            }
190    
191            @Override
192            public Class<?> getModelClass() {
193                    return Company.class;
194            }
195    
196            @Override
197            public String getModelClassName() {
198                    return Company.class.getName();
199            }
200    
201            @Override
202            public Map<String, Object> getModelAttributes() {
203                    Map<String, Object> attributes = new HashMap<String, Object>();
204    
205                    attributes.put("mvccVersion", getMvccVersion());
206                    attributes.put("companyId", getCompanyId());
207                    attributes.put("accountId", getAccountId());
208                    attributes.put("webId", getWebId());
209                    attributes.put("key", getKey());
210                    attributes.put("mx", getMx());
211                    attributes.put("homeURL", getHomeURL());
212                    attributes.put("logoId", getLogoId());
213                    attributes.put("system", getSystem());
214                    attributes.put("maxUsers", getMaxUsers());
215                    attributes.put("active", getActive());
216    
217                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
218                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
219    
220                    return attributes;
221            }
222    
223            @Override
224            public void setModelAttributes(Map<String, Object> attributes) {
225                    Long mvccVersion = (Long)attributes.get("mvccVersion");
226    
227                    if (mvccVersion != null) {
228                            setMvccVersion(mvccVersion);
229                    }
230    
231                    Long companyId = (Long)attributes.get("companyId");
232    
233                    if (companyId != null) {
234                            setCompanyId(companyId);
235                    }
236    
237                    Long accountId = (Long)attributes.get("accountId");
238    
239                    if (accountId != null) {
240                            setAccountId(accountId);
241                    }
242    
243                    String webId = (String)attributes.get("webId");
244    
245                    if (webId != null) {
246                            setWebId(webId);
247                    }
248    
249                    String key = (String)attributes.get("key");
250    
251                    if (key != null) {
252                            setKey(key);
253                    }
254    
255                    String mx = (String)attributes.get("mx");
256    
257                    if (mx != null) {
258                            setMx(mx);
259                    }
260    
261                    String homeURL = (String)attributes.get("homeURL");
262    
263                    if (homeURL != null) {
264                            setHomeURL(homeURL);
265                    }
266    
267                    Long logoId = (Long)attributes.get("logoId");
268    
269                    if (logoId != null) {
270                            setLogoId(logoId);
271                    }
272    
273                    Boolean system = (Boolean)attributes.get("system");
274    
275                    if (system != null) {
276                            setSystem(system);
277                    }
278    
279                    Integer maxUsers = (Integer)attributes.get("maxUsers");
280    
281                    if (maxUsers != null) {
282                            setMaxUsers(maxUsers);
283                    }
284    
285                    Boolean active = (Boolean)attributes.get("active");
286    
287                    if (active != null) {
288                            setActive(active);
289                    }
290            }
291    
292            @JSON
293            @Override
294            public long getMvccVersion() {
295                    return _mvccVersion;
296            }
297    
298            @Override
299            public void setMvccVersion(long mvccVersion) {
300                    _mvccVersion = mvccVersion;
301            }
302    
303            @JSON
304            @Override
305            public long getCompanyId() {
306                    return _companyId;
307            }
308    
309            @Override
310            public void setCompanyId(long companyId) {
311                    _companyId = companyId;
312            }
313    
314            @JSON
315            @Override
316            public long getAccountId() {
317                    return _accountId;
318            }
319    
320            @Override
321            public void setAccountId(long accountId) {
322                    _accountId = accountId;
323            }
324    
325            @JSON
326            @Override
327            public String getWebId() {
328                    if (_webId == null) {
329                            return StringPool.BLANK;
330                    }
331                    else {
332                            return _webId;
333                    }
334            }
335    
336            @Override
337            public void setWebId(String webId) {
338                    _columnBitmask |= WEBID_COLUMN_BITMASK;
339    
340                    if (_originalWebId == null) {
341                            _originalWebId = _webId;
342                    }
343    
344                    _webId = webId;
345            }
346    
347            public String getOriginalWebId() {
348                    return GetterUtil.getString(_originalWebId);
349            }
350    
351            @JSON
352            @Override
353            public String getKey() {
354                    if (_key == null) {
355                            return StringPool.BLANK;
356                    }
357                    else {
358                            return _key;
359                    }
360            }
361    
362            @Override
363            public void setKey(String key) {
364                    _key = key;
365            }
366    
367            @JSON
368            @Override
369            public String getMx() {
370                    if (_mx == null) {
371                            return StringPool.BLANK;
372                    }
373                    else {
374                            return _mx;
375                    }
376            }
377    
378            @Override
379            public void setMx(String mx) {
380                    _columnBitmask |= MX_COLUMN_BITMASK;
381    
382                    if (_originalMx == null) {
383                            _originalMx = _mx;
384                    }
385    
386                    _mx = mx;
387            }
388    
389            public String getOriginalMx() {
390                    return GetterUtil.getString(_originalMx);
391            }
392    
393            @JSON
394            @Override
395            public String getHomeURL() {
396                    if (_homeURL == null) {
397                            return StringPool.BLANK;
398                    }
399                    else {
400                            return _homeURL;
401                    }
402            }
403    
404            @Override
405            public void setHomeURL(String homeURL) {
406                    _homeURL = homeURL;
407            }
408    
409            @JSON
410            @Override
411            public long getLogoId() {
412                    return _logoId;
413            }
414    
415            @Override
416            public void setLogoId(long logoId) {
417                    _columnBitmask |= LOGOID_COLUMN_BITMASK;
418    
419                    if (!_setOriginalLogoId) {
420                            _setOriginalLogoId = true;
421    
422                            _originalLogoId = _logoId;
423                    }
424    
425                    _logoId = logoId;
426            }
427    
428            public long getOriginalLogoId() {
429                    return _originalLogoId;
430            }
431    
432            @JSON
433            @Override
434            public boolean getSystem() {
435                    return _system;
436            }
437    
438            @Override
439            public boolean isSystem() {
440                    return _system;
441            }
442    
443            @Override
444            public void setSystem(boolean system) {
445                    _columnBitmask |= SYSTEM_COLUMN_BITMASK;
446    
447                    if (!_setOriginalSystem) {
448                            _setOriginalSystem = true;
449    
450                            _originalSystem = _system;
451                    }
452    
453                    _system = system;
454            }
455    
456            public boolean getOriginalSystem() {
457                    return _originalSystem;
458            }
459    
460            @JSON
461            @Override
462            public int getMaxUsers() {
463                    return _maxUsers;
464            }
465    
466            @Override
467            public void setMaxUsers(int maxUsers) {
468                    _maxUsers = maxUsers;
469            }
470    
471            @JSON
472            @Override
473            public boolean getActive() {
474                    return _active;
475            }
476    
477            @Override
478            public boolean isActive() {
479                    return _active;
480            }
481    
482            @Override
483            public void setActive(boolean active) {
484                    _active = active;
485            }
486    
487            public java.security.Key getKeyObj() {
488                    return null;
489            }
490    
491            public void setKeyObj(java.security.Key keyObj) {
492            }
493    
494            public java.lang.String getVirtualHostname() {
495                    return null;
496            }
497    
498            public void setVirtualHostname(java.lang.String virtualHostname) {
499            }
500    
501            public long getColumnBitmask() {
502                    return _columnBitmask;
503            }
504    
505            @Override
506            public ExpandoBridge getExpandoBridge() {
507                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
508                            Company.class.getName(), getPrimaryKey());
509            }
510    
511            @Override
512            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
513                    ExpandoBridge expandoBridge = getExpandoBridge();
514    
515                    expandoBridge.setAttributes(serviceContext);
516            }
517    
518            @Override
519            public Company toEscapedModel() {
520                    if (_escapedModel == null) {
521                            _escapedModel = (Company)ProxyUtil.newProxyInstance(_classLoader,
522                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
523                    }
524    
525                    return _escapedModel;
526            }
527    
528            @Override
529            public Object clone() {
530                    CompanyImpl companyImpl = new CompanyImpl();
531    
532                    companyImpl.setMvccVersion(getMvccVersion());
533                    companyImpl.setCompanyId(getCompanyId());
534                    companyImpl.setAccountId(getAccountId());
535                    companyImpl.setWebId(getWebId());
536                    companyImpl.setKey(getKey());
537                    companyImpl.setMx(getMx());
538                    companyImpl.setHomeURL(getHomeURL());
539                    companyImpl.setLogoId(getLogoId());
540                    companyImpl.setSystem(getSystem());
541                    companyImpl.setMaxUsers(getMaxUsers());
542                    companyImpl.setActive(getActive());
543    
544                    companyImpl.resetOriginalValues();
545    
546                    return companyImpl;
547            }
548    
549            @Override
550            public int compareTo(Company company) {
551                    long primaryKey = company.getPrimaryKey();
552    
553                    if (getPrimaryKey() < primaryKey) {
554                            return -1;
555                    }
556                    else if (getPrimaryKey() > primaryKey) {
557                            return 1;
558                    }
559                    else {
560                            return 0;
561                    }
562            }
563    
564            @Override
565            public boolean equals(Object obj) {
566                    if (this == obj) {
567                            return true;
568                    }
569    
570                    if (!(obj instanceof Company)) {
571                            return false;
572                    }
573    
574                    Company company = (Company)obj;
575    
576                    long primaryKey = company.getPrimaryKey();
577    
578                    if (getPrimaryKey() == primaryKey) {
579                            return true;
580                    }
581                    else {
582                            return false;
583                    }
584            }
585    
586            @Override
587            public int hashCode() {
588                    return (int)getPrimaryKey();
589            }
590    
591            @Override
592            public boolean isEntityCacheEnabled() {
593                    return ENTITY_CACHE_ENABLED;
594            }
595    
596            @Override
597            public boolean isFinderCacheEnabled() {
598                    return FINDER_CACHE_ENABLED;
599            }
600    
601            @Override
602            public void resetOriginalValues() {
603                    CompanyModelImpl companyModelImpl = this;
604    
605                    companyModelImpl._originalWebId = companyModelImpl._webId;
606    
607                    companyModelImpl._originalMx = companyModelImpl._mx;
608    
609                    companyModelImpl._originalLogoId = companyModelImpl._logoId;
610    
611                    companyModelImpl._setOriginalLogoId = false;
612    
613                    companyModelImpl._originalSystem = companyModelImpl._system;
614    
615                    companyModelImpl._setOriginalSystem = false;
616    
617                    setKeyObj(null);
618    
619                    setVirtualHostname(null);
620    
621                    companyModelImpl._columnBitmask = 0;
622            }
623    
624            @Override
625            public CacheModel<Company> toCacheModel() {
626                    CompanyCacheModel companyCacheModel = new CompanyCacheModel();
627    
628                    companyCacheModel.mvccVersion = getMvccVersion();
629    
630                    companyCacheModel.companyId = getCompanyId();
631    
632                    companyCacheModel.accountId = getAccountId();
633    
634                    companyCacheModel.webId = getWebId();
635    
636                    String webId = companyCacheModel.webId;
637    
638                    if ((webId != null) && (webId.length() == 0)) {
639                            companyCacheModel.webId = null;
640                    }
641    
642                    companyCacheModel.key = getKey();
643    
644                    String key = companyCacheModel.key;
645    
646                    if ((key != null) && (key.length() == 0)) {
647                            companyCacheModel.key = null;
648                    }
649    
650                    companyCacheModel.mx = getMx();
651    
652                    String mx = companyCacheModel.mx;
653    
654                    if ((mx != null) && (mx.length() == 0)) {
655                            companyCacheModel.mx = null;
656                    }
657    
658                    companyCacheModel.homeURL = getHomeURL();
659    
660                    String homeURL = companyCacheModel.homeURL;
661    
662                    if ((homeURL != null) && (homeURL.length() == 0)) {
663                            companyCacheModel.homeURL = null;
664                    }
665    
666                    companyCacheModel.logoId = getLogoId();
667    
668                    companyCacheModel.system = getSystem();
669    
670                    companyCacheModel.maxUsers = getMaxUsers();
671    
672                    companyCacheModel.active = getActive();
673    
674                    companyCacheModel._keyObj = getKeyObj();
675    
676                    companyCacheModel._virtualHostname = getVirtualHostname();
677    
678                    return companyCacheModel;
679            }
680    
681            @Override
682            public String toString() {
683                    StringBundler sb = new StringBundler(23);
684    
685                    sb.append("{mvccVersion=");
686                    sb.append(getMvccVersion());
687                    sb.append(", companyId=");
688                    sb.append(getCompanyId());
689                    sb.append(", accountId=");
690                    sb.append(getAccountId());
691                    sb.append(", webId=");
692                    sb.append(getWebId());
693                    sb.append(", key=");
694                    sb.append(getKey());
695                    sb.append(", mx=");
696                    sb.append(getMx());
697                    sb.append(", homeURL=");
698                    sb.append(getHomeURL());
699                    sb.append(", logoId=");
700                    sb.append(getLogoId());
701                    sb.append(", system=");
702                    sb.append(getSystem());
703                    sb.append(", maxUsers=");
704                    sb.append(getMaxUsers());
705                    sb.append(", active=");
706                    sb.append(getActive());
707                    sb.append("}");
708    
709                    return sb.toString();
710            }
711    
712            @Override
713            public String toXmlString() {
714                    StringBundler sb = new StringBundler(37);
715    
716                    sb.append("<model><model-name>");
717                    sb.append("com.liferay.portal.model.Company");
718                    sb.append("</model-name>");
719    
720                    sb.append(
721                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
722                    sb.append(getMvccVersion());
723                    sb.append("]]></column-value></column>");
724                    sb.append(
725                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
726                    sb.append(getCompanyId());
727                    sb.append("]]></column-value></column>");
728                    sb.append(
729                            "<column><column-name>accountId</column-name><column-value><![CDATA[");
730                    sb.append(getAccountId());
731                    sb.append("]]></column-value></column>");
732                    sb.append(
733                            "<column><column-name>webId</column-name><column-value><![CDATA[");
734                    sb.append(getWebId());
735                    sb.append("]]></column-value></column>");
736                    sb.append(
737                            "<column><column-name>key</column-name><column-value><![CDATA[");
738                    sb.append(getKey());
739                    sb.append("]]></column-value></column>");
740                    sb.append(
741                            "<column><column-name>mx</column-name><column-value><![CDATA[");
742                    sb.append(getMx());
743                    sb.append("]]></column-value></column>");
744                    sb.append(
745                            "<column><column-name>homeURL</column-name><column-value><![CDATA[");
746                    sb.append(getHomeURL());
747                    sb.append("]]></column-value></column>");
748                    sb.append(
749                            "<column><column-name>logoId</column-name><column-value><![CDATA[");
750                    sb.append(getLogoId());
751                    sb.append("]]></column-value></column>");
752                    sb.append(
753                            "<column><column-name>system</column-name><column-value><![CDATA[");
754                    sb.append(getSystem());
755                    sb.append("]]></column-value></column>");
756                    sb.append(
757                            "<column><column-name>maxUsers</column-name><column-value><![CDATA[");
758                    sb.append(getMaxUsers());
759                    sb.append("]]></column-value></column>");
760                    sb.append(
761                            "<column><column-name>active</column-name><column-value><![CDATA[");
762                    sb.append(getActive());
763                    sb.append("]]></column-value></column>");
764    
765                    sb.append("</model>");
766    
767                    return sb.toString();
768            }
769    
770            private static final ClassLoader _classLoader = Company.class.getClassLoader();
771            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
772                            Company.class
773                    };
774            private long _mvccVersion;
775            private long _companyId;
776            private long _accountId;
777            private String _webId;
778            private String _originalWebId;
779            private String _key;
780            private String _mx;
781            private String _originalMx;
782            private String _homeURL;
783            private long _logoId;
784            private long _originalLogoId;
785            private boolean _setOriginalLogoId;
786            private boolean _system;
787            private boolean _originalSystem;
788            private boolean _setOriginalSystem;
789            private int _maxUsers;
790            private boolean _active;
791            private long _columnBitmask;
792            private Company _escapedModel;
793    }