001
014
015 package com.liferay.portlet.bookmarks.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.impl.BaseModelImpl;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portal.util.PortalUtil;
025
026 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
027 import com.liferay.portlet.bookmarks.model.BookmarksEntryModel;
028 import com.liferay.portlet.bookmarks.model.BookmarksEntrySoap;
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031
032 import java.io.Serializable;
033
034 import java.lang.reflect.Proxy;
035
036 import java.sql.Types;
037
038 import java.util.ArrayList;
039 import java.util.Date;
040 import java.util.List;
041
042
059 public class BookmarksEntryModelImpl extends BaseModelImpl<BookmarksEntry>
060 implements BookmarksEntryModel {
061 public static final String TABLE_NAME = "BookmarksEntry";
062 public static final Object[][] TABLE_COLUMNS = {
063 { "uuid_", new Integer(Types.VARCHAR) },
064 { "entryId", new Integer(Types.BIGINT) },
065 { "groupId", new Integer(Types.BIGINT) },
066 { "companyId", new Integer(Types.BIGINT) },
067 { "userId", new Integer(Types.BIGINT) },
068 { "createDate", new Integer(Types.TIMESTAMP) },
069 { "modifiedDate", new Integer(Types.TIMESTAMP) },
070 { "folderId", new Integer(Types.BIGINT) },
071 { "name", new Integer(Types.VARCHAR) },
072 { "url", new Integer(Types.VARCHAR) },
073 { "comments", new Integer(Types.VARCHAR) },
074 { "visits", new Integer(Types.INTEGER) },
075 { "priority", new Integer(Types.INTEGER) }
076 };
077 public static final String TABLE_SQL_CREATE = "create table BookmarksEntry (uuid_ VARCHAR(75) null,entryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,folderId LONG,name VARCHAR(255) null,url STRING null,comments STRING null,visits INTEGER,priority INTEGER)";
078 public static final String TABLE_SQL_DROP = "drop table BookmarksEntry";
079 public static final String ORDER_BY_JPQL = " ORDER BY bookmarksEntry.folderId ASC, bookmarksEntry.name ASC";
080 public static final String ORDER_BY_SQL = " ORDER BY BookmarksEntry.folderId ASC, BookmarksEntry.name ASC";
081 public static final String DATA_SOURCE = "liferayDataSource";
082 public static final String SESSION_FACTORY = "liferaySessionFactory";
083 public static final String TX_MANAGER = "liferayTransactionManager";
084 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.entity.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksEntry"),
086 true);
087 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088 "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksEntry"),
089 true);
090
091
097 public static BookmarksEntry toModel(BookmarksEntrySoap soapModel) {
098 BookmarksEntry model = new BookmarksEntryImpl();
099
100 model.setUuid(soapModel.getUuid());
101 model.setEntryId(soapModel.getEntryId());
102 model.setGroupId(soapModel.getGroupId());
103 model.setCompanyId(soapModel.getCompanyId());
104 model.setUserId(soapModel.getUserId());
105 model.setCreateDate(soapModel.getCreateDate());
106 model.setModifiedDate(soapModel.getModifiedDate());
107 model.setFolderId(soapModel.getFolderId());
108 model.setName(soapModel.getName());
109 model.setUrl(soapModel.getUrl());
110 model.setComments(soapModel.getComments());
111 model.setVisits(soapModel.getVisits());
112 model.setPriority(soapModel.getPriority());
113
114 return model;
115 }
116
117
123 public static List<BookmarksEntry> toModels(BookmarksEntrySoap[] soapModels) {
124 List<BookmarksEntry> models = new ArrayList<BookmarksEntry>(soapModels.length);
125
126 for (BookmarksEntrySoap soapModel : soapModels) {
127 models.add(toModel(soapModel));
128 }
129
130 return models;
131 }
132
133 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134 "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksEntry"));
135
136 public BookmarksEntryModelImpl() {
137 }
138
139 public long getPrimaryKey() {
140 return _entryId;
141 }
142
143 public void setPrimaryKey(long pk) {
144 setEntryId(pk);
145 }
146
147 public Serializable getPrimaryKeyObj() {
148 return new Long(_entryId);
149 }
150
151 public String getUuid() {
152 if (_uuid == null) {
153 return StringPool.BLANK;
154 }
155 else {
156 return _uuid;
157 }
158 }
159
160 public void setUuid(String uuid) {
161 _uuid = uuid;
162
163 if (_originalUuid == null) {
164 _originalUuid = uuid;
165 }
166 }
167
168 public String getOriginalUuid() {
169 return GetterUtil.getString(_originalUuid);
170 }
171
172 public long getEntryId() {
173 return _entryId;
174 }
175
176 public void setEntryId(long entryId) {
177 _entryId = entryId;
178 }
179
180 public long getGroupId() {
181 return _groupId;
182 }
183
184 public void setGroupId(long groupId) {
185 _groupId = groupId;
186
187 if (!_setOriginalGroupId) {
188 _setOriginalGroupId = true;
189
190 _originalGroupId = groupId;
191 }
192 }
193
194 public long getOriginalGroupId() {
195 return _originalGroupId;
196 }
197
198 public long getCompanyId() {
199 return _companyId;
200 }
201
202 public void setCompanyId(long companyId) {
203 _companyId = companyId;
204 }
205
206 public long getUserId() {
207 return _userId;
208 }
209
210 public void setUserId(long userId) {
211 _userId = userId;
212 }
213
214 public String getUserUuid() throws SystemException {
215 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
216 }
217
218 public void setUserUuid(String userUuid) {
219 _userUuid = userUuid;
220 }
221
222 public Date getCreateDate() {
223 return _createDate;
224 }
225
226 public void setCreateDate(Date createDate) {
227 _createDate = createDate;
228 }
229
230 public Date getModifiedDate() {
231 return _modifiedDate;
232 }
233
234 public void setModifiedDate(Date modifiedDate) {
235 _modifiedDate = modifiedDate;
236 }
237
238 public long getFolderId() {
239 return _folderId;
240 }
241
242 public void setFolderId(long folderId) {
243 _folderId = folderId;
244 }
245
246 public String getName() {
247 if (_name == null) {
248 return StringPool.BLANK;
249 }
250 else {
251 return _name;
252 }
253 }
254
255 public void setName(String name) {
256 _name = name;
257 }
258
259 public String getUrl() {
260 if (_url == null) {
261 return StringPool.BLANK;
262 }
263 else {
264 return _url;
265 }
266 }
267
268 public void setUrl(String url) {
269 _url = url;
270 }
271
272 public String getComments() {
273 if (_comments == null) {
274 return StringPool.BLANK;
275 }
276 else {
277 return _comments;
278 }
279 }
280
281 public void setComments(String comments) {
282 _comments = comments;
283 }
284
285 public int getVisits() {
286 return _visits;
287 }
288
289 public void setVisits(int visits) {
290 _visits = visits;
291 }
292
293 public int getPriority() {
294 return _priority;
295 }
296
297 public void setPriority(int priority) {
298 _priority = priority;
299 }
300
301 public BookmarksEntry toEscapedModel() {
302 if (isEscapedModel()) {
303 return (BookmarksEntry)this;
304 }
305 else {
306 return (BookmarksEntry)Proxy.newProxyInstance(BookmarksEntry.class.getClassLoader(),
307 new Class[] { BookmarksEntry.class },
308 new AutoEscapeBeanHandler(this));
309 }
310 }
311
312 public ExpandoBridge getExpandoBridge() {
313 if (_expandoBridge == null) {
314 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
315 BookmarksEntry.class.getName(), getPrimaryKey());
316 }
317
318 return _expandoBridge;
319 }
320
321 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
322 getExpandoBridge().setAttributes(serviceContext);
323 }
324
325 public Object clone() {
326 BookmarksEntryImpl clone = new BookmarksEntryImpl();
327
328 clone.setUuid(getUuid());
329 clone.setEntryId(getEntryId());
330 clone.setGroupId(getGroupId());
331 clone.setCompanyId(getCompanyId());
332 clone.setUserId(getUserId());
333 clone.setCreateDate(getCreateDate());
334 clone.setModifiedDate(getModifiedDate());
335 clone.setFolderId(getFolderId());
336 clone.setName(getName());
337 clone.setUrl(getUrl());
338 clone.setComments(getComments());
339 clone.setVisits(getVisits());
340 clone.setPriority(getPriority());
341
342 return clone;
343 }
344
345 public int compareTo(BookmarksEntry bookmarksEntry) {
346 int value = 0;
347
348 if (getFolderId() < bookmarksEntry.getFolderId()) {
349 value = -1;
350 }
351 else if (getFolderId() > bookmarksEntry.getFolderId()) {
352 value = 1;
353 }
354 else {
355 value = 0;
356 }
357
358 if (value != 0) {
359 return value;
360 }
361
362 value = getName().toLowerCase()
363 .compareTo(bookmarksEntry.getName().toLowerCase());
364
365 if (value != 0) {
366 return value;
367 }
368
369 return 0;
370 }
371
372 public boolean equals(Object obj) {
373 if (obj == null) {
374 return false;
375 }
376
377 BookmarksEntry bookmarksEntry = null;
378
379 try {
380 bookmarksEntry = (BookmarksEntry)obj;
381 }
382 catch (ClassCastException cce) {
383 return false;
384 }
385
386 long pk = bookmarksEntry.getPrimaryKey();
387
388 if (getPrimaryKey() == pk) {
389 return true;
390 }
391 else {
392 return false;
393 }
394 }
395
396 public int hashCode() {
397 return (int)getPrimaryKey();
398 }
399
400 public String toString() {
401 StringBundler sb = new StringBundler(27);
402
403 sb.append("{uuid=");
404 sb.append(getUuid());
405 sb.append(", entryId=");
406 sb.append(getEntryId());
407 sb.append(", groupId=");
408 sb.append(getGroupId());
409 sb.append(", companyId=");
410 sb.append(getCompanyId());
411 sb.append(", userId=");
412 sb.append(getUserId());
413 sb.append(", createDate=");
414 sb.append(getCreateDate());
415 sb.append(", modifiedDate=");
416 sb.append(getModifiedDate());
417 sb.append(", folderId=");
418 sb.append(getFolderId());
419 sb.append(", name=");
420 sb.append(getName());
421 sb.append(", url=");
422 sb.append(getUrl());
423 sb.append(", comments=");
424 sb.append(getComments());
425 sb.append(", visits=");
426 sb.append(getVisits());
427 sb.append(", priority=");
428 sb.append(getPriority());
429 sb.append("}");
430
431 return sb.toString();
432 }
433
434 public String toXmlString() {
435 StringBundler sb = new StringBundler(43);
436
437 sb.append("<model><model-name>");
438 sb.append("com.liferay.portlet.bookmarks.model.BookmarksEntry");
439 sb.append("</model-name>");
440
441 sb.append(
442 "<column><column-name>uuid</column-name><column-value><![CDATA[");
443 sb.append(getUuid());
444 sb.append("]]></column-value></column>");
445 sb.append(
446 "<column><column-name>entryId</column-name><column-value><![CDATA[");
447 sb.append(getEntryId());
448 sb.append("]]></column-value></column>");
449 sb.append(
450 "<column><column-name>groupId</column-name><column-value><![CDATA[");
451 sb.append(getGroupId());
452 sb.append("]]></column-value></column>");
453 sb.append(
454 "<column><column-name>companyId</column-name><column-value><![CDATA[");
455 sb.append(getCompanyId());
456 sb.append("]]></column-value></column>");
457 sb.append(
458 "<column><column-name>userId</column-name><column-value><![CDATA[");
459 sb.append(getUserId());
460 sb.append("]]></column-value></column>");
461 sb.append(
462 "<column><column-name>createDate</column-name><column-value><![CDATA[");
463 sb.append(getCreateDate());
464 sb.append("]]></column-value></column>");
465 sb.append(
466 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
467 sb.append(getModifiedDate());
468 sb.append("]]></column-value></column>");
469 sb.append(
470 "<column><column-name>folderId</column-name><column-value><![CDATA[");
471 sb.append(getFolderId());
472 sb.append("]]></column-value></column>");
473 sb.append(
474 "<column><column-name>name</column-name><column-value><![CDATA[");
475 sb.append(getName());
476 sb.append("]]></column-value></column>");
477 sb.append(
478 "<column><column-name>url</column-name><column-value><![CDATA[");
479 sb.append(getUrl());
480 sb.append("]]></column-value></column>");
481 sb.append(
482 "<column><column-name>comments</column-name><column-value><![CDATA[");
483 sb.append(getComments());
484 sb.append("]]></column-value></column>");
485 sb.append(
486 "<column><column-name>visits</column-name><column-value><![CDATA[");
487 sb.append(getVisits());
488 sb.append("]]></column-value></column>");
489 sb.append(
490 "<column><column-name>priority</column-name><column-value><![CDATA[");
491 sb.append(getPriority());
492 sb.append("]]></column-value></column>");
493
494 sb.append("</model>");
495
496 return sb.toString();
497 }
498
499 private String _uuid;
500 private String _originalUuid;
501 private long _entryId;
502 private long _groupId;
503 private long _originalGroupId;
504 private boolean _setOriginalGroupId;
505 private long _companyId;
506 private long _userId;
507 private String _userUuid;
508 private Date _createDate;
509 private Date _modifiedDate;
510 private long _folderId;
511 private String _name;
512 private String _url;
513 private String _comments;
514 private int _visits;
515 private int _priority;
516 private transient ExpandoBridge _expandoBridge;
517 }