1
22
23 package com.liferay.portlet.documentlibrary.model.impl;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27 import com.liferay.portal.kernel.util.GetterUtil;
28 import com.liferay.portal.kernel.util.HtmlUtil;
29 import com.liferay.portal.kernel.util.StringBundler;
30 import com.liferay.portal.model.impl.BaseModelImpl;
31 import com.liferay.portal.service.ServiceContext;
32 import com.liferay.portal.util.PortalUtil;
33
34 import com.liferay.portlet.documentlibrary.model.DLFolder;
35 import com.liferay.portlet.documentlibrary.model.DLFolderSoap;
36 import com.liferay.portlet.expando.model.ExpandoBridge;
37 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
38
39 import java.io.Serializable;
40
41 import java.lang.reflect.Proxy;
42
43 import java.sql.Types;
44
45 import java.util.ArrayList;
46 import java.util.Date;
47 import java.util.List;
48
49
68 public class DLFolderModelImpl extends BaseModelImpl<DLFolder> {
69 public static final String TABLE_NAME = "DLFolder";
70 public static final Object[][] TABLE_COLUMNS = {
71 { "uuid_", new Integer(Types.VARCHAR) },
72 { "folderId", new Integer(Types.BIGINT) },
73 { "groupId", new Integer(Types.BIGINT) },
74 { "companyId", new Integer(Types.BIGINT) },
75 { "userId", new Integer(Types.BIGINT) },
76 { "userName", new Integer(Types.VARCHAR) },
77 { "createDate", new Integer(Types.TIMESTAMP) },
78 { "modifiedDate", new Integer(Types.TIMESTAMP) },
79 { "parentFolderId", new Integer(Types.BIGINT) },
80 { "name", new Integer(Types.VARCHAR) },
81 { "description", new Integer(Types.VARCHAR) },
82 { "lastPostDate", new Integer(Types.TIMESTAMP) }
83 };
84 public static final String TABLE_SQL_CREATE = "create table DLFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(100) null,description STRING null,lastPostDate DATE null)";
85 public static final String TABLE_SQL_DROP = "drop table DLFolder";
86 public static final String ORDER_BY_JPQL = " ORDER BY dlFolder.parentFolderId ASC, dlFolder.name ASC";
87 public static final String ORDER_BY_SQL = " ORDER BY DLFolder.parentFolderId ASC, DLFolder.name ASC";
88 public static final String DATA_SOURCE = "liferayDataSource";
89 public static final String SESSION_FACTORY = "liferaySessionFactory";
90 public static final String TX_MANAGER = "liferayTransactionManager";
91 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
93 true);
94 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
96 true);
97
98 public static DLFolder toModel(DLFolderSoap soapModel) {
99 DLFolder model = new DLFolderImpl();
100
101 model.setUuid(soapModel.getUuid());
102 model.setFolderId(soapModel.getFolderId());
103 model.setGroupId(soapModel.getGroupId());
104 model.setCompanyId(soapModel.getCompanyId());
105 model.setUserId(soapModel.getUserId());
106 model.setUserName(soapModel.getUserName());
107 model.setCreateDate(soapModel.getCreateDate());
108 model.setModifiedDate(soapModel.getModifiedDate());
109 model.setParentFolderId(soapModel.getParentFolderId());
110 model.setName(soapModel.getName());
111 model.setDescription(soapModel.getDescription());
112 model.setLastPostDate(soapModel.getLastPostDate());
113
114 return model;
115 }
116
117 public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
118 List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
119
120 for (DLFolderSoap soapModel : soapModels) {
121 models.add(toModel(soapModel));
122 }
123
124 return models;
125 }
126
127 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
129
130 public DLFolderModelImpl() {
131 }
132
133 public long getPrimaryKey() {
134 return _folderId;
135 }
136
137 public void setPrimaryKey(long pk) {
138 setFolderId(pk);
139 }
140
141 public Serializable getPrimaryKeyObj() {
142 return new Long(_folderId);
143 }
144
145 public String getUuid() {
146 return GetterUtil.getString(_uuid);
147 }
148
149 public void setUuid(String uuid) {
150 _uuid = uuid;
151
152 if (_originalUuid == null) {
153 _originalUuid = uuid;
154 }
155 }
156
157 public String getOriginalUuid() {
158 return GetterUtil.getString(_originalUuid);
159 }
160
161 public long getFolderId() {
162 return _folderId;
163 }
164
165 public void setFolderId(long folderId) {
166 _folderId = folderId;
167 }
168
169 public long getGroupId() {
170 return _groupId;
171 }
172
173 public void setGroupId(long groupId) {
174 _groupId = groupId;
175
176 if (!_setOriginalGroupId) {
177 _setOriginalGroupId = true;
178
179 _originalGroupId = groupId;
180 }
181 }
182
183 public long getOriginalGroupId() {
184 return _originalGroupId;
185 }
186
187 public long getCompanyId() {
188 return _companyId;
189 }
190
191 public void setCompanyId(long companyId) {
192 _companyId = companyId;
193 }
194
195 public long getUserId() {
196 return _userId;
197 }
198
199 public void setUserId(long userId) {
200 _userId = userId;
201 }
202
203 public String getUserUuid() throws SystemException {
204 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
205 }
206
207 public void setUserUuid(String userUuid) {
208 _userUuid = userUuid;
209 }
210
211 public String getUserName() {
212 return GetterUtil.getString(_userName);
213 }
214
215 public void setUserName(String userName) {
216 _userName = userName;
217 }
218
219 public Date getCreateDate() {
220 return _createDate;
221 }
222
223 public void setCreateDate(Date createDate) {
224 _createDate = createDate;
225 }
226
227 public Date getModifiedDate() {
228 return _modifiedDate;
229 }
230
231 public void setModifiedDate(Date modifiedDate) {
232 _modifiedDate = modifiedDate;
233 }
234
235 public long getParentFolderId() {
236 return _parentFolderId;
237 }
238
239 public void setParentFolderId(long parentFolderId) {
240 _parentFolderId = parentFolderId;
241
242 if (!_setOriginalParentFolderId) {
243 _setOriginalParentFolderId = true;
244
245 _originalParentFolderId = parentFolderId;
246 }
247 }
248
249 public long getOriginalParentFolderId() {
250 return _originalParentFolderId;
251 }
252
253 public String getName() {
254 return GetterUtil.getString(_name);
255 }
256
257 public void setName(String name) {
258 _name = name;
259
260 if (_originalName == null) {
261 _originalName = name;
262 }
263 }
264
265 public String getOriginalName() {
266 return GetterUtil.getString(_originalName);
267 }
268
269 public String getDescription() {
270 return GetterUtil.getString(_description);
271 }
272
273 public void setDescription(String description) {
274 _description = description;
275 }
276
277 public Date getLastPostDate() {
278 return _lastPostDate;
279 }
280
281 public void setLastPostDate(Date lastPostDate) {
282 _lastPostDate = lastPostDate;
283 }
284
285 public DLFolder toEscapedModel() {
286 if (isEscapedModel()) {
287 return (DLFolder)this;
288 }
289 else {
290 DLFolder model = new DLFolderImpl();
291
292 model.setNew(isNew());
293 model.setEscapedModel(true);
294
295 model.setUuid(HtmlUtil.escape(getUuid()));
296 model.setFolderId(getFolderId());
297 model.setGroupId(getGroupId());
298 model.setCompanyId(getCompanyId());
299 model.setUserId(getUserId());
300 model.setUserName(HtmlUtil.escape(getUserName()));
301 model.setCreateDate(getCreateDate());
302 model.setModifiedDate(getModifiedDate());
303 model.setParentFolderId(getParentFolderId());
304 model.setName(HtmlUtil.escape(getName()));
305 model.setDescription(HtmlUtil.escape(getDescription()));
306 model.setLastPostDate(getLastPostDate());
307
308 model = (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
309 new Class[] { DLFolder.class },
310 new ReadOnlyBeanHandler(model));
311
312 return model;
313 }
314 }
315
316 public ExpandoBridge getExpandoBridge() {
317 if (_expandoBridge == null) {
318 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(DLFolder.class.getName(),
319 getPrimaryKey());
320 }
321
322 return _expandoBridge;
323 }
324
325 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
326 getExpandoBridge().setAttributes(serviceContext);
327 }
328
329 public Object clone() {
330 DLFolderImpl clone = new DLFolderImpl();
331
332 clone.setUuid(getUuid());
333 clone.setFolderId(getFolderId());
334 clone.setGroupId(getGroupId());
335 clone.setCompanyId(getCompanyId());
336 clone.setUserId(getUserId());
337 clone.setUserName(getUserName());
338 clone.setCreateDate(getCreateDate());
339 clone.setModifiedDate(getModifiedDate());
340 clone.setParentFolderId(getParentFolderId());
341 clone.setName(getName());
342 clone.setDescription(getDescription());
343 clone.setLastPostDate(getLastPostDate());
344
345 return clone;
346 }
347
348 public int compareTo(DLFolder dlFolder) {
349 int value = 0;
350
351 if (getParentFolderId() < dlFolder.getParentFolderId()) {
352 value = -1;
353 }
354 else if (getParentFolderId() > dlFolder.getParentFolderId()) {
355 value = 1;
356 }
357 else {
358 value = 0;
359 }
360
361 if (value != 0) {
362 return value;
363 }
364
365 value = getName().toLowerCase()
366 .compareTo(dlFolder.getName().toLowerCase());
367
368 if (value != 0) {
369 return value;
370 }
371
372 return 0;
373 }
374
375 public boolean equals(Object obj) {
376 if (obj == null) {
377 return false;
378 }
379
380 DLFolder dlFolder = null;
381
382 try {
383 dlFolder = (DLFolder)obj;
384 }
385 catch (ClassCastException cce) {
386 return false;
387 }
388
389 long pk = dlFolder.getPrimaryKey();
390
391 if (getPrimaryKey() == pk) {
392 return true;
393 }
394 else {
395 return false;
396 }
397 }
398
399 public int hashCode() {
400 return (int)getPrimaryKey();
401 }
402
403 public String toString() {
404 StringBundler sb = new StringBundler(25);
405
406 sb.append("{uuid=");
407 sb.append(getUuid());
408 sb.append(", folderId=");
409 sb.append(getFolderId());
410 sb.append(", groupId=");
411 sb.append(getGroupId());
412 sb.append(", companyId=");
413 sb.append(getCompanyId());
414 sb.append(", userId=");
415 sb.append(getUserId());
416 sb.append(", userName=");
417 sb.append(getUserName());
418 sb.append(", createDate=");
419 sb.append(getCreateDate());
420 sb.append(", modifiedDate=");
421 sb.append(getModifiedDate());
422 sb.append(", parentFolderId=");
423 sb.append(getParentFolderId());
424 sb.append(", name=");
425 sb.append(getName());
426 sb.append(", description=");
427 sb.append(getDescription());
428 sb.append(", lastPostDate=");
429 sb.append(getLastPostDate());
430 sb.append("}");
431
432 return sb.toString();
433 }
434
435 public String toXmlString() {
436 StringBundler sb = new StringBundler(40);
437
438 sb.append("<model><model-name>");
439 sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
440 sb.append("</model-name>");
441
442 sb.append(
443 "<column><column-name>uuid</column-name><column-value><![CDATA[");
444 sb.append(getUuid());
445 sb.append("]]></column-value></column>");
446 sb.append(
447 "<column><column-name>folderId</column-name><column-value><![CDATA[");
448 sb.append(getFolderId());
449 sb.append("]]></column-value></column>");
450 sb.append(
451 "<column><column-name>groupId</column-name><column-value><![CDATA[");
452 sb.append(getGroupId());
453 sb.append("]]></column-value></column>");
454 sb.append(
455 "<column><column-name>companyId</column-name><column-value><![CDATA[");
456 sb.append(getCompanyId());
457 sb.append("]]></column-value></column>");
458 sb.append(
459 "<column><column-name>userId</column-name><column-value><![CDATA[");
460 sb.append(getUserId());
461 sb.append("]]></column-value></column>");
462 sb.append(
463 "<column><column-name>userName</column-name><column-value><![CDATA[");
464 sb.append(getUserName());
465 sb.append("]]></column-value></column>");
466 sb.append(
467 "<column><column-name>createDate</column-name><column-value><![CDATA[");
468 sb.append(getCreateDate());
469 sb.append("]]></column-value></column>");
470 sb.append(
471 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
472 sb.append(getModifiedDate());
473 sb.append("]]></column-value></column>");
474 sb.append(
475 "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
476 sb.append(getParentFolderId());
477 sb.append("]]></column-value></column>");
478 sb.append(
479 "<column><column-name>name</column-name><column-value><![CDATA[");
480 sb.append(getName());
481 sb.append("]]></column-value></column>");
482 sb.append(
483 "<column><column-name>description</column-name><column-value><![CDATA[");
484 sb.append(getDescription());
485 sb.append("]]></column-value></column>");
486 sb.append(
487 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
488 sb.append(getLastPostDate());
489 sb.append("]]></column-value></column>");
490
491 sb.append("</model>");
492
493 return sb.toString();
494 }
495
496 private String _uuid;
497 private String _originalUuid;
498 private long _folderId;
499 private long _groupId;
500 private long _originalGroupId;
501 private boolean _setOriginalGroupId;
502 private long _companyId;
503 private long _userId;
504 private String _userUuid;
505 private String _userName;
506 private Date _createDate;
507 private Date _modifiedDate;
508 private long _parentFolderId;
509 private long _originalParentFolderId;
510 private boolean _setOriginalParentFolderId;
511 private String _name;
512 private String _originalName;
513 private String _description;
514 private Date _lastPostDate;
515 private transient ExpandoBridge _expandoBridge;
516 }