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