001    /**
002     * Copyright (c) 2000-2010 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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Company;
022    import com.liferay.portal.model.CompanyModel;
023    import com.liferay.portal.model.CompanySoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.List;
037    
038    /**
039     * 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.
040     *
041     * <p>
042     * 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}.
043     * </p>
044     *
045     * <p>
046     * 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.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see CompanyImpl
051     * @see com.liferay.portal.model.Company
052     * @see com.liferay.portal.model.CompanyModel
053     * @generated
054     */
055    public class CompanyModelImpl extends BaseModelImpl<Company>
056            implements CompanyModel {
057            public static final String TABLE_NAME = "Company";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "companyId", new Integer(Types.BIGINT) },
060                            { "accountId", new Integer(Types.BIGINT) },
061                            { "webId", new Integer(Types.VARCHAR) },
062                            { "key_", new Integer(Types.CLOB) },
063                            { "virtualHost", new Integer(Types.VARCHAR) },
064                            { "mx", new Integer(Types.VARCHAR) },
065                            { "homeURL", new Integer(Types.VARCHAR) },
066                            { "logoId", new Integer(Types.BIGINT) },
067                            { "system", new Integer(Types.BOOLEAN) },
068                            { "maxUsers", new Integer(Types.INTEGER) }
069                    };
070            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,virtualHost VARCHAR(75) null,mx VARCHAR(75) null,homeURL STRING null,logoId LONG,system BOOLEAN,maxUsers INTEGER)";
071            public static final String TABLE_SQL_DROP = "drop table Company";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Company"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Company"),
080                            true);
081    
082            /**
083             * Converts the soap model instance into a normal model instance.
084             *
085             * @param soapModel the soap model instance to convert
086             * @return the normal model instance
087             */
088            public static Company toModel(CompanySoap soapModel) {
089                    Company model = new CompanyImpl();
090    
091                    model.setCompanyId(soapModel.getCompanyId());
092                    model.setAccountId(soapModel.getAccountId());
093                    model.setWebId(soapModel.getWebId());
094                    model.setKey(soapModel.getKey());
095                    model.setVirtualHost(soapModel.getVirtualHost());
096                    model.setMx(soapModel.getMx());
097                    model.setHomeURL(soapModel.getHomeURL());
098                    model.setLogoId(soapModel.getLogoId());
099                    model.setSystem(soapModel.getSystem());
100                    model.setMaxUsers(soapModel.getMaxUsers());
101    
102                    return model;
103            }
104    
105            /**
106             * Converts the soap model instances into normal model instances.
107             *
108             * @param soapModels the soap model instances to convert
109             * @return the normal model instances
110             */
111            public static List<Company> toModels(CompanySoap[] soapModels) {
112                    List<Company> models = new ArrayList<Company>(soapModels.length);
113    
114                    for (CompanySoap soapModel : soapModels) {
115                            models.add(toModel(soapModel));
116                    }
117    
118                    return models;
119            }
120    
121            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
122                                    "lock.expiration.time.com.liferay.portal.model.Company"));
123    
124            public CompanyModelImpl() {
125            }
126    
127            public long getPrimaryKey() {
128                    return _companyId;
129            }
130    
131            public void setPrimaryKey(long pk) {
132                    setCompanyId(pk);
133            }
134    
135            public Serializable getPrimaryKeyObj() {
136                    return new Long(_companyId);
137            }
138    
139            public long getCompanyId() {
140                    return _companyId;
141            }
142    
143            public void setCompanyId(long companyId) {
144                    _companyId = companyId;
145            }
146    
147            public long getAccountId() {
148                    return _accountId;
149            }
150    
151            public void setAccountId(long accountId) {
152                    _accountId = accountId;
153            }
154    
155            public String getWebId() {
156                    if (_webId == null) {
157                            return StringPool.BLANK;
158                    }
159                    else {
160                            return _webId;
161                    }
162            }
163    
164            public void setWebId(String webId) {
165                    _webId = webId;
166    
167                    if (_originalWebId == null) {
168                            _originalWebId = webId;
169                    }
170            }
171    
172            public String getOriginalWebId() {
173                    return GetterUtil.getString(_originalWebId);
174            }
175    
176            public String getKey() {
177                    if (_key == null) {
178                            return StringPool.BLANK;
179                    }
180                    else {
181                            return _key;
182                    }
183            }
184    
185            public void setKey(String key) {
186                    _key = key;
187            }
188    
189            public String getVirtualHost() {
190                    if (_virtualHost == null) {
191                            return StringPool.BLANK;
192                    }
193                    else {
194                            return _virtualHost;
195                    }
196            }
197    
198            public void setVirtualHost(String virtualHost) {
199                    _virtualHost = virtualHost;
200    
201                    if (_originalVirtualHost == null) {
202                            _originalVirtualHost = virtualHost;
203                    }
204            }
205    
206            public String getOriginalVirtualHost() {
207                    return GetterUtil.getString(_originalVirtualHost);
208            }
209    
210            public String getMx() {
211                    if (_mx == null) {
212                            return StringPool.BLANK;
213                    }
214                    else {
215                            return _mx;
216                    }
217            }
218    
219            public void setMx(String mx) {
220                    _mx = mx;
221    
222                    if (_originalMx == null) {
223                            _originalMx = mx;
224                    }
225            }
226    
227            public String getOriginalMx() {
228                    return GetterUtil.getString(_originalMx);
229            }
230    
231            public String getHomeURL() {
232                    if (_homeURL == null) {
233                            return StringPool.BLANK;
234                    }
235                    else {
236                            return _homeURL;
237                    }
238            }
239    
240            public void setHomeURL(String homeURL) {
241                    _homeURL = homeURL;
242            }
243    
244            public long getLogoId() {
245                    return _logoId;
246            }
247    
248            public void setLogoId(long logoId) {
249                    _logoId = logoId;
250    
251                    if (!_setOriginalLogoId) {
252                            _setOriginalLogoId = true;
253    
254                            _originalLogoId = logoId;
255                    }
256            }
257    
258            public long getOriginalLogoId() {
259                    return _originalLogoId;
260            }
261    
262            public boolean getSystem() {
263                    return _system;
264            }
265    
266            public boolean isSystem() {
267                    return _system;
268            }
269    
270            public void setSystem(boolean system) {
271                    _system = system;
272            }
273    
274            public int getMaxUsers() {
275                    return _maxUsers;
276            }
277    
278            public void setMaxUsers(int maxUsers) {
279                    _maxUsers = maxUsers;
280            }
281    
282            public Company toEscapedModel() {
283                    if (isEscapedModel()) {
284                            return (Company)this;
285                    }
286                    else {
287                            return (Company)Proxy.newProxyInstance(Company.class.getClassLoader(),
288                                    new Class[] { Company.class }, new AutoEscapeBeanHandler(this));
289                    }
290            }
291    
292            public ExpandoBridge getExpandoBridge() {
293                    if (_expandoBridge == null) {
294                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
295                                            Company.class.getName(), getPrimaryKey());
296                    }
297    
298                    return _expandoBridge;
299            }
300    
301            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
302                    getExpandoBridge().setAttributes(serviceContext);
303            }
304    
305            public Object clone() {
306                    CompanyImpl clone = new CompanyImpl();
307    
308                    clone.setCompanyId(getCompanyId());
309                    clone.setAccountId(getAccountId());
310                    clone.setWebId(getWebId());
311                    clone.setKey(getKey());
312                    clone.setVirtualHost(getVirtualHost());
313                    clone.setMx(getMx());
314                    clone.setHomeURL(getHomeURL());
315                    clone.setLogoId(getLogoId());
316                    clone.setSystem(getSystem());
317                    clone.setMaxUsers(getMaxUsers());
318    
319                    return clone;
320            }
321    
322            public int compareTo(Company company) {
323                    long pk = company.getPrimaryKey();
324    
325                    if (getPrimaryKey() < pk) {
326                            return -1;
327                    }
328                    else if (getPrimaryKey() > pk) {
329                            return 1;
330                    }
331                    else {
332                            return 0;
333                    }
334            }
335    
336            public boolean equals(Object obj) {
337                    if (obj == null) {
338                            return false;
339                    }
340    
341                    Company company = null;
342    
343                    try {
344                            company = (Company)obj;
345                    }
346                    catch (ClassCastException cce) {
347                            return false;
348                    }
349    
350                    long pk = company.getPrimaryKey();
351    
352                    if (getPrimaryKey() == pk) {
353                            return true;
354                    }
355                    else {
356                            return false;
357                    }
358            }
359    
360            public int hashCode() {
361                    return (int)getPrimaryKey();
362            }
363    
364            public String toString() {
365                    StringBundler sb = new StringBundler(21);
366    
367                    sb.append("{companyId=");
368                    sb.append(getCompanyId());
369                    sb.append(", accountId=");
370                    sb.append(getAccountId());
371                    sb.append(", webId=");
372                    sb.append(getWebId());
373                    sb.append(", key=");
374                    sb.append(getKey());
375                    sb.append(", virtualHost=");
376                    sb.append(getVirtualHost());
377                    sb.append(", mx=");
378                    sb.append(getMx());
379                    sb.append(", homeURL=");
380                    sb.append(getHomeURL());
381                    sb.append(", logoId=");
382                    sb.append(getLogoId());
383                    sb.append(", system=");
384                    sb.append(getSystem());
385                    sb.append(", maxUsers=");
386                    sb.append(getMaxUsers());
387                    sb.append("}");
388    
389                    return sb.toString();
390            }
391    
392            public String toXmlString() {
393                    StringBundler sb = new StringBundler(34);
394    
395                    sb.append("<model><model-name>");
396                    sb.append("com.liferay.portal.model.Company");
397                    sb.append("</model-name>");
398    
399                    sb.append(
400                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
401                    sb.append(getCompanyId());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>accountId</column-name><column-value><![CDATA[");
405                    sb.append(getAccountId());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>webId</column-name><column-value><![CDATA[");
409                    sb.append(getWebId());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>key</column-name><column-value><![CDATA[");
413                    sb.append(getKey());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>virtualHost</column-name><column-value><![CDATA[");
417                    sb.append(getVirtualHost());
418                    sb.append("]]></column-value></column>");
419                    sb.append(
420                            "<column><column-name>mx</column-name><column-value><![CDATA[");
421                    sb.append(getMx());
422                    sb.append("]]></column-value></column>");
423                    sb.append(
424                            "<column><column-name>homeURL</column-name><column-value><![CDATA[");
425                    sb.append(getHomeURL());
426                    sb.append("]]></column-value></column>");
427                    sb.append(
428                            "<column><column-name>logoId</column-name><column-value><![CDATA[");
429                    sb.append(getLogoId());
430                    sb.append("]]></column-value></column>");
431                    sb.append(
432                            "<column><column-name>system</column-name><column-value><![CDATA[");
433                    sb.append(getSystem());
434                    sb.append("]]></column-value></column>");
435                    sb.append(
436                            "<column><column-name>maxUsers</column-name><column-value><![CDATA[");
437                    sb.append(getMaxUsers());
438                    sb.append("]]></column-value></column>");
439    
440                    sb.append("</model>");
441    
442                    return sb.toString();
443            }
444    
445            private long _companyId;
446            private long _accountId;
447            private String _webId;
448            private String _originalWebId;
449            private String _key;
450            private String _virtualHost;
451            private String _originalVirtualHost;
452            private String _mx;
453            private String _originalMx;
454            private String _homeURL;
455            private long _logoId;
456            private long _originalLogoId;
457            private boolean _setOriginalLogoId;
458            private boolean _system;
459            private int _maxUsers;
460            private transient ExpandoBridge _expandoBridge;
461    }