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