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