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