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