001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.Website;
024    import com.liferay.portal.model.WebsiteModel;
025    import com.liferay.portal.model.WebsiteSoap;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * <p>
044     * This interface is a model that represents the Website table in the
045     * database.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       WebsiteImpl
050     * @see       com.liferay.portal.model.Website
051     * @see       com.liferay.portal.model.WebsiteModel
052     * @generated
053     */
054    public class WebsiteModelImpl extends BaseModelImpl<Website>
055            implements WebsiteModel {
056            public static final String TABLE_NAME = "Website";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "websiteId", new Integer(Types.BIGINT) },
059                            { "companyId", new Integer(Types.BIGINT) },
060                            { "userId", new Integer(Types.BIGINT) },
061                            { "userName", new Integer(Types.VARCHAR) },
062                            { "createDate", new Integer(Types.TIMESTAMP) },
063                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
064                            { "classNameId", new Integer(Types.BIGINT) },
065                            { "classPK", new Integer(Types.BIGINT) },
066                            { "url", new Integer(Types.VARCHAR) },
067                            { "typeId", new Integer(Types.INTEGER) },
068                            { "primary_", new Integer(Types.BOOLEAN) }
069                    };
070            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)";
071            public static final String TABLE_SQL_DROP = "drop table Website";
072            public static final String ORDER_BY_JPQL = " ORDER BY website.createDate ASC";
073            public static final String ORDER_BY_SQL = " ORDER BY Website.createDate ASC";
074            public static final String DATA_SOURCE = "liferayDataSource";
075            public static final String SESSION_FACTORY = "liferaySessionFactory";
076            public static final String TX_MANAGER = "liferayTransactionManager";
077            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Website"),
079                            true);
080            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Website"),
082                            true);
083    
084            public static Website toModel(WebsiteSoap soapModel) {
085                    Website model = new WebsiteImpl();
086    
087                    model.setWebsiteId(soapModel.getWebsiteId());
088                    model.setCompanyId(soapModel.getCompanyId());
089                    model.setUserId(soapModel.getUserId());
090                    model.setUserName(soapModel.getUserName());
091                    model.setCreateDate(soapModel.getCreateDate());
092                    model.setModifiedDate(soapModel.getModifiedDate());
093                    model.setClassNameId(soapModel.getClassNameId());
094                    model.setClassPK(soapModel.getClassPK());
095                    model.setUrl(soapModel.getUrl());
096                    model.setTypeId(soapModel.getTypeId());
097                    model.setPrimary(soapModel.getPrimary());
098    
099                    return model;
100            }
101    
102            public static List<Website> toModels(WebsiteSoap[] soapModels) {
103                    List<Website> models = new ArrayList<Website>(soapModels.length);
104    
105                    for (WebsiteSoap soapModel : soapModels) {
106                            models.add(toModel(soapModel));
107                    }
108    
109                    return models;
110            }
111    
112            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                                    "lock.expiration.time.com.liferay.portal.model.Website"));
114    
115            public WebsiteModelImpl() {
116            }
117    
118            public long getPrimaryKey() {
119                    return _websiteId;
120            }
121    
122            public void setPrimaryKey(long pk) {
123                    setWebsiteId(pk);
124            }
125    
126            public Serializable getPrimaryKeyObj() {
127                    return new Long(_websiteId);
128            }
129    
130            public long getWebsiteId() {
131                    return _websiteId;
132            }
133    
134            public void setWebsiteId(long websiteId) {
135                    _websiteId = websiteId;
136            }
137    
138            public long getCompanyId() {
139                    return _companyId;
140            }
141    
142            public void setCompanyId(long companyId) {
143                    _companyId = companyId;
144            }
145    
146            public long getUserId() {
147                    return _userId;
148            }
149    
150            public void setUserId(long userId) {
151                    _userId = userId;
152            }
153    
154            public String getUserUuid() throws SystemException {
155                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
156            }
157    
158            public void setUserUuid(String userUuid) {
159                    _userUuid = userUuid;
160            }
161    
162            public String getUserName() {
163                    if (_userName == null) {
164                            return StringPool.BLANK;
165                    }
166                    else {
167                            return _userName;
168                    }
169            }
170    
171            public void setUserName(String userName) {
172                    _userName = userName;
173            }
174    
175            public Date getCreateDate() {
176                    return _createDate;
177            }
178    
179            public void setCreateDate(Date createDate) {
180                    _createDate = createDate;
181            }
182    
183            public Date getModifiedDate() {
184                    return _modifiedDate;
185            }
186    
187            public void setModifiedDate(Date modifiedDate) {
188                    _modifiedDate = modifiedDate;
189            }
190    
191            public String getClassName() {
192                    if (getClassNameId() <= 0) {
193                            return StringPool.BLANK;
194                    }
195    
196                    return PortalUtil.getClassName(getClassNameId());
197            }
198    
199            public long getClassNameId() {
200                    return _classNameId;
201            }
202    
203            public void setClassNameId(long classNameId) {
204                    _classNameId = classNameId;
205            }
206    
207            public long getClassPK() {
208                    return _classPK;
209            }
210    
211            public void setClassPK(long classPK) {
212                    _classPK = classPK;
213            }
214    
215            public String getUrl() {
216                    if (_url == null) {
217                            return StringPool.BLANK;
218                    }
219                    else {
220                            return _url;
221                    }
222            }
223    
224            public void setUrl(String url) {
225                    _url = url;
226            }
227    
228            public int getTypeId() {
229                    return _typeId;
230            }
231    
232            public void setTypeId(int typeId) {
233                    _typeId = typeId;
234            }
235    
236            public boolean getPrimary() {
237                    return _primary;
238            }
239    
240            public boolean isPrimary() {
241                    return _primary;
242            }
243    
244            public void setPrimary(boolean primary) {
245                    _primary = primary;
246            }
247    
248            public Website toEscapedModel() {
249                    if (isEscapedModel()) {
250                            return (Website)this;
251                    }
252                    else {
253                            return (Website)Proxy.newProxyInstance(Website.class.getClassLoader(),
254                                    new Class[] { Website.class }, new AutoEscapeBeanHandler(this));
255                    }
256            }
257    
258            public ExpandoBridge getExpandoBridge() {
259                    if (_expandoBridge == null) {
260                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
261                                            Website.class.getName(), getPrimaryKey());
262                    }
263    
264                    return _expandoBridge;
265            }
266    
267            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
268                    getExpandoBridge().setAttributes(serviceContext);
269            }
270    
271            public Object clone() {
272                    WebsiteImpl clone = new WebsiteImpl();
273    
274                    clone.setWebsiteId(getWebsiteId());
275                    clone.setCompanyId(getCompanyId());
276                    clone.setUserId(getUserId());
277                    clone.setUserName(getUserName());
278                    clone.setCreateDate(getCreateDate());
279                    clone.setModifiedDate(getModifiedDate());
280                    clone.setClassNameId(getClassNameId());
281                    clone.setClassPK(getClassPK());
282                    clone.setUrl(getUrl());
283                    clone.setTypeId(getTypeId());
284                    clone.setPrimary(getPrimary());
285    
286                    return clone;
287            }
288    
289            public int compareTo(Website website) {
290                    int value = 0;
291    
292                    value = DateUtil.compareTo(getCreateDate(), website.getCreateDate());
293    
294                    if (value != 0) {
295                            return value;
296                    }
297    
298                    return 0;
299            }
300    
301            public boolean equals(Object obj) {
302                    if (obj == null) {
303                            return false;
304                    }
305    
306                    Website website = null;
307    
308                    try {
309                            website = (Website)obj;
310                    }
311                    catch (ClassCastException cce) {
312                            return false;
313                    }
314    
315                    long pk = website.getPrimaryKey();
316    
317                    if (getPrimaryKey() == pk) {
318                            return true;
319                    }
320                    else {
321                            return false;
322                    }
323            }
324    
325            public int hashCode() {
326                    return (int)getPrimaryKey();
327            }
328    
329            public String toString() {
330                    StringBundler sb = new StringBundler(23);
331    
332                    sb.append("{websiteId=");
333                    sb.append(getWebsiteId());
334                    sb.append(", companyId=");
335                    sb.append(getCompanyId());
336                    sb.append(", userId=");
337                    sb.append(getUserId());
338                    sb.append(", userName=");
339                    sb.append(getUserName());
340                    sb.append(", createDate=");
341                    sb.append(getCreateDate());
342                    sb.append(", modifiedDate=");
343                    sb.append(getModifiedDate());
344                    sb.append(", classNameId=");
345                    sb.append(getClassNameId());
346                    sb.append(", classPK=");
347                    sb.append(getClassPK());
348                    sb.append(", url=");
349                    sb.append(getUrl());
350                    sb.append(", typeId=");
351                    sb.append(getTypeId());
352                    sb.append(", primary=");
353                    sb.append(getPrimary());
354                    sb.append("}");
355    
356                    return sb.toString();
357            }
358    
359            public String toXmlString() {
360                    StringBundler sb = new StringBundler(37);
361    
362                    sb.append("<model><model-name>");
363                    sb.append("com.liferay.portal.model.Website");
364                    sb.append("</model-name>");
365    
366                    sb.append(
367                            "<column><column-name>websiteId</column-name><column-value><![CDATA[");
368                    sb.append(getWebsiteId());
369                    sb.append("]]></column-value></column>");
370                    sb.append(
371                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
372                    sb.append(getCompanyId());
373                    sb.append("]]></column-value></column>");
374                    sb.append(
375                            "<column><column-name>userId</column-name><column-value><![CDATA[");
376                    sb.append(getUserId());
377                    sb.append("]]></column-value></column>");
378                    sb.append(
379                            "<column><column-name>userName</column-name><column-value><![CDATA[");
380                    sb.append(getUserName());
381                    sb.append("]]></column-value></column>");
382                    sb.append(
383                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
384                    sb.append(getCreateDate());
385                    sb.append("]]></column-value></column>");
386                    sb.append(
387                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
388                    sb.append(getModifiedDate());
389                    sb.append("]]></column-value></column>");
390                    sb.append(
391                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
392                    sb.append(getClassNameId());
393                    sb.append("]]></column-value></column>");
394                    sb.append(
395                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
396                    sb.append(getClassPK());
397                    sb.append("]]></column-value></column>");
398                    sb.append(
399                            "<column><column-name>url</column-name><column-value><![CDATA[");
400                    sb.append(getUrl());
401                    sb.append("]]></column-value></column>");
402                    sb.append(
403                            "<column><column-name>typeId</column-name><column-value><![CDATA[");
404                    sb.append(getTypeId());
405                    sb.append("]]></column-value></column>");
406                    sb.append(
407                            "<column><column-name>primary</column-name><column-value><![CDATA[");
408                    sb.append(getPrimary());
409                    sb.append("]]></column-value></column>");
410    
411                    sb.append("</model>");
412    
413                    return sb.toString();
414            }
415    
416            private long _websiteId;
417            private long _companyId;
418            private long _userId;
419            private String _userUuid;
420            private String _userName;
421            private Date _createDate;
422            private Date _modifiedDate;
423            private long _classNameId;
424            private long _classPK;
425            private String _url;
426            private int _typeId;
427            private boolean _primary;
428            private transient ExpandoBridge _expandoBridge;
429    }