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