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