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