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     * The base model implementation for the Website service. Represents a row in the "Website" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portal.model.WebsiteModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link WebsiteImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a website model instance should use the {@link com.liferay.portal.model.Website} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see WebsiteImpl
055     * @see com.liferay.portal.model.Website
056     * @see com.liferay.portal.model.WebsiteModel
057     * @generated
058     */
059    public class WebsiteModelImpl extends BaseModelImpl<Website>
060            implements WebsiteModel {
061            public static final String TABLE_NAME = "Website";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "websiteId", new Integer(Types.BIGINT) },
064                            { "companyId", new Integer(Types.BIGINT) },
065                            { "userId", new Integer(Types.BIGINT) },
066                            { "userName", new Integer(Types.VARCHAR) },
067                            { "createDate", new Integer(Types.TIMESTAMP) },
068                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
069                            { "classNameId", new Integer(Types.BIGINT) },
070                            { "classPK", new Integer(Types.BIGINT) },
071                            { "url", new Integer(Types.VARCHAR) },
072                            { "typeId", new Integer(Types.INTEGER) },
073                            { "primary_", new Integer(Types.BOOLEAN) }
074                    };
075            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)";
076            public static final String TABLE_SQL_DROP = "drop table Website";
077            public static final String ORDER_BY_JPQL = " ORDER BY website.createDate ASC";
078            public static final String ORDER_BY_SQL = " ORDER BY Website.createDate ASC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Website"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Website"),
087                            true);
088    
089            /**
090             * Converts the soap model instance into a normal model instance.
091             *
092             * @param soapModel the soap model instance to convert
093             * @return the normal model instance
094             */
095            public static Website toModel(WebsiteSoap soapModel) {
096                    Website model = new WebsiteImpl();
097    
098                    model.setWebsiteId(soapModel.getWebsiteId());
099                    model.setCompanyId(soapModel.getCompanyId());
100                    model.setUserId(soapModel.getUserId());
101                    model.setUserName(soapModel.getUserName());
102                    model.setCreateDate(soapModel.getCreateDate());
103                    model.setModifiedDate(soapModel.getModifiedDate());
104                    model.setClassNameId(soapModel.getClassNameId());
105                    model.setClassPK(soapModel.getClassPK());
106                    model.setUrl(soapModel.getUrl());
107                    model.setTypeId(soapModel.getTypeId());
108                    model.setPrimary(soapModel.getPrimary());
109    
110                    return model;
111            }
112    
113            /**
114             * Converts the soap model instances into normal model instances.
115             *
116             * @param soapModels the soap model instances to convert
117             * @return the normal model instances
118             */
119            public static List<Website> toModels(WebsiteSoap[] soapModels) {
120                    List<Website> models = new ArrayList<Website>(soapModels.length);
121    
122                    for (WebsiteSoap soapModel : soapModels) {
123                            models.add(toModel(soapModel));
124                    }
125    
126                    return models;
127            }
128    
129            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                                    "lock.expiration.time.com.liferay.portal.model.Website"));
131    
132            public WebsiteModelImpl() {
133            }
134    
135            public long getPrimaryKey() {
136                    return _websiteId;
137            }
138    
139            public void setPrimaryKey(long pk) {
140                    setWebsiteId(pk);
141            }
142    
143            public Serializable getPrimaryKeyObj() {
144                    return new Long(_websiteId);
145            }
146    
147            public long getWebsiteId() {
148                    return _websiteId;
149            }
150    
151            public void setWebsiteId(long websiteId) {
152                    _websiteId = websiteId;
153            }
154    
155            public long getCompanyId() {
156                    return _companyId;
157            }
158    
159            public void setCompanyId(long companyId) {
160                    _companyId = companyId;
161            }
162    
163            public long getUserId() {
164                    return _userId;
165            }
166    
167            public void setUserId(long userId) {
168                    _userId = userId;
169            }
170    
171            public String getUserUuid() throws SystemException {
172                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
173            }
174    
175            public void setUserUuid(String userUuid) {
176                    _userUuid = userUuid;
177            }
178    
179            public String getUserName() {
180                    if (_userName == null) {
181                            return StringPool.BLANK;
182                    }
183                    else {
184                            return _userName;
185                    }
186            }
187    
188            public void setUserName(String userName) {
189                    _userName = userName;
190            }
191    
192            public Date getCreateDate() {
193                    return _createDate;
194            }
195    
196            public void setCreateDate(Date createDate) {
197                    _createDate = createDate;
198            }
199    
200            public Date getModifiedDate() {
201                    return _modifiedDate;
202            }
203    
204            public void setModifiedDate(Date modifiedDate) {
205                    _modifiedDate = modifiedDate;
206            }
207    
208            public String getClassName() {
209                    if (getClassNameId() <= 0) {
210                            return StringPool.BLANK;
211                    }
212    
213                    return PortalUtil.getClassName(getClassNameId());
214            }
215    
216            public long getClassNameId() {
217                    return _classNameId;
218            }
219    
220            public void setClassNameId(long classNameId) {
221                    _classNameId = classNameId;
222            }
223    
224            public long getClassPK() {
225                    return _classPK;
226            }
227    
228            public void setClassPK(long classPK) {
229                    _classPK = classPK;
230            }
231    
232            public String getUrl() {
233                    if (_url == null) {
234                            return StringPool.BLANK;
235                    }
236                    else {
237                            return _url;
238                    }
239            }
240    
241            public void setUrl(String url) {
242                    _url = url;
243            }
244    
245            public int getTypeId() {
246                    return _typeId;
247            }
248    
249            public void setTypeId(int typeId) {
250                    _typeId = typeId;
251            }
252    
253            public boolean getPrimary() {
254                    return _primary;
255            }
256    
257            public boolean isPrimary() {
258                    return _primary;
259            }
260    
261            public void setPrimary(boolean primary) {
262                    _primary = primary;
263            }
264    
265            public Website toEscapedModel() {
266                    if (isEscapedModel()) {
267                            return (Website)this;
268                    }
269                    else {
270                            return (Website)Proxy.newProxyInstance(Website.class.getClassLoader(),
271                                    new Class[] { Website.class }, new AutoEscapeBeanHandler(this));
272                    }
273            }
274    
275            public ExpandoBridge getExpandoBridge() {
276                    if (_expandoBridge == null) {
277                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
278                                            Website.class.getName(), getPrimaryKey());
279                    }
280    
281                    return _expandoBridge;
282            }
283    
284            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
285                    getExpandoBridge().setAttributes(serviceContext);
286            }
287    
288            public Object clone() {
289                    WebsiteImpl clone = new WebsiteImpl();
290    
291                    clone.setWebsiteId(getWebsiteId());
292                    clone.setCompanyId(getCompanyId());
293                    clone.setUserId(getUserId());
294                    clone.setUserName(getUserName());
295                    clone.setCreateDate(getCreateDate());
296                    clone.setModifiedDate(getModifiedDate());
297                    clone.setClassNameId(getClassNameId());
298                    clone.setClassPK(getClassPK());
299                    clone.setUrl(getUrl());
300                    clone.setTypeId(getTypeId());
301                    clone.setPrimary(getPrimary());
302    
303                    return clone;
304            }
305    
306            public int compareTo(Website website) {
307                    int value = 0;
308    
309                    value = DateUtil.compareTo(getCreateDate(), website.getCreateDate());
310    
311                    if (value != 0) {
312                            return value;
313                    }
314    
315                    return 0;
316            }
317    
318            public boolean equals(Object obj) {
319                    if (obj == null) {
320                            return false;
321                    }
322    
323                    Website website = null;
324    
325                    try {
326                            website = (Website)obj;
327                    }
328                    catch (ClassCastException cce) {
329                            return false;
330                    }
331    
332                    long pk = website.getPrimaryKey();
333    
334                    if (getPrimaryKey() == pk) {
335                            return true;
336                    }
337                    else {
338                            return false;
339                    }
340            }
341    
342            public int hashCode() {
343                    return (int)getPrimaryKey();
344            }
345    
346            public String toString() {
347                    StringBundler sb = new StringBundler(23);
348    
349                    sb.append("{websiteId=");
350                    sb.append(getWebsiteId());
351                    sb.append(", companyId=");
352                    sb.append(getCompanyId());
353                    sb.append(", userId=");
354                    sb.append(getUserId());
355                    sb.append(", userName=");
356                    sb.append(getUserName());
357                    sb.append(", createDate=");
358                    sb.append(getCreateDate());
359                    sb.append(", modifiedDate=");
360                    sb.append(getModifiedDate());
361                    sb.append(", classNameId=");
362                    sb.append(getClassNameId());
363                    sb.append(", classPK=");
364                    sb.append(getClassPK());
365                    sb.append(", url=");
366                    sb.append(getUrl());
367                    sb.append(", typeId=");
368                    sb.append(getTypeId());
369                    sb.append(", primary=");
370                    sb.append(getPrimary());
371                    sb.append("}");
372    
373                    return sb.toString();
374            }
375    
376            public String toXmlString() {
377                    StringBundler sb = new StringBundler(37);
378    
379                    sb.append("<model><model-name>");
380                    sb.append("com.liferay.portal.model.Website");
381                    sb.append("</model-name>");
382    
383                    sb.append(
384                            "<column><column-name>websiteId</column-name><column-value><![CDATA[");
385                    sb.append(getWebsiteId());
386                    sb.append("]]></column-value></column>");
387                    sb.append(
388                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
389                    sb.append(getCompanyId());
390                    sb.append("]]></column-value></column>");
391                    sb.append(
392                            "<column><column-name>userId</column-name><column-value><![CDATA[");
393                    sb.append(getUserId());
394                    sb.append("]]></column-value></column>");
395                    sb.append(
396                            "<column><column-name>userName</column-name><column-value><![CDATA[");
397                    sb.append(getUserName());
398                    sb.append("]]></column-value></column>");
399                    sb.append(
400                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
401                    sb.append(getCreateDate());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
405                    sb.append(getModifiedDate());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
409                    sb.append(getClassNameId());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
413                    sb.append(getClassPK());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>url</column-name><column-value><![CDATA[");
417                    sb.append(getUrl());
418                    sb.append("]]></column-value></column>");
419                    sb.append(
420                            "<column><column-name>typeId</column-name><column-value><![CDATA[");
421                    sb.append(getTypeId());
422                    sb.append("]]></column-value></column>");
423                    sb.append(
424                            "<column><column-name>primary</column-name><column-value><![CDATA[");
425                    sb.append(getPrimary());
426                    sb.append("]]></column-value></column>");
427    
428                    sb.append("</model>");
429    
430                    return sb.toString();
431            }
432    
433            private long _websiteId;
434            private long _companyId;
435            private long _userId;
436            private String _userUuid;
437            private String _userName;
438            private Date _createDate;
439            private Date _modifiedDate;
440            private long _classNameId;
441            private long _classPK;
442            private String _url;
443            private int _typeId;
444            private boolean _primary;
445            private transient ExpandoBridge _expandoBridge;
446    }