1   /**
2    * Copyright (c) 2000-2007 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.kernel.util.DateUtil;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.XSSUtil;
31  
32  import java.io.Serializable;
33  
34  import java.sql.Types;
35  
36  import java.util.Date;
37  
38  /**
39   * <a href="WebsiteModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be overwritten
43   * the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Website</code> table in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.service.model.Website
53   * @see com.liferay.portal.service.model.WebsiteModel
54   * @see com.liferay.portal.service.model.impl.WebsiteImpl
55   *
56   */
57  public class WebsiteModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "Website";
59      public static Object[][] TABLE_COLUMNS = {
60              { "websiteId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "modifiedDate", new Integer(Types.TIMESTAMP) },
66              { "classNameId", new Integer(Types.BIGINT) },
67              { "classPK", new Integer(Types.BIGINT) },
68              { "url", new Integer(Types.VARCHAR) },
69              { "typeId", new Integer(Types.INTEGER) },
70              { "primary_", new Integer(Types.BOOLEAN) }
71          };
72      public static 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)";
73      public static String TABLE_SQL_DROP = "drop table Website";
74      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
75                  "xss.allow.com.liferay.portal.model.Website"), XSS_ALLOW);
76      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
77                  "xss.allow.com.liferay.portal.model.Website.userName"),
78              XSS_ALLOW_BY_MODEL);
79      public static boolean XSS_ALLOW_URL = GetterUtil.getBoolean(PropsUtil.get(
80                  "xss.allow.com.liferay.portal.model.Website.url"),
81              XSS_ALLOW_BY_MODEL);
82      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
83                  "lock.expiration.time.com.liferay.portal.model.WebsiteModel"));
84  
85      public WebsiteModelImpl() {
86      }
87  
88      public long getPrimaryKey() {
89          return _websiteId;
90      }
91  
92      public void setPrimaryKey(long pk) {
93          setWebsiteId(pk);
94      }
95  
96      public Serializable getPrimaryKeyObj() {
97          return new Long(_websiteId);
98      }
99  
100     public long getWebsiteId() {
101         return _websiteId;
102     }
103 
104     public void setWebsiteId(long websiteId) {
105         if (websiteId != _websiteId) {
106             _websiteId = websiteId;
107         }
108     }
109 
110     public long getCompanyId() {
111         return _companyId;
112     }
113 
114     public void setCompanyId(long companyId) {
115         if (companyId != _companyId) {
116             _companyId = companyId;
117         }
118     }
119 
120     public long getUserId() {
121         return _userId;
122     }
123 
124     public void setUserId(long userId) {
125         if (userId != _userId) {
126             _userId = userId;
127         }
128     }
129 
130     public String getUserName() {
131         return GetterUtil.getString(_userName);
132     }
133 
134     public void setUserName(String userName) {
135         if (((userName == null) && (_userName != null)) ||
136                 ((userName != null) && (_userName == null)) ||
137                 ((userName != null) && (_userName != null) &&
138                 !userName.equals(_userName))) {
139             if (!XSS_ALLOW_USERNAME) {
140                 userName = XSSUtil.strip(userName);
141             }
142 
143             _userName = userName;
144         }
145     }
146 
147     public Date getCreateDate() {
148         return _createDate;
149     }
150 
151     public void setCreateDate(Date createDate) {
152         if (((createDate == null) && (_createDate != null)) ||
153                 ((createDate != null) && (_createDate == null)) ||
154                 ((createDate != null) && (_createDate != null) &&
155                 !createDate.equals(_createDate))) {
156             _createDate = createDate;
157         }
158     }
159 
160     public Date getModifiedDate() {
161         return _modifiedDate;
162     }
163 
164     public void setModifiedDate(Date modifiedDate) {
165         if (((modifiedDate == null) && (_modifiedDate != null)) ||
166                 ((modifiedDate != null) && (_modifiedDate == null)) ||
167                 ((modifiedDate != null) && (_modifiedDate != null) &&
168                 !modifiedDate.equals(_modifiedDate))) {
169             _modifiedDate = modifiedDate;
170         }
171     }
172 
173     public long getClassNameId() {
174         return _classNameId;
175     }
176 
177     public void setClassNameId(long classNameId) {
178         if (classNameId != _classNameId) {
179             _classNameId = classNameId;
180         }
181     }
182 
183     public long getClassPK() {
184         return _classPK;
185     }
186 
187     public void setClassPK(long classPK) {
188         if (classPK != _classPK) {
189             _classPK = classPK;
190         }
191     }
192 
193     public String getUrl() {
194         return GetterUtil.getString(_url);
195     }
196 
197     public void setUrl(String url) {
198         if (((url == null) && (_url != null)) ||
199                 ((url != null) && (_url == null)) ||
200                 ((url != null) && (_url != null) && !url.equals(_url))) {
201             if (!XSS_ALLOW_URL) {
202                 url = XSSUtil.strip(url);
203             }
204 
205             _url = url;
206         }
207     }
208 
209     public int getTypeId() {
210         return _typeId;
211     }
212 
213     public void setTypeId(int typeId) {
214         if (typeId != _typeId) {
215             _typeId = typeId;
216         }
217     }
218 
219     public boolean getPrimary() {
220         return _primary;
221     }
222 
223     public boolean isPrimary() {
224         return _primary;
225     }
226 
227     public void setPrimary(boolean primary) {
228         if (primary != _primary) {
229             _primary = primary;
230         }
231     }
232 
233     public Object clone() {
234         WebsiteImpl clone = new WebsiteImpl();
235         clone.setWebsiteId(getWebsiteId());
236         clone.setCompanyId(getCompanyId());
237         clone.setUserId(getUserId());
238         clone.setUserName(getUserName());
239         clone.setCreateDate(getCreateDate());
240         clone.setModifiedDate(getModifiedDate());
241         clone.setClassNameId(getClassNameId());
242         clone.setClassPK(getClassPK());
243         clone.setUrl(getUrl());
244         clone.setTypeId(getTypeId());
245         clone.setPrimary(getPrimary());
246 
247         return clone;
248     }
249 
250     public int compareTo(Object obj) {
251         if (obj == null) {
252             return -1;
253         }
254 
255         WebsiteImpl website = (WebsiteImpl)obj;
256         int value = 0;
257         value = DateUtil.compareTo(getCreateDate(), website.getCreateDate());
258 
259         if (value != 0) {
260             return value;
261         }
262 
263         return 0;
264     }
265 
266     public boolean equals(Object obj) {
267         if (obj == null) {
268             return false;
269         }
270 
271         WebsiteImpl website = null;
272 
273         try {
274             website = (WebsiteImpl)obj;
275         }
276         catch (ClassCastException cce) {
277             return false;
278         }
279 
280         long pk = website.getPrimaryKey();
281 
282         if (getPrimaryKey() == pk) {
283             return true;
284         }
285         else {
286             return false;
287         }
288     }
289 
290     public int hashCode() {
291         return (int)getPrimaryKey();
292     }
293 
294     private long _websiteId;
295     private long _companyId;
296     private long _userId;
297     private String _userName;
298     private Date _createDate;
299     private Date _modifiedDate;
300     private long _classNameId;
301     private long _classPK;
302     private String _url;
303     private int _typeId;
304     private boolean _primary;
305 }