1
14
15 package com.liferay.portlet.documentlibrary.model.impl;
16
17 import com.liferay.portal.SystemException;
18 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
19 import com.liferay.portal.kernel.util.GetterUtil;
20 import com.liferay.portal.kernel.util.StringBundler;
21 import com.liferay.portal.kernel.util.StringPool;
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 if (_uuid == null) {
139 return StringPool.BLANK;
140 }
141 else {
142 return _uuid;
143 }
144 }
145
146 public void setUuid(String uuid) {
147 _uuid = uuid;
148
149 if (_originalUuid == null) {
150 _originalUuid = uuid;
151 }
152 }
153
154 public String getOriginalUuid() {
155 return GetterUtil.getString(_originalUuid);
156 }
157
158 public long getFolderId() {
159 return _folderId;
160 }
161
162 public void setFolderId(long folderId) {
163 _folderId = folderId;
164 }
165
166 public long getGroupId() {
167 return _groupId;
168 }
169
170 public void setGroupId(long groupId) {
171 _groupId = groupId;
172
173 if (!_setOriginalGroupId) {
174 _setOriginalGroupId = true;
175
176 _originalGroupId = groupId;
177 }
178 }
179
180 public long getOriginalGroupId() {
181 return _originalGroupId;
182 }
183
184 public long getCompanyId() {
185 return _companyId;
186 }
187
188 public void setCompanyId(long companyId) {
189 _companyId = companyId;
190 }
191
192 public long getUserId() {
193 return _userId;
194 }
195
196 public void setUserId(long userId) {
197 _userId = userId;
198 }
199
200 public String getUserUuid() throws SystemException {
201 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
202 }
203
204 public void setUserUuid(String userUuid) {
205 _userUuid = userUuid;
206 }
207
208 public String getUserName() {
209 if (_userName == null) {
210 return StringPool.BLANK;
211 }
212 else {
213 return _userName;
214 }
215 }
216
217 public void setUserName(String userName) {
218 _userName = userName;
219 }
220
221 public Date getCreateDate() {
222 return _createDate;
223 }
224
225 public void setCreateDate(Date createDate) {
226 _createDate = createDate;
227 }
228
229 public Date getModifiedDate() {
230 return _modifiedDate;
231 }
232
233 public void setModifiedDate(Date modifiedDate) {
234 _modifiedDate = modifiedDate;
235 }
236
237 public long getParentFolderId() {
238 return _parentFolderId;
239 }
240
241 public void setParentFolderId(long parentFolderId) {
242 _parentFolderId = parentFolderId;
243
244 if (!_setOriginalParentFolderId) {
245 _setOriginalParentFolderId = true;
246
247 _originalParentFolderId = parentFolderId;
248 }
249 }
250
251 public long getOriginalParentFolderId() {
252 return _originalParentFolderId;
253 }
254
255 public String getName() {
256 if (_name == null) {
257 return StringPool.BLANK;
258 }
259 else {
260 return _name;
261 }
262 }
263
264 public void setName(String name) {
265 _name = name;
266
267 if (_originalName == null) {
268 _originalName = name;
269 }
270 }
271
272 public String getOriginalName() {
273 return GetterUtil.getString(_originalName);
274 }
275
276 public String getDescription() {
277 if (_description == null) {
278 return StringPool.BLANK;
279 }
280 else {
281 return _description;
282 }
283 }
284
285 public void setDescription(String description) {
286 _description = description;
287 }
288
289 public Date getLastPostDate() {
290 return _lastPostDate;
291 }
292
293 public void setLastPostDate(Date lastPostDate) {
294 _lastPostDate = lastPostDate;
295 }
296
297 public DLFolder toEscapedModel() {
298 if (isEscapedModel()) {
299 return (DLFolder)this;
300 }
301 else {
302 return (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
303 new Class[] { DLFolder.class }, new AutoEscapeBeanHandler(this));
304 }
305 }
306
307 public ExpandoBridge getExpandoBridge() {
308 if (_expandoBridge == null) {
309 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(DLFolder.class.getName(),
310 getPrimaryKey());
311 }
312
313 return _expandoBridge;
314 }
315
316 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
317 getExpandoBridge().setAttributes(serviceContext);
318 }
319
320 public Object clone() {
321 DLFolderImpl clone = new DLFolderImpl();
322
323 clone.setUuid(getUuid());
324 clone.setFolderId(getFolderId());
325 clone.setGroupId(getGroupId());
326 clone.setCompanyId(getCompanyId());
327 clone.setUserId(getUserId());
328 clone.setUserName(getUserName());
329 clone.setCreateDate(getCreateDate());
330 clone.setModifiedDate(getModifiedDate());
331 clone.setParentFolderId(getParentFolderId());
332 clone.setName(getName());
333 clone.setDescription(getDescription());
334 clone.setLastPostDate(getLastPostDate());
335
336 return clone;
337 }
338
339 public int compareTo(DLFolder dlFolder) {
340 int value = 0;
341
342 if (getParentFolderId() < dlFolder.getParentFolderId()) {
343 value = -1;
344 }
345 else if (getParentFolderId() > dlFolder.getParentFolderId()) {
346 value = 1;
347 }
348 else {
349 value = 0;
350 }
351
352 if (value != 0) {
353 return value;
354 }
355
356 value = getName().toLowerCase()
357 .compareTo(dlFolder.getName().toLowerCase());
358
359 if (value != 0) {
360 return value;
361 }
362
363 return 0;
364 }
365
366 public boolean equals(Object obj) {
367 if (obj == null) {
368 return false;
369 }
370
371 DLFolder dlFolder = null;
372
373 try {
374 dlFolder = (DLFolder)obj;
375 }
376 catch (ClassCastException cce) {
377 return false;
378 }
379
380 long pk = dlFolder.getPrimaryKey();
381
382 if (getPrimaryKey() == pk) {
383 return true;
384 }
385 else {
386 return false;
387 }
388 }
389
390 public int hashCode() {
391 return (int)getPrimaryKey();
392 }
393
394 public String toString() {
395 StringBundler sb = new StringBundler(25);
396
397 sb.append("{uuid=");
398 sb.append(getUuid());
399 sb.append(", folderId=");
400 sb.append(getFolderId());
401 sb.append(", groupId=");
402 sb.append(getGroupId());
403 sb.append(", companyId=");
404 sb.append(getCompanyId());
405 sb.append(", userId=");
406 sb.append(getUserId());
407 sb.append(", userName=");
408 sb.append(getUserName());
409 sb.append(", createDate=");
410 sb.append(getCreateDate());
411 sb.append(", modifiedDate=");
412 sb.append(getModifiedDate());
413 sb.append(", parentFolderId=");
414 sb.append(getParentFolderId());
415 sb.append(", name=");
416 sb.append(getName());
417 sb.append(", description=");
418 sb.append(getDescription());
419 sb.append(", lastPostDate=");
420 sb.append(getLastPostDate());
421 sb.append("}");
422
423 return sb.toString();
424 }
425
426 public String toXmlString() {
427 StringBundler sb = new StringBundler(40);
428
429 sb.append("<model><model-name>");
430 sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
431 sb.append("</model-name>");
432
433 sb.append(
434 "<column><column-name>uuid</column-name><column-value><![CDATA[");
435 sb.append(getUuid());
436 sb.append("]]></column-value></column>");
437 sb.append(
438 "<column><column-name>folderId</column-name><column-value><![CDATA[");
439 sb.append(getFolderId());
440 sb.append("]]></column-value></column>");
441 sb.append(
442 "<column><column-name>groupId</column-name><column-value><![CDATA[");
443 sb.append(getGroupId());
444 sb.append("]]></column-value></column>");
445 sb.append(
446 "<column><column-name>companyId</column-name><column-value><![CDATA[");
447 sb.append(getCompanyId());
448 sb.append("]]></column-value></column>");
449 sb.append(
450 "<column><column-name>userId</column-name><column-value><![CDATA[");
451 sb.append(getUserId());
452 sb.append("]]></column-value></column>");
453 sb.append(
454 "<column><column-name>userName</column-name><column-value><![CDATA[");
455 sb.append(getUserName());
456 sb.append("]]></column-value></column>");
457 sb.append(
458 "<column><column-name>createDate</column-name><column-value><![CDATA[");
459 sb.append(getCreateDate());
460 sb.append("]]></column-value></column>");
461 sb.append(
462 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
463 sb.append(getModifiedDate());
464 sb.append("]]></column-value></column>");
465 sb.append(
466 "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
467 sb.append(getParentFolderId());
468 sb.append("]]></column-value></column>");
469 sb.append(
470 "<column><column-name>name</column-name><column-value><![CDATA[");
471 sb.append(getName());
472 sb.append("]]></column-value></column>");
473 sb.append(
474 "<column><column-name>description</column-name><column-value><![CDATA[");
475 sb.append(getDescription());
476 sb.append("]]></column-value></column>");
477 sb.append(
478 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
479 sb.append(getLastPostDate());
480 sb.append("]]></column-value></column>");
481
482 sb.append("</model>");
483
484 return sb.toString();
485 }
486
487 private String _uuid;
488 private String _originalUuid;
489 private long _folderId;
490 private long _groupId;
491 private long _originalGroupId;
492 private boolean _setOriginalGroupId;
493 private long _companyId;
494 private long _userId;
495 private String _userUuid;
496 private String _userName;
497 private Date _createDate;
498 private Date _modifiedDate;
499 private long _parentFolderId;
500 private long _originalParentFolderId;
501 private boolean _setOriginalParentFolderId;
502 private String _name;
503 private String _originalName;
504 private String _description;
505 private Date _lastPostDate;
506 private transient ExpandoBridge _expandoBridge;
507 }