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