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.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.Website;
30  import com.liferay.portal.model.WebsiteSoap;
31  import com.liferay.portal.util.PortalUtil;
32  import com.liferay.portal.util.PropsUtil;
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.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="WebsiteModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>Website</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.service.model.Website
60   * @see com.liferay.portal.service.model.WebsiteModel
61   * @see com.liferay.portal.service.model.impl.WebsiteImpl
62   *
63   */
64  public class WebsiteModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "Website";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "websiteId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "classNameId", new Integer(Types.BIGINT) },
86              
87  
88              { "classPK", new Integer(Types.BIGINT) },
89              
90  
91              { "url", new Integer(Types.VARCHAR) },
92              
93  
94              { "typeId", new Integer(Types.INTEGER) },
95              
96  
97              { "primary_", new Integer(Types.BOOLEAN) }
98          };
99      public static final String TABLE_SQL_CREATE = "create table Website (websiteId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,url STRING null,typeId INTEGER,primary_ BOOLEAN)";
100     public static final String TABLE_SQL_DROP = "drop table Website";
101     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
102                 "value.object.finder.cache.enabled.com.liferay.portal.model.Website"),
103             true);
104 
105     public static Website toModel(WebsiteSoap soapModel) {
106         Website model = new WebsiteImpl();
107 
108         model.setWebsiteId(soapModel.getWebsiteId());
109         model.setCompanyId(soapModel.getCompanyId());
110         model.setUserId(soapModel.getUserId());
111         model.setUserName(soapModel.getUserName());
112         model.setCreateDate(soapModel.getCreateDate());
113         model.setModifiedDate(soapModel.getModifiedDate());
114         model.setClassNameId(soapModel.getClassNameId());
115         model.setClassPK(soapModel.getClassPK());
116         model.setUrl(soapModel.getUrl());
117         model.setTypeId(soapModel.getTypeId());
118         model.setPrimary(soapModel.getPrimary());
119 
120         return model;
121     }
122 
123     public static List<Website> toModels(WebsiteSoap[] soapModels) {
124         List<Website> models = new ArrayList<Website>(soapModels.length);
125 
126         for (WebsiteSoap soapModel : soapModels) {
127             models.add(toModel(soapModel));
128         }
129 
130         return models;
131     }
132 
133     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
134                 "lock.expiration.time.com.liferay.portal.model.Website"));
135 
136     public WebsiteModelImpl() {
137     }
138 
139     public long getPrimaryKey() {
140         return _websiteId;
141     }
142 
143     public void setPrimaryKey(long pk) {
144         setWebsiteId(pk);
145     }
146 
147     public Serializable getPrimaryKeyObj() {
148         return new Long(_websiteId);
149     }
150 
151     public long getWebsiteId() {
152         return _websiteId;
153     }
154 
155     public void setWebsiteId(long websiteId) {
156         if (websiteId != _websiteId) {
157             _websiteId = websiteId;
158         }
159     }
160 
161     public long getCompanyId() {
162         return _companyId;
163     }
164 
165     public void setCompanyId(long companyId) {
166         if (companyId != _companyId) {
167             _companyId = companyId;
168         }
169     }
170 
171     public long getUserId() {
172         return _userId;
173     }
174 
175     public void setUserId(long userId) {
176         if (userId != _userId) {
177             _userId = userId;
178         }
179     }
180 
181     public String getUserName() {
182         return GetterUtil.getString(_userName);
183     }
184 
185     public void setUserName(String userName) {
186         if (((userName == null) && (_userName != null)) ||
187                 ((userName != null) && (_userName == null)) ||
188                 ((userName != null) && (_userName != null) &&
189                 !userName.equals(_userName))) {
190             _userName = userName;
191         }
192     }
193 
194     public Date getCreateDate() {
195         return _createDate;
196     }
197 
198     public void setCreateDate(Date createDate) {
199         if (((createDate == null) && (_createDate != null)) ||
200                 ((createDate != null) && (_createDate == null)) ||
201                 ((createDate != null) && (_createDate != null) &&
202                 !createDate.equals(_createDate))) {
203             _createDate = createDate;
204         }
205     }
206 
207     public Date getModifiedDate() {
208         return _modifiedDate;
209     }
210 
211     public void setModifiedDate(Date modifiedDate) {
212         if (((modifiedDate == null) && (_modifiedDate != null)) ||
213                 ((modifiedDate != null) && (_modifiedDate == null)) ||
214                 ((modifiedDate != null) && (_modifiedDate != null) &&
215                 !modifiedDate.equals(_modifiedDate))) {
216             _modifiedDate = modifiedDate;
217         }
218     }
219 
220     public String getClassName() {
221         return PortalUtil.getClassName(getClassNameId());
222     }
223 
224     public long getClassNameId() {
225         return _classNameId;
226     }
227 
228     public void setClassNameId(long classNameId) {
229         if (classNameId != _classNameId) {
230             _classNameId = classNameId;
231         }
232     }
233 
234     public long getClassPK() {
235         return _classPK;
236     }
237 
238     public void setClassPK(long classPK) {
239         if (classPK != _classPK) {
240             _classPK = classPK;
241         }
242     }
243 
244     public String getUrl() {
245         return GetterUtil.getString(_url);
246     }
247 
248     public void setUrl(String url) {
249         if (((url == null) && (_url != null)) ||
250                 ((url != null) && (_url == null)) ||
251                 ((url != null) && (_url != null) && !url.equals(_url))) {
252             _url = url;
253         }
254     }
255 
256     public int getTypeId() {
257         return _typeId;
258     }
259 
260     public void setTypeId(int typeId) {
261         if (typeId != _typeId) {
262             _typeId = typeId;
263         }
264     }
265 
266     public boolean getPrimary() {
267         return _primary;
268     }
269 
270     public boolean isPrimary() {
271         return _primary;
272     }
273 
274     public void setPrimary(boolean primary) {
275         if (primary != _primary) {
276             _primary = primary;
277         }
278     }
279 
280     public Website toEscapedModel() {
281         if (isEscapedModel()) {
282             return (Website)this;
283         }
284         else {
285             Website model = new WebsiteImpl();
286 
287             model.setEscapedModel(true);
288 
289             model.setWebsiteId(getWebsiteId());
290             model.setCompanyId(getCompanyId());
291             model.setUserId(getUserId());
292             model.setUserName(HtmlUtil.escape(getUserName()));
293             model.setCreateDate(getCreateDate());
294             model.setModifiedDate(getModifiedDate());
295             model.setClassNameId(getClassNameId());
296             model.setClassPK(getClassPK());
297             model.setUrl(HtmlUtil.escape(getUrl()));
298             model.setTypeId(getTypeId());
299             model.setPrimary(getPrimary());
300 
301             model = (Website)Proxy.newProxyInstance(Website.class.getClassLoader(),
302                     new Class[] { Website.class },
303                     new ReadOnlyBeanHandler(model));
304 
305             return model;
306         }
307     }
308 
309     public Object clone() {
310         WebsiteImpl clone = new WebsiteImpl();
311 
312         clone.setWebsiteId(getWebsiteId());
313         clone.setCompanyId(getCompanyId());
314         clone.setUserId(getUserId());
315         clone.setUserName(getUserName());
316         clone.setCreateDate(getCreateDate());
317         clone.setModifiedDate(getModifiedDate());
318         clone.setClassNameId(getClassNameId());
319         clone.setClassPK(getClassPK());
320         clone.setUrl(getUrl());
321         clone.setTypeId(getTypeId());
322         clone.setPrimary(getPrimary());
323 
324         return clone;
325     }
326 
327     public int compareTo(Object obj) {
328         if (obj == null) {
329             return -1;
330         }
331 
332         WebsiteImpl website = (WebsiteImpl)obj;
333 
334         int value = 0;
335 
336         value = DateUtil.compareTo(getCreateDate(), website.getCreateDate());
337 
338         if (value != 0) {
339             return value;
340         }
341 
342         return 0;
343     }
344 
345     public boolean equals(Object obj) {
346         if (obj == null) {
347             return false;
348         }
349 
350         WebsiteImpl website = null;
351 
352         try {
353             website = (WebsiteImpl)obj;
354         }
355         catch (ClassCastException cce) {
356             return false;
357         }
358 
359         long pk = website.getPrimaryKey();
360 
361         if (getPrimaryKey() == pk) {
362             return true;
363         }
364         else {
365             return false;
366         }
367     }
368 
369     public int hashCode() {
370         return (int)getPrimaryKey();
371     }
372 
373     private long _websiteId;
374     private long _companyId;
375     private long _userId;
376     private String _userName;
377     private Date _createDate;
378     private Date _modifiedDate;
379     private long _classNameId;
380     private long _classPK;
381     private String _url;
382     private int _typeId;
383     private boolean _primary;
384 }