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.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            public long getPrimaryKey() {
151                    return _companyId;
152            }
153    
154            public void setPrimaryKey(long primaryKey) {
155                    setCompanyId(primaryKey);
156            }
157    
158            public Serializable getPrimaryKeyObj() {
159                    return _companyId;
160            }
161    
162            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
163                    setPrimaryKey(((Long)primaryKeyObj).longValue());
164            }
165    
166            public Class<?> getModelClass() {
167                    return Company.class;
168            }
169    
170            public String getModelClassName() {
171                    return Company.class.getName();
172            }
173    
174            @Override
175            public Map<String, Object> getModelAttributes() {
176                    Map<String, Object> attributes = new HashMap<String, Object>();
177    
178                    attributes.put("companyId", getCompanyId());
179                    attributes.put("accountId", getAccountId());
180                    attributes.put("webId", getWebId());
181                    attributes.put("key", getKey());
182                    attributes.put("mx", getMx());
183                    attributes.put("homeURL", getHomeURL());
184                    attributes.put("logoId", getLogoId());
185                    attributes.put("system", getSystem());
186                    attributes.put("maxUsers", getMaxUsers());
187                    attributes.put("active", getActive());
188    
189                    return attributes;
190            }
191    
192            @Override
193            public void setModelAttributes(Map<String, Object> attributes) {
194                    Long companyId = (Long)attributes.get("companyId");
195    
196                    if (companyId != null) {
197                            setCompanyId(companyId);
198                    }
199    
200                    Long accountId = (Long)attributes.get("accountId");
201    
202                    if (accountId != null) {
203                            setAccountId(accountId);
204                    }
205    
206                    String webId = (String)attributes.get("webId");
207    
208                    if (webId != null) {
209                            setWebId(webId);
210                    }
211    
212                    String key = (String)attributes.get("key");
213    
214                    if (key != null) {
215                            setKey(key);
216                    }
217    
218                    String mx = (String)attributes.get("mx");
219    
220                    if (mx != null) {
221                            setMx(mx);
222                    }
223    
224                    String homeURL = (String)attributes.get("homeURL");
225    
226                    if (homeURL != null) {
227                            setHomeURL(homeURL);
228                    }
229    
230                    Long logoId = (Long)attributes.get("logoId");
231    
232                    if (logoId != null) {
233                            setLogoId(logoId);
234                    }
235    
236                    Boolean system = (Boolean)attributes.get("system");
237    
238                    if (system != null) {
239                            setSystem(system);
240                    }
241    
242                    Integer maxUsers = (Integer)attributes.get("maxUsers");
243    
244                    if (maxUsers != null) {
245                            setMaxUsers(maxUsers);
246                    }
247    
248                    Boolean active = (Boolean)attributes.get("active");
249    
250                    if (active != null) {
251                            setActive(active);
252                    }
253            }
254    
255            @JSON
256            public long getCompanyId() {
257                    return _companyId;
258            }
259    
260            public void setCompanyId(long companyId) {
261                    _companyId = companyId;
262            }
263    
264            @JSON
265            public long getAccountId() {
266                    return _accountId;
267            }
268    
269            public void setAccountId(long accountId) {
270                    _accountId = accountId;
271            }
272    
273            @JSON
274            public String getWebId() {
275                    if (_webId == null) {
276                            return StringPool.BLANK;
277                    }
278                    else {
279                            return _webId;
280                    }
281            }
282    
283            public void setWebId(String webId) {
284                    _columnBitmask |= WEBID_COLUMN_BITMASK;
285    
286                    if (_originalWebId == null) {
287                            _originalWebId = _webId;
288                    }
289    
290                    _webId = webId;
291            }
292    
293            public String getOriginalWebId() {
294                    return GetterUtil.getString(_originalWebId);
295            }
296    
297            @JSON
298            public String getKey() {
299                    if (_key == null) {
300                            return StringPool.BLANK;
301                    }
302                    else {
303                            return _key;
304                    }
305            }
306    
307            public void setKey(String key) {
308                    _key = key;
309            }
310    
311            @JSON
312            public String getMx() {
313                    if (_mx == null) {
314                            return StringPool.BLANK;
315                    }
316                    else {
317                            return _mx;
318                    }
319            }
320    
321            public void setMx(String mx) {
322                    _columnBitmask |= MX_COLUMN_BITMASK;
323    
324                    if (_originalMx == null) {
325                            _originalMx = _mx;
326                    }
327    
328                    _mx = mx;
329            }
330    
331            public String getOriginalMx() {
332                    return GetterUtil.getString(_originalMx);
333            }
334    
335            @JSON
336            public String getHomeURL() {
337                    if (_homeURL == null) {
338                            return StringPool.BLANK;
339                    }
340                    else {
341                            return _homeURL;
342                    }
343            }
344    
345            public void setHomeURL(String homeURL) {
346                    _homeURL = homeURL;
347            }
348    
349            @JSON
350            public long getLogoId() {
351                    return _logoId;
352            }
353    
354            public void setLogoId(long logoId) {
355                    _columnBitmask |= LOGOID_COLUMN_BITMASK;
356    
357                    if (!_setOriginalLogoId) {
358                            _setOriginalLogoId = true;
359    
360                            _originalLogoId = _logoId;
361                    }
362    
363                    _logoId = logoId;
364            }
365    
366            public long getOriginalLogoId() {
367                    return _originalLogoId;
368            }
369    
370            @JSON
371            public boolean getSystem() {
372                    return _system;
373            }
374    
375            public boolean isSystem() {
376                    return _system;
377            }
378    
379            public void setSystem(boolean system) {
380                    _columnBitmask |= SYSTEM_COLUMN_BITMASK;
381    
382                    if (!_setOriginalSystem) {
383                            _setOriginalSystem = true;
384    
385                            _originalSystem = _system;
386                    }
387    
388                    _system = system;
389            }
390    
391            public boolean getOriginalSystem() {
392                    return _originalSystem;
393            }
394    
395            @JSON
396            public int getMaxUsers() {
397                    return _maxUsers;
398            }
399    
400            public void setMaxUsers(int maxUsers) {
401                    _maxUsers = maxUsers;
402            }
403    
404            @JSON
405            public boolean getActive() {
406                    return _active;
407            }
408    
409            public boolean isActive() {
410                    return _active;
411            }
412    
413            public void setActive(boolean active) {
414                    _active = active;
415            }
416    
417            public java.security.Key getKeyObj() {
418                    return null;
419            }
420    
421            public void setKeyObj(java.security.Key keyObj) {
422            }
423    
424            public java.lang.String getVirtualHostname() {
425                    return null;
426            }
427    
428            public void setVirtualHostname(java.lang.String virtualHostname) {
429            }
430    
431            public long getColumnBitmask() {
432                    return _columnBitmask;
433            }
434    
435            @Override
436            public ExpandoBridge getExpandoBridge() {
437                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
438                            Company.class.getName(), getPrimaryKey());
439            }
440    
441            @Override
442            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
443                    ExpandoBridge expandoBridge = getExpandoBridge();
444    
445                    expandoBridge.setAttributes(serviceContext);
446            }
447    
448            @Override
449            public Company toEscapedModel() {
450                    if (_escapedModel == null) {
451                            _escapedModel = (Company)ProxyUtil.newProxyInstance(_classLoader,
452                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
453                    }
454    
455                    return _escapedModel;
456            }
457    
458            @Override
459            public Object clone() {
460                    CompanyImpl companyImpl = new CompanyImpl();
461    
462                    companyImpl.setCompanyId(getCompanyId());
463                    companyImpl.setAccountId(getAccountId());
464                    companyImpl.setWebId(getWebId());
465                    companyImpl.setKey(getKey());
466                    companyImpl.setMx(getMx());
467                    companyImpl.setHomeURL(getHomeURL());
468                    companyImpl.setLogoId(getLogoId());
469                    companyImpl.setSystem(getSystem());
470                    companyImpl.setMaxUsers(getMaxUsers());
471                    companyImpl.setActive(getActive());
472    
473                    companyImpl.resetOriginalValues();
474    
475                    return companyImpl;
476            }
477    
478            public int compareTo(Company company) {
479                    long primaryKey = company.getPrimaryKey();
480    
481                    if (getPrimaryKey() < primaryKey) {
482                            return -1;
483                    }
484                    else if (getPrimaryKey() > primaryKey) {
485                            return 1;
486                    }
487                    else {
488                            return 0;
489                    }
490            }
491    
492            @Override
493            public boolean equals(Object obj) {
494                    if (obj == null) {
495                            return false;
496                    }
497    
498                    Company company = null;
499    
500                    try {
501                            company = (Company)obj;
502                    }
503                    catch (ClassCastException cce) {
504                            return false;
505                    }
506    
507                    long primaryKey = company.getPrimaryKey();
508    
509                    if (getPrimaryKey() == primaryKey) {
510                            return true;
511                    }
512                    else {
513                            return false;
514                    }
515            }
516    
517            @Override
518            public int hashCode() {
519                    return (int)getPrimaryKey();
520            }
521    
522            @Override
523            public void resetOriginalValues() {
524                    CompanyModelImpl companyModelImpl = this;
525    
526                    companyModelImpl._originalWebId = companyModelImpl._webId;
527    
528                    companyModelImpl._originalMx = companyModelImpl._mx;
529    
530                    companyModelImpl._originalLogoId = companyModelImpl._logoId;
531    
532                    companyModelImpl._setOriginalLogoId = false;
533    
534                    companyModelImpl._originalSystem = companyModelImpl._system;
535    
536                    companyModelImpl._setOriginalSystem = false;
537    
538                    companyModelImpl._columnBitmask = 0;
539            }
540    
541            @Override
542            public CacheModel<Company> toCacheModel() {
543                    CompanyCacheModel companyCacheModel = new CompanyCacheModel();
544    
545                    companyCacheModel.companyId = getCompanyId();
546    
547                    companyCacheModel.accountId = getAccountId();
548    
549                    companyCacheModel.webId = getWebId();
550    
551                    String webId = companyCacheModel.webId;
552    
553                    if ((webId != null) && (webId.length() == 0)) {
554                            companyCacheModel.webId = null;
555                    }
556    
557                    companyCacheModel.key = getKey();
558    
559                    String key = companyCacheModel.key;
560    
561                    if ((key != null) && (key.length() == 0)) {
562                            companyCacheModel.key = null;
563                    }
564    
565                    companyCacheModel.mx = getMx();
566    
567                    String mx = companyCacheModel.mx;
568    
569                    if ((mx != null) && (mx.length() == 0)) {
570                            companyCacheModel.mx = null;
571                    }
572    
573                    companyCacheModel.homeURL = getHomeURL();
574    
575                    String homeURL = companyCacheModel.homeURL;
576    
577                    if ((homeURL != null) && (homeURL.length() == 0)) {
578                            companyCacheModel.homeURL = null;
579                    }
580    
581                    companyCacheModel.logoId = getLogoId();
582    
583                    companyCacheModel.system = getSystem();
584    
585                    companyCacheModel.maxUsers = getMaxUsers();
586    
587                    companyCacheModel.active = getActive();
588    
589                    companyCacheModel._keyObj = getKeyObj();
590    
591                    companyCacheModel._virtualHostname = getVirtualHostname();
592    
593                    return companyCacheModel;
594            }
595    
596            @Override
597            public String toString() {
598                    StringBundler sb = new StringBundler(21);
599    
600                    sb.append("{companyId=");
601                    sb.append(getCompanyId());
602                    sb.append(", accountId=");
603                    sb.append(getAccountId());
604                    sb.append(", webId=");
605                    sb.append(getWebId());
606                    sb.append(", key=");
607                    sb.append(getKey());
608                    sb.append(", mx=");
609                    sb.append(getMx());
610                    sb.append(", homeURL=");
611                    sb.append(getHomeURL());
612                    sb.append(", logoId=");
613                    sb.append(getLogoId());
614                    sb.append(", system=");
615                    sb.append(getSystem());
616                    sb.append(", maxUsers=");
617                    sb.append(getMaxUsers());
618                    sb.append(", active=");
619                    sb.append(getActive());
620                    sb.append("}");
621    
622                    return sb.toString();
623            }
624    
625            public String toXmlString() {
626                    StringBundler sb = new StringBundler(34);
627    
628                    sb.append("<model><model-name>");
629                    sb.append("com.liferay.portal.model.Company");
630                    sb.append("</model-name>");
631    
632                    sb.append(
633                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
634                    sb.append(getCompanyId());
635                    sb.append("]]></column-value></column>");
636                    sb.append(
637                            "<column><column-name>accountId</column-name><column-value><![CDATA[");
638                    sb.append(getAccountId());
639                    sb.append("]]></column-value></column>");
640                    sb.append(
641                            "<column><column-name>webId</column-name><column-value><![CDATA[");
642                    sb.append(getWebId());
643                    sb.append("]]></column-value></column>");
644                    sb.append(
645                            "<column><column-name>key</column-name><column-value><![CDATA[");
646                    sb.append(getKey());
647                    sb.append("]]></column-value></column>");
648                    sb.append(
649                            "<column><column-name>mx</column-name><column-value><![CDATA[");
650                    sb.append(getMx());
651                    sb.append("]]></column-value></column>");
652                    sb.append(
653                            "<column><column-name>homeURL</column-name><column-value><![CDATA[");
654                    sb.append(getHomeURL());
655                    sb.append("]]></column-value></column>");
656                    sb.append(
657                            "<column><column-name>logoId</column-name><column-value><![CDATA[");
658                    sb.append(getLogoId());
659                    sb.append("]]></column-value></column>");
660                    sb.append(
661                            "<column><column-name>system</column-name><column-value><![CDATA[");
662                    sb.append(getSystem());
663                    sb.append("]]></column-value></column>");
664                    sb.append(
665                            "<column><column-name>maxUsers</column-name><column-value><![CDATA[");
666                    sb.append(getMaxUsers());
667                    sb.append("]]></column-value></column>");
668                    sb.append(
669                            "<column><column-name>active</column-name><column-value><![CDATA[");
670                    sb.append(getActive());
671                    sb.append("]]></column-value></column>");
672    
673                    sb.append("</model>");
674    
675                    return sb.toString();
676            }
677    
678            private static ClassLoader _classLoader = Company.class.getClassLoader();
679            private static Class<?>[] _escapedModelInterfaces = new Class[] {
680                            Company.class
681                    };
682            private long _companyId;
683            private long _accountId;
684            private String _webId;
685            private String _originalWebId;
686            private String _key;
687            private String _mx;
688            private String _originalMx;
689            private String _homeURL;
690            private long _logoId;
691            private long _originalLogoId;
692            private boolean _setOriginalLogoId;
693            private boolean _system;
694            private boolean _originalSystem;
695            private boolean _setOriginalSystem;
696            private int _maxUsers;
697            private boolean _active;
698            private long _columnBitmask;
699            private Company _escapedModel;
700    }