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