1   /**
2    * Copyright (c) 2000-2008 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.portlet.bookmarks.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
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.portlet.bookmarks.model.BookmarksEntry;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.Date;
41  
42  /**
43   * <a href="BookmarksEntryModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>BookmarksEntry</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.bookmarks.service.model.BookmarksEntry
58   * @see com.liferay.portlet.bookmarks.service.model.BookmarksEntryModel
59   * @see com.liferay.portlet.bookmarks.service.model.impl.BookmarksEntryImpl
60   *
61   */
62  public class BookmarksEntryModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "BookmarksEntry";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "entryId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "userId", new Integer(Types.BIGINT) },
75              
76  
77              { "createDate", new Integer(Types.TIMESTAMP) },
78              
79  
80              { "modifiedDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "folderId", new Integer(Types.BIGINT) },
84              
85  
86              { "name", new Integer(Types.VARCHAR) },
87              
88  
89              { "url", new Integer(Types.VARCHAR) },
90              
91  
92              { "comments", new Integer(Types.VARCHAR) },
93              
94  
95              { "visits", new Integer(Types.INTEGER) },
96              
97  
98              { "priority", new Integer(Types.INTEGER) }
99          };
100     public static final String TABLE_SQL_CREATE = "create table BookmarksEntry (uuid_ VARCHAR(75) null,entryId LONG not null primary key,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,folderId LONG,name VARCHAR(300) null,url STRING null,comments STRING null,visits INTEGER,priority INTEGER)";
101     public static final String TABLE_SQL_DROP = "drop table BookmarksEntry";
102     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
103                 "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksEntry"),
104             true);
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksEntry"));
107 
108     public BookmarksEntryModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _entryId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setEntryId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_entryId);
121     }
122 
123     public String getUuid() {
124         return GetterUtil.getString(_uuid);
125     }
126 
127     public void setUuid(String uuid) {
128         if ((uuid != null) && (uuid != _uuid)) {
129             _uuid = uuid;
130         }
131     }
132 
133     public long getEntryId() {
134         return _entryId;
135     }
136 
137     public void setEntryId(long entryId) {
138         if (entryId != _entryId) {
139             _entryId = entryId;
140         }
141     }
142 
143     public long getCompanyId() {
144         return _companyId;
145     }
146 
147     public void setCompanyId(long companyId) {
148         if (companyId != _companyId) {
149             _companyId = companyId;
150         }
151     }
152 
153     public long getUserId() {
154         return _userId;
155     }
156 
157     public void setUserId(long userId) {
158         if (userId != _userId) {
159             _userId = userId;
160         }
161     }
162 
163     public Date getCreateDate() {
164         return _createDate;
165     }
166 
167     public void setCreateDate(Date createDate) {
168         if (((createDate == null) && (_createDate != null)) ||
169                 ((createDate != null) && (_createDate == null)) ||
170                 ((createDate != null) && (_createDate != null) &&
171                 !createDate.equals(_createDate))) {
172             _createDate = createDate;
173         }
174     }
175 
176     public Date getModifiedDate() {
177         return _modifiedDate;
178     }
179 
180     public void setModifiedDate(Date modifiedDate) {
181         if (((modifiedDate == null) && (_modifiedDate != null)) ||
182                 ((modifiedDate != null) && (_modifiedDate == null)) ||
183                 ((modifiedDate != null) && (_modifiedDate != null) &&
184                 !modifiedDate.equals(_modifiedDate))) {
185             _modifiedDate = modifiedDate;
186         }
187     }
188 
189     public long getFolderId() {
190         return _folderId;
191     }
192 
193     public void setFolderId(long folderId) {
194         if (folderId != _folderId) {
195             _folderId = folderId;
196         }
197     }
198 
199     public String getName() {
200         return GetterUtil.getString(_name);
201     }
202 
203     public void setName(String name) {
204         if (((name == null) && (_name != null)) ||
205                 ((name != null) && (_name == null)) ||
206                 ((name != null) && (_name != null) && !name.equals(_name))) {
207             _name = name;
208         }
209     }
210 
211     public String getUrl() {
212         return GetterUtil.getString(_url);
213     }
214 
215     public void setUrl(String url) {
216         if (((url == null) && (_url != null)) ||
217                 ((url != null) && (_url == null)) ||
218                 ((url != null) && (_url != null) && !url.equals(_url))) {
219             _url = url;
220         }
221     }
222 
223     public String getComments() {
224         return GetterUtil.getString(_comments);
225     }
226 
227     public void setComments(String comments) {
228         if (((comments == null) && (_comments != null)) ||
229                 ((comments != null) && (_comments == null)) ||
230                 ((comments != null) && (_comments != null) &&
231                 !comments.equals(_comments))) {
232             _comments = comments;
233         }
234     }
235 
236     public int getVisits() {
237         return _visits;
238     }
239 
240     public void setVisits(int visits) {
241         if (visits != _visits) {
242             _visits = visits;
243         }
244     }
245 
246     public int getPriority() {
247         return _priority;
248     }
249 
250     public void setPriority(int priority) {
251         if (priority != _priority) {
252             _priority = priority;
253         }
254     }
255 
256     public BookmarksEntry toEscapedModel() {
257         if (isEscapedModel()) {
258             return (BookmarksEntry)this;
259         }
260         else {
261             BookmarksEntry model = new BookmarksEntryImpl();
262 
263             model.setEscapedModel(true);
264 
265             model.setUuid(Html.escape(getUuid()));
266             model.setEntryId(getEntryId());
267             model.setCompanyId(getCompanyId());
268             model.setUserId(getUserId());
269             model.setCreateDate(getCreateDate());
270             model.setModifiedDate(getModifiedDate());
271             model.setFolderId(getFolderId());
272             model.setName(Html.escape(getName()));
273             model.setUrl(Html.escape(getUrl()));
274             model.setComments(Html.escape(getComments()));
275             model.setVisits(getVisits());
276             model.setPriority(getPriority());
277 
278             model = (BookmarksEntry)Proxy.newProxyInstance(BookmarksEntry.class.getClassLoader(),
279                     new Class[] { BookmarksEntry.class },
280                     new ReadOnlyBeanHandler(model));
281 
282             return model;
283         }
284     }
285 
286     public Object clone() {
287         BookmarksEntryImpl clone = new BookmarksEntryImpl();
288 
289         clone.setUuid(getUuid());
290         clone.setEntryId(getEntryId());
291         clone.setCompanyId(getCompanyId());
292         clone.setUserId(getUserId());
293         clone.setCreateDate(getCreateDate());
294         clone.setModifiedDate(getModifiedDate());
295         clone.setFolderId(getFolderId());
296         clone.setName(getName());
297         clone.setUrl(getUrl());
298         clone.setComments(getComments());
299         clone.setVisits(getVisits());
300         clone.setPriority(getPriority());
301 
302         return clone;
303     }
304 
305     public int compareTo(Object obj) {
306         if (obj == null) {
307             return -1;
308         }
309 
310         BookmarksEntryImpl bookmarksEntry = (BookmarksEntryImpl)obj;
311 
312         int value = 0;
313 
314         if (getFolderId() < bookmarksEntry.getFolderId()) {
315             value = -1;
316         }
317         else if (getFolderId() > bookmarksEntry.getFolderId()) {
318             value = 1;
319         }
320         else {
321             value = 0;
322         }
323 
324         if (value != 0) {
325             return value;
326         }
327 
328         value = getName().toLowerCase().compareTo(bookmarksEntry.getName()
329                                                                 .toLowerCase());
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         BookmarksEntryImpl bookmarksEntry = null;
344 
345         try {
346             bookmarksEntry = (BookmarksEntryImpl)obj;
347         }
348         catch (ClassCastException cce) {
349             return false;
350         }
351 
352         long pk = bookmarksEntry.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     private String _uuid;
367     private long _entryId;
368     private long _companyId;
369     private long _userId;
370     private Date _createDate;
371     private Date _modifiedDate;
372     private long _folderId;
373     private String _name;
374     private String _url;
375     private String _comments;
376     private int _visits;
377     private int _priority;
378 }