1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Company;
26  import com.liferay.portal.model.CompanySoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="CompanyModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>Company</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.Company
53   * @see com.liferay.portal.model.CompanyModel
54   * @see com.liferay.portal.model.impl.CompanyImpl
55   *
56   */
57  public class CompanyModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "Company";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "companyId", new Integer(Types.BIGINT) },
61              
62  
63              { "accountId", new Integer(Types.BIGINT) },
64              
65  
66              { "webId", new Integer(Types.VARCHAR) },
67              
68  
69              { "key_", new Integer(Types.CLOB) },
70              
71  
72              { "virtualHost", new Integer(Types.VARCHAR) },
73              
74  
75              { "mx", new Integer(Types.VARCHAR) },
76              
77  
78              { "logoId", new Integer(Types.BIGINT) }
79          };
80      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)";
81      public static final String TABLE_SQL_DROP = "drop table Company";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portal.model.Company"),
87              true);
88  
89      public static Company toModel(CompanySoap soapModel) {
90          Company model = new CompanyImpl();
91  
92          model.setCompanyId(soapModel.getCompanyId());
93          model.setAccountId(soapModel.getAccountId());
94          model.setWebId(soapModel.getWebId());
95          model.setKey(soapModel.getKey());
96          model.setVirtualHost(soapModel.getVirtualHost());
97          model.setMx(soapModel.getMx());
98          model.setLogoId(soapModel.getLogoId());
99  
100         return model;
101     }
102 
103     public static List<Company> toModels(CompanySoap[] soapModels) {
104         List<Company> models = new ArrayList<Company>(soapModels.length);
105 
106         for (CompanySoap soapModel : soapModels) {
107             models.add(toModel(soapModel));
108         }
109 
110         return models;
111     }
112 
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portal.model.Company"));
115 
116     public CompanyModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _companyId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setCompanyId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_companyId);
129     }
130 
131     public long getCompanyId() {
132         return _companyId;
133     }
134 
135     public void setCompanyId(long companyId) {
136         if (companyId != _companyId) {
137             _companyId = companyId;
138         }
139     }
140 
141     public long getAccountId() {
142         return _accountId;
143     }
144 
145     public void setAccountId(long accountId) {
146         if (accountId != _accountId) {
147             _accountId = accountId;
148         }
149     }
150 
151     public String getWebId() {
152         return GetterUtil.getString(_webId);
153     }
154 
155     public void setWebId(String webId) {
156         if (((webId == null) && (_webId != null)) ||
157                 ((webId != null) && (_webId == null)) ||
158                 ((webId != null) && (_webId != null) && !webId.equals(_webId))) {
159             _webId = webId;
160         }
161     }
162 
163     public String getKey() {
164         return GetterUtil.getString(_key);
165     }
166 
167     public void setKey(String key) {
168         if (((key == null) && (_key != null)) ||
169                 ((key != null) && (_key == null)) ||
170                 ((key != null) && (_key != null) && !key.equals(_key))) {
171             _key = key;
172         }
173     }
174 
175     public String getVirtualHost() {
176         return GetterUtil.getString(_virtualHost);
177     }
178 
179     public void setVirtualHost(String virtualHost) {
180         if (((virtualHost == null) && (_virtualHost != null)) ||
181                 ((virtualHost != null) && (_virtualHost == null)) ||
182                 ((virtualHost != null) && (_virtualHost != null) &&
183                 !virtualHost.equals(_virtualHost))) {
184             _virtualHost = virtualHost;
185         }
186     }
187 
188     public String getMx() {
189         return GetterUtil.getString(_mx);
190     }
191 
192     public void setMx(String mx) {
193         if (((mx == null) && (_mx != null)) || ((mx != null) && (_mx == null)) ||
194                 ((mx != null) && (_mx != null) && !mx.equals(_mx))) {
195             _mx = mx;
196         }
197     }
198 
199     public long getLogoId() {
200         return _logoId;
201     }
202 
203     public void setLogoId(long logoId) {
204         if (logoId != _logoId) {
205             _logoId = logoId;
206         }
207     }
208 
209     public Company toEscapedModel() {
210         if (isEscapedModel()) {
211             return (Company)this;
212         }
213         else {
214             Company model = new CompanyImpl();
215 
216             model.setNew(isNew());
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 }