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.BookmarksFolder;
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="BookmarksFolderModelImpl.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>BookmarksFolder</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.bookmarks.service.model.BookmarksFolder
58   * @see com.liferay.portlet.bookmarks.service.model.BookmarksFolderModel
59   * @see com.liferay.portlet.bookmarks.service.model.impl.BookmarksFolderImpl
60   *
61   */
62  public class BookmarksFolderModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "BookmarksFolder";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "folderId", new Integer(Types.BIGINT) },
69              
70  
71              { "groupId", new Integer(Types.BIGINT) },
72              
73  
74              { "companyId", new Integer(Types.BIGINT) },
75              
76  
77              { "userId", new Integer(Types.BIGINT) },
78              
79  
80              { "createDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "modifiedDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "parentFolderId", new Integer(Types.BIGINT) },
87              
88  
89              { "name", new Integer(Types.VARCHAR) },
90              
91  
92              { "description", new Integer(Types.VARCHAR) }
93          };
94      public static final String TABLE_SQL_CREATE = "create table BookmarksFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
95      public static final String TABLE_SQL_DROP = "drop table BookmarksFolder";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
98              true);
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksFolder"));
101 
102     public BookmarksFolderModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _folderId;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setFolderId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_folderId);
115     }
116 
117     public String getUuid() {
118         return GetterUtil.getString(_uuid);
119     }
120 
121     public void setUuid(String uuid) {
122         if ((uuid != null) && (uuid != _uuid)) {
123             _uuid = uuid;
124         }
125     }
126 
127     public long getFolderId() {
128         return _folderId;
129     }
130 
131     public void setFolderId(long folderId) {
132         if (folderId != _folderId) {
133             _folderId = folderId;
134         }
135     }
136 
137     public long getGroupId() {
138         return _groupId;
139     }
140 
141     public void setGroupId(long groupId) {
142         if (groupId != _groupId) {
143             _groupId = groupId;
144         }
145     }
146 
147     public long getCompanyId() {
148         return _companyId;
149     }
150 
151     public void setCompanyId(long companyId) {
152         if (companyId != _companyId) {
153             _companyId = companyId;
154         }
155     }
156 
157     public long getUserId() {
158         return _userId;
159     }
160 
161     public void setUserId(long userId) {
162         if (userId != _userId) {
163             _userId = userId;
164         }
165     }
166 
167     public Date getCreateDate() {
168         return _createDate;
169     }
170 
171     public void setCreateDate(Date createDate) {
172         if (((createDate == null) && (_createDate != null)) ||
173                 ((createDate != null) && (_createDate == null)) ||
174                 ((createDate != null) && (_createDate != null) &&
175                 !createDate.equals(_createDate))) {
176             _createDate = createDate;
177         }
178     }
179 
180     public Date getModifiedDate() {
181         return _modifiedDate;
182     }
183 
184     public void setModifiedDate(Date modifiedDate) {
185         if (((modifiedDate == null) && (_modifiedDate != null)) ||
186                 ((modifiedDate != null) && (_modifiedDate == null)) ||
187                 ((modifiedDate != null) && (_modifiedDate != null) &&
188                 !modifiedDate.equals(_modifiedDate))) {
189             _modifiedDate = modifiedDate;
190         }
191     }
192 
193     public long getParentFolderId() {
194         return _parentFolderId;
195     }
196 
197     public void setParentFolderId(long parentFolderId) {
198         if (parentFolderId != _parentFolderId) {
199             _parentFolderId = parentFolderId;
200         }
201     }
202 
203     public String getName() {
204         return GetterUtil.getString(_name);
205     }
206 
207     public void setName(String name) {
208         if (((name == null) && (_name != null)) ||
209                 ((name != null) && (_name == null)) ||
210                 ((name != null) && (_name != null) && !name.equals(_name))) {
211             _name = name;
212         }
213     }
214 
215     public String getDescription() {
216         return GetterUtil.getString(_description);
217     }
218 
219     public void setDescription(String description) {
220         if (((description == null) && (_description != null)) ||
221                 ((description != null) && (_description == null)) ||
222                 ((description != null) && (_description != null) &&
223                 !description.equals(_description))) {
224             _description = description;
225         }
226     }
227 
228     public BookmarksFolder toEscapedModel() {
229         if (isEscapedModel()) {
230             return (BookmarksFolder)this;
231         }
232         else {
233             BookmarksFolder model = new BookmarksFolderImpl();
234 
235             model.setEscapedModel(true);
236 
237             model.setUuid(Html.escape(getUuid()));
238             model.setFolderId(getFolderId());
239             model.setGroupId(getGroupId());
240             model.setCompanyId(getCompanyId());
241             model.setUserId(getUserId());
242             model.setCreateDate(getCreateDate());
243             model.setModifiedDate(getModifiedDate());
244             model.setParentFolderId(getParentFolderId());
245             model.setName(Html.escape(getName()));
246             model.setDescription(Html.escape(getDescription()));
247 
248             model = (BookmarksFolder)Proxy.newProxyInstance(BookmarksFolder.class.getClassLoader(),
249                     new Class[] { BookmarksFolder.class },
250                     new ReadOnlyBeanHandler(model));
251 
252             return model;
253         }
254     }
255 
256     public Object clone() {
257         BookmarksFolderImpl clone = new BookmarksFolderImpl();
258 
259         clone.setUuid(getUuid());
260         clone.setFolderId(getFolderId());
261         clone.setGroupId(getGroupId());
262         clone.setCompanyId(getCompanyId());
263         clone.setUserId(getUserId());
264         clone.setCreateDate(getCreateDate());
265         clone.setModifiedDate(getModifiedDate());
266         clone.setParentFolderId(getParentFolderId());
267         clone.setName(getName());
268         clone.setDescription(getDescription());
269 
270         return clone;
271     }
272 
273     public int compareTo(Object obj) {
274         if (obj == null) {
275             return -1;
276         }
277 
278         BookmarksFolderImpl bookmarksFolder = (BookmarksFolderImpl)obj;
279 
280         int value = 0;
281 
282         if (getParentFolderId() < bookmarksFolder.getParentFolderId()) {
283             value = -1;
284         }
285         else if (getParentFolderId() > bookmarksFolder.getParentFolderId()) {
286             value = 1;
287         }
288         else {
289             value = 0;
290         }
291 
292         if (value != 0) {
293             return value;
294         }
295 
296         value = getName().toLowerCase().compareTo(bookmarksFolder.getName()
297                                                                  .toLowerCase());
298 
299         if (value != 0) {
300             return value;
301         }
302 
303         return 0;
304     }
305 
306     public boolean equals(Object obj) {
307         if (obj == null) {
308             return false;
309         }
310 
311         BookmarksFolderImpl bookmarksFolder = null;
312 
313         try {
314             bookmarksFolder = (BookmarksFolderImpl)obj;
315         }
316         catch (ClassCastException cce) {
317             return false;
318         }
319 
320         long pk = bookmarksFolder.getPrimaryKey();
321 
322         if (getPrimaryKey() == pk) {
323             return true;
324         }
325         else {
326             return false;
327         }
328     }
329 
330     public int hashCode() {
331         return (int)getPrimaryKey();
332     }
333 
334     private String _uuid;
335     private long _folderId;
336     private long _groupId;
337     private long _companyId;
338     private long _userId;
339     private Date _createDate;
340     private Date _modifiedDate;
341     private long _parentFolderId;
342     private String _name;
343     private String _description;
344 }