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