1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Company;
29  import com.liferay.portal.model.CompanySoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="CompanyModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>Company</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.Company
57   * @see com.liferay.portal.service.model.CompanyModel
58   * @see com.liferay.portal.service.model.impl.CompanyImpl
59   *
60   */
61  public class CompanyModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Company";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "accountId", new Integer(Types.BIGINT) },
68              
69  
70              { "webId", new Integer(Types.VARCHAR) },
71              
72  
73              { "key_", new Integer(Types.CLOB) },
74              
75  
76              { "virtualHost", new Integer(Types.VARCHAR) },
77              
78  
79              { "mx", new Integer(Types.VARCHAR) },
80              
81  
82              { "logoId", new Integer(Types.BIGINT) }
83          };
84      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,logoId LONG)";
85      public static final String TABLE_SQL_DROP = "drop table Company";
86      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portal.model.Company"),
88              true);
89  
90      public static Company toModel(CompanySoap soapModel) {
91          Company model = new CompanyImpl();
92  
93          model.setCompanyId(soapModel.getCompanyId());
94          model.setAccountId(soapModel.getAccountId());
95          model.setWebId(soapModel.getWebId());
96          model.setKey(soapModel.getKey());
97          model.setVirtualHost(soapModel.getVirtualHost());
98          model.setMx(soapModel.getMx());
99          model.setLogoId(soapModel.getLogoId());
100 
101         return model;
102     }
103 
104     public static List<Company> toModels(CompanySoap[] soapModels) {
105         List<Company> models = new ArrayList<Company>(soapModels.length);
106 
107         for (CompanySoap soapModel : soapModels) {
108             models.add(toModel(soapModel));
109         }
110 
111         return models;
112     }
113 
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portal.model.Company"));
116 
117     public CompanyModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _companyId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setCompanyId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_companyId);
130     }
131 
132     public long getCompanyId() {
133         return _companyId;
134     }
135 
136     public void setCompanyId(long companyId) {
137         if (companyId != _companyId) {
138             _companyId = companyId;
139         }
140     }
141 
142     public long getAccountId() {
143         return _accountId;
144     }
145 
146     public void setAccountId(long accountId) {
147         if (accountId != _accountId) {
148             _accountId = accountId;
149         }
150     }
151 
152     public String getWebId() {
153         return GetterUtil.getString(_webId);
154     }
155 
156     public void setWebId(String webId) {
157         if (((webId == null) && (_webId != null)) ||
158                 ((webId != null) && (_webId == null)) ||
159                 ((webId != null) && (_webId != null) && !webId.equals(_webId))) {
160             _webId = webId;
161         }
162     }
163 
164     public String getKey() {
165         return GetterUtil.getString(_key);
166     }
167 
168     public void setKey(String key) {
169         if (((key == null) && (_key != null)) ||
170                 ((key != null) && (_key == null)) ||
171                 ((key != null) && (_key != null) && !key.equals(_key))) {
172             _key = key;
173         }
174     }
175 
176     public String getVirtualHost() {
177         return GetterUtil.getString(_virtualHost);
178     }
179 
180     public void setVirtualHost(String virtualHost) {
181         if (((virtualHost == null) && (_virtualHost != null)) ||
182                 ((virtualHost != null) && (_virtualHost == null)) ||
183                 ((virtualHost != null) && (_virtualHost != null) &&
184                 !virtualHost.equals(_virtualHost))) {
185             _virtualHost = virtualHost;
186         }
187     }
188 
189     public String getMx() {
190         return GetterUtil.getString(_mx);
191     }
192 
193     public void setMx(String mx) {
194         if (((mx == null) && (_mx != null)) || ((mx != null) && (_mx == null)) ||
195                 ((mx != null) && (_mx != null) && !mx.equals(_mx))) {
196             _mx = mx;
197         }
198     }
199 
200     public long getLogoId() {
201         return _logoId;
202     }
203 
204     public void setLogoId(long logoId) {
205         if (logoId != _logoId) {
206             _logoId = logoId;
207         }
208     }
209 
210     public Company toEscapedModel() {
211         if (isEscapedModel()) {
212             return (Company)this;
213         }
214         else {
215             Company model = new CompanyImpl();
216 
217             model.setEscapedModel(true);
218 
219             model.setCompanyId(getCompanyId());
220             model.setAccountId(getAccountId());
221             model.setWebId(HtmlUtil.escape(getWebId()));
222             model.setKey(HtmlUtil.escape(getKey()));
223             model.setVirtualHost(HtmlUtil.escape(getVirtualHost()));
224             model.setMx(HtmlUtil.escape(getMx()));
225             model.setLogoId(getLogoId());
226 
227             model = (Company)Proxy.newProxyInstance(Company.class.getClassLoader(),
228                     new Class[] { Company.class },
229                     new ReadOnlyBeanHandler(model));
230 
231             return model;
232         }
233     }
234 
235     public Object clone() {
236         CompanyImpl clone = new CompanyImpl();
237 
238         clone.setCompanyId(getCompanyId());
239         clone.setAccountId(getAccountId());
240         clone.setWebId(getWebId());
241         clone.setKey(getKey());
242         clone.setVirtualHost(getVirtualHost());
243         clone.setMx(getMx());
244         clone.setLogoId(getLogoId());
245 
246         return clone;
247     }
248 
249     public int compareTo(Object obj) {
250         if (obj == null) {
251             return -1;
252         }
253 
254         CompanyImpl company = (CompanyImpl)obj;
255 
256         long pk = company.getPrimaryKey();
257 
258         if (getPrimaryKey() < pk) {
259             return -1;
260         }
261         else if (getPrimaryKey() > pk) {
262             return 1;
263         }
264         else {
265             return 0;
266         }
267     }
268 
269     public boolean equals(Object obj) {
270         if (obj == null) {
271             return false;
272         }
273 
274         CompanyImpl company = null;
275 
276         try {
277             company = (CompanyImpl)obj;
278         }
279         catch (ClassCastException cce) {
280             return false;
281         }
282 
283         long pk = company.getPrimaryKey();
284 
285         if (getPrimaryKey() == pk) {
286             return true;
287         }
288         else {
289             return false;
290         }
291     }
292 
293     public int hashCode() {
294         return (int)getPrimaryKey();
295     }
296 
297     private long _companyId;
298     private long _accountId;
299     private String _webId;
300     private String _key;
301     private String _virtualHost;
302     private String _mx;
303     private long _logoId;
304 }