1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.bookmarks.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.bookmarks.model.BookmarksFolder;
28  import com.liferay.portlet.bookmarks.model.BookmarksFolderSoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="BookmarksFolderModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>BookmarksFolder</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.bookmarks.model.BookmarksFolder
56   * @see com.liferay.portlet.bookmarks.model.BookmarksFolderModel
57   * @see com.liferay.portlet.bookmarks.model.impl.BookmarksFolderImpl
58   *
59   */
60  public class BookmarksFolderModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "BookmarksFolder";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "uuid_", new Integer(Types.VARCHAR) },
64              
65  
66              { "folderId", new Integer(Types.BIGINT) },
67              
68  
69              { "groupId", new Integer(Types.BIGINT) },
70              
71  
72              { "companyId", new Integer(Types.BIGINT) },
73              
74  
75              { "userId", new Integer(Types.BIGINT) },
76              
77  
78              { "createDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "modifiedDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "parentFolderId", new Integer(Types.BIGINT) },
85              
86  
87              { "name", new Integer(Types.VARCHAR) },
88              
89  
90              { "description", new Integer(Types.VARCHAR) }
91          };
92      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)";
93      public static final String TABLE_SQL_DROP = "drop table BookmarksFolder";
94      public static final String DATA_SOURCE = "liferayDataSource";
95      public static final String SESSION_FACTORY = "liferaySessionFactory";
96      public static final String TX_MANAGER = "liferayTransactionManager";
97      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
99              true);
100 
101     public static BookmarksFolder toModel(BookmarksFolderSoap soapModel) {
102         BookmarksFolder model = new BookmarksFolderImpl();
103 
104         model.setUuid(soapModel.getUuid());
105         model.setFolderId(soapModel.getFolderId());
106         model.setGroupId(soapModel.getGroupId());
107         model.setCompanyId(soapModel.getCompanyId());
108         model.setUserId(soapModel.getUserId());
109         model.setCreateDate(soapModel.getCreateDate());
110         model.setModifiedDate(soapModel.getModifiedDate());
111         model.setParentFolderId(soapModel.getParentFolderId());
112         model.setName(soapModel.getName());
113         model.setDescription(soapModel.getDescription());
114 
115         return model;
116     }
117 
118     public static List<BookmarksFolder> toModels(
119         BookmarksFolderSoap[] soapModels) {
120         List<BookmarksFolder> models = new ArrayList<BookmarksFolder>(soapModels.length);
121 
122         for (BookmarksFolderSoap soapModel : soapModels) {
123             models.add(toModel(soapModel));
124         }
125 
126         return models;
127     }
128 
129     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                 "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksFolder"));
131 
132     public BookmarksFolderModelImpl() {
133     }
134 
135     public long getPrimaryKey() {
136         return _folderId;
137     }
138 
139     public void setPrimaryKey(long pk) {
140         setFolderId(pk);
141     }
142 
143     public Serializable getPrimaryKeyObj() {
144         return new Long(_folderId);
145     }
146 
147     public String getUuid() {
148         return GetterUtil.getString(_uuid);
149     }
150 
151     public void setUuid(String uuid) {
152         if ((uuid != null) && (uuid != _uuid)) {
153             _uuid = uuid;
154         }
155     }
156 
157     public long getFolderId() {
158         return _folderId;
159     }
160 
161     public void setFolderId(long folderId) {
162         if (folderId != _folderId) {
163             _folderId = folderId;
164         }
165     }
166 
167     public long getGroupId() {
168         return _groupId;
169     }
170 
171     public void setGroupId(long groupId) {
172         if (groupId != _groupId) {
173             _groupId = groupId;
174         }
175     }
176 
177     public long getCompanyId() {
178         return _companyId;
179     }
180 
181     public void setCompanyId(long companyId) {
182         if (companyId != _companyId) {
183             _companyId = companyId;
184         }
185     }
186 
187     public long getUserId() {
188         return _userId;
189     }
190 
191     public void setUserId(long userId) {
192         if (userId != _userId) {
193             _userId = userId;
194         }
195     }
196 
197     public Date getCreateDate() {
198         return _createDate;
199     }
200 
201     public void setCreateDate(Date createDate) {
202         if (((createDate == null) && (_createDate != null)) ||
203                 ((createDate != null) && (_createDate == null)) ||
204                 ((createDate != null) && (_createDate != null) &&
205                 !createDate.equals(_createDate))) {
206             _createDate = createDate;
207         }
208     }
209 
210     public Date getModifiedDate() {
211         return _modifiedDate;
212     }
213 
214     public void setModifiedDate(Date modifiedDate) {
215         if (((modifiedDate == null) && (_modifiedDate != null)) ||
216                 ((modifiedDate != null) && (_modifiedDate == null)) ||
217                 ((modifiedDate != null) && (_modifiedDate != null) &&
218                 !modifiedDate.equals(_modifiedDate))) {
219             _modifiedDate = modifiedDate;
220         }
221     }
222 
223     public long getParentFolderId() {
224         return _parentFolderId;
225     }
226 
227     public void setParentFolderId(long parentFolderId) {
228         if (parentFolderId != _parentFolderId) {
229             _parentFolderId = parentFolderId;
230         }
231     }
232 
233     public String getName() {
234         return GetterUtil.getString(_name);
235     }
236 
237     public void setName(String name) {
238         if (((name == null) && (_name != null)) ||
239                 ((name != null) && (_name == null)) ||
240                 ((name != null) && (_name != null) && !name.equals(_name))) {
241             _name = name;
242         }
243     }
244 
245     public String getDescription() {
246         return GetterUtil.getString(_description);
247     }
248 
249     public void setDescription(String description) {
250         if (((description == null) && (_description != null)) ||
251                 ((description != null) && (_description == null)) ||
252                 ((description != null) && (_description != null) &&
253                 !description.equals(_description))) {
254             _description = description;
255         }
256     }
257 
258     public BookmarksFolder toEscapedModel() {
259         if (isEscapedModel()) {
260             return (BookmarksFolder)this;
261         }
262         else {
263             BookmarksFolder model = new BookmarksFolderImpl();
264 
265             model.setNew(isNew());
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 }