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