1   /**
2    * Copyright (c) 2000-2009 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  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="CompanyModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>Company</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.model.Company
59   * @see com.liferay.portal.model.CompanyModel
60   * @see com.liferay.portal.model.impl.CompanyImpl
61   *
62   */
63  public class CompanyModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "Company";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "companyId", new Integer(Types.BIGINT) },
67              
68  
69              { "accountId", new Integer(Types.BIGINT) },
70              
71  
72              { "webId", new Integer(Types.VARCHAR) },
73              
74  
75              { "key_", new Integer(Types.CLOB) },
76              
77  
78              { "virtualHost", new Integer(Types.VARCHAR) },
79              
80  
81              { "mx", new Integer(Types.VARCHAR) },
82              
83  
84              { "homeURL", new Integer(Types.VARCHAR) },
85              
86  
87              { "logoId", new Integer(Types.BIGINT) }
88          };
89      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)";
90      public static final String TABLE_SQL_DROP = "drop table Company";
91      public static final String DATA_SOURCE = "liferayDataSource";
92      public static final String SESSION_FACTORY = "liferaySessionFactory";
93      public static final String TX_MANAGER = "liferayTransactionManager";
94      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portal.model.Company"),
96              true);
97  
98      public static Company toModel(CompanySoap soapModel) {
99          Company model = new CompanyImpl();
100 
101         model.setCompanyId(soapModel.getCompanyId());
102         model.setAccountId(soapModel.getAccountId());
103         model.setWebId(soapModel.getWebId());
104         model.setKey(soapModel.getKey());
105         model.setVirtualHost(soapModel.getVirtualHost());
106         model.setMx(soapModel.getMx());
107         model.setHomeURL(soapModel.getHomeURL());
108         model.setLogoId(soapModel.getLogoId());
109 
110         return model;
111     }
112 
113     public static List<Company> toModels(CompanySoap[] soapModels) {
114         List<Company> models = new ArrayList<Company>(soapModels.length);
115 
116         for (CompanySoap soapModel : soapModels) {
117             models.add(toModel(soapModel));
118         }
119 
120         return models;
121     }
122 
123     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
124                 "lock.expiration.time.com.liferay.portal.model.Company"));
125 
126     public CompanyModelImpl() {
127     }
128 
129     public long getPrimaryKey() {
130         return _companyId;
131     }
132 
133     public void setPrimaryKey(long pk) {
134         setCompanyId(pk);
135     }
136 
137     public Serializable getPrimaryKeyObj() {
138         return new Long(_companyId);
139     }
140 
141     public long getCompanyId() {
142         return _companyId;
143     }
144 
145     public void setCompanyId(long companyId) {
146         if (companyId != _companyId) {
147             _companyId = companyId;
148         }
149     }
150 
151     public long getAccountId() {
152         return _accountId;
153     }
154 
155     public void setAccountId(long accountId) {
156         if (accountId != _accountId) {
157             _accountId = accountId;
158         }
159     }
160 
161     public String getWebId() {
162         return GetterUtil.getString(_webId);
163     }
164 
165     public void setWebId(String webId) {
166         if (((webId == null) && (_webId != null)) ||
167                 ((webId != null) && (_webId == null)) ||
168                 ((webId != null) && (_webId != null) && !webId.equals(_webId))) {
169             _webId = webId;
170         }
171     }
172 
173     public String getKey() {
174         return GetterUtil.getString(_key);
175     }
176 
177     public void setKey(String key) {
178         if (((key == null) && (_key != null)) ||
179                 ((key != null) && (_key == null)) ||
180                 ((key != null) && (_key != null) && !key.equals(_key))) {
181             _key = key;
182         }
183     }
184 
185     public String getVirtualHost() {
186         return GetterUtil.getString(_virtualHost);
187     }
188 
189     public void setVirtualHost(String virtualHost) {
190         if (((virtualHost == null) && (_virtualHost != null)) ||
191                 ((virtualHost != null) && (_virtualHost == null)) ||
192                 ((virtualHost != null) && (_virtualHost != null) &&
193                 !virtualHost.equals(_virtualHost))) {
194             _virtualHost = virtualHost;
195         }
196     }
197 
198     public String getMx() {
199         return GetterUtil.getString(_mx);
200     }
201 
202     public void setMx(String mx) {
203         if (((mx == null) && (_mx != null)) || ((mx != null) && (_mx == null)) ||
204                 ((mx != null) && (_mx != null) && !mx.equals(_mx))) {
205             _mx = mx;
206         }
207     }
208 
209     public String getHomeURL() {
210         return GetterUtil.getString(_homeURL);
211     }
212 
213     public void setHomeURL(String homeURL) {
214         if (((homeURL == null) && (_homeURL != null)) ||
215                 ((homeURL != null) && (_homeURL == null)) ||
216                 ((homeURL != null) && (_homeURL != null) &&
217                 !homeURL.equals(_homeURL))) {
218             _homeURL = homeURL;
219         }
220     }
221 
222     public long getLogoId() {
223         return _logoId;
224     }
225 
226     public void setLogoId(long logoId) {
227         if (logoId != _logoId) {
228             _logoId = logoId;
229         }
230     }
231 
232     public Company toEscapedModel() {
233         if (isEscapedModel()) {
234             return (Company)this;
235         }
236         else {
237             Company model = new CompanyImpl();
238 
239             model.setNew(isNew());
240             model.setEscapedModel(true);
241 
242             model.setCompanyId(getCompanyId());
243             model.setAccountId(getAccountId());
244             model.setWebId(HtmlUtil.escape(getWebId()));
245             model.setKey(HtmlUtil.escape(getKey()));
246             model.setVirtualHost(HtmlUtil.escape(getVirtualHost()));
247             model.setMx(HtmlUtil.escape(getMx()));
248             model.setHomeURL(HtmlUtil.escape(getHomeURL()));
249             model.setLogoId(getLogoId());
250 
251             model = (Company)Proxy.newProxyInstance(Company.class.getClassLoader(),
252                     new Class[] { Company.class },
253                     new ReadOnlyBeanHandler(model));
254 
255             return model;
256         }
257     }
258 
259     public ExpandoBridge getExpandoBridge() {
260         if (_expandoBridge == null) {
261             _expandoBridge = new ExpandoBridgeImpl(Company.class.getName(),
262                     getPrimaryKey());
263         }
264 
265         return _expandoBridge;
266     }
267 
268     public Object clone() {
269         CompanyImpl clone = new CompanyImpl();
270 
271         clone.setCompanyId(getCompanyId());
272         clone.setAccountId(getAccountId());
273         clone.setWebId(getWebId());
274         clone.setKey(getKey());
275         clone.setVirtualHost(getVirtualHost());
276         clone.setMx(getMx());
277         clone.setHomeURL(getHomeURL());
278         clone.setLogoId(getLogoId());
279 
280         return clone;
281     }
282 
283     public int compareTo(Object obj) {
284         if (obj == null) {
285             return -1;
286         }
287 
288         CompanyImpl company = (CompanyImpl)obj;
289 
290         long pk = company.getPrimaryKey();
291 
292         if (getPrimaryKey() < pk) {
293             return -1;
294         }
295         else if (getPrimaryKey() > pk) {
296             return 1;
297         }
298         else {
299             return 0;
300         }
301     }
302 
303     public boolean equals(Object obj) {
304         if (obj == null) {
305             return false;
306         }
307 
308         CompanyImpl company = null;
309 
310         try {
311             company = (CompanyImpl)obj;
312         }
313         catch (ClassCastException cce) {
314             return false;
315         }
316 
317         long pk = company.getPrimaryKey();
318 
319         if (getPrimaryKey() == pk) {
320             return true;
321         }
322         else {
323             return false;
324         }
325     }
326 
327     public int hashCode() {
328         return (int)getPrimaryKey();
329     }
330 
331     private long _companyId;
332     private long _accountId;
333     private String _webId;
334     private String _key;
335     private String _virtualHost;
336     private String _mx;
337     private String _homeURL;
338     private long _logoId;
339     private transient ExpandoBridge _expandoBridge;
340 }