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