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.model.Company
56   * @see com.liferay.portal.model.CompanyModel
57   * @see com.liferay.portal.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.setNew(isNew());
220             model.setEscapedModel(true);
221 
222             model.setCompanyId(getCompanyId());
223             model.setAccountId(getAccountId());
224             model.setWebId(HtmlUtil.escape(getWebId()));
225             model.setKey(HtmlUtil.escape(getKey()));
226             model.setVirtualHost(HtmlUtil.escape(getVirtualHost()));
227             model.setMx(HtmlUtil.escape(getMx()));
228             model.setLogoId(getLogoId());
229 
230             model = (Company)Proxy.newProxyInstance(Company.class.getClassLoader(),
231                     new Class[] { Company.class },
232                     new ReadOnlyBeanHandler(model));
233 
234             return model;
235         }
236     }
237 
238     public Object clone() {
239         CompanyImpl clone = new CompanyImpl();
240 
241         clone.setCompanyId(getCompanyId());
242         clone.setAccountId(getAccountId());
243         clone.setWebId(getWebId());
244         clone.setKey(getKey());
245         clone.setVirtualHost(getVirtualHost());
246         clone.setMx(getMx());
247         clone.setLogoId(getLogoId());
248 
249         return clone;
250     }
251 
252     public int compareTo(Object obj) {
253         if (obj == null) {
254             return -1;
255         }
256 
257         CompanyImpl company = (CompanyImpl)obj;
258 
259         long pk = company.getPrimaryKey();
260 
261         if (getPrimaryKey() < pk) {
262             return -1;
263         }
264         else if (getPrimaryKey() > pk) {
265             return 1;
266         }
267         else {
268             return 0;
269         }
270     }
271 
272     public boolean equals(Object obj) {
273         if (obj == null) {
274             return false;
275         }
276 
277         CompanyImpl company = null;
278 
279         try {
280             company = (CompanyImpl)obj;
281         }
282         catch (ClassCastException cce) {
283             return false;
284         }
285 
286         long pk = company.getPrimaryKey();
287 
288         if (getPrimaryKey() == pk) {
289             return true;
290         }
291         else {
292             return false;
293         }
294     }
295 
296     public int hashCode() {
297         return (int)getPrimaryKey();
298     }
299 
300     private long _companyId;
301     private long _accountId;
302     private String _webId;
303     private String _key;
304     private String _virtualHost;
305     private String _mx;
306     private long _logoId;
307 }