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
054 public class DLFolderModelImpl extends BaseModelImpl<DLFolder>
055 implements DLFolderModel {
056 public static final String TABLE_NAME = "DLFolder";
057 public static final Object[][] TABLE_COLUMNS = {
058 { "uuid_", new Integer(Types.VARCHAR) },
059 { "folderId", new Integer(Types.BIGINT) },
060 { "groupId", new Integer(Types.BIGINT) },
061 { "companyId", new Integer(Types.BIGINT) },
062 { "userId", new Integer(Types.BIGINT) },
063 { "userName", new Integer(Types.VARCHAR) },
064 { "createDate", new Integer(Types.TIMESTAMP) },
065 { "modifiedDate", new Integer(Types.TIMESTAMP) },
066 { "parentFolderId", new Integer(Types.BIGINT) },
067 { "name", new Integer(Types.VARCHAR) },
068 { "description", new Integer(Types.VARCHAR) },
069 { "lastPostDate", new Integer(Types.TIMESTAMP) }
070 };
071 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)";
072 public static final String TABLE_SQL_DROP = "drop table DLFolder";
073 public static final String ORDER_BY_JPQL = " ORDER BY dlFolder.parentFolderId ASC, dlFolder.name ASC";
074 public static final String ORDER_BY_SQL = " ORDER BY DLFolder.parentFolderId ASC, DLFolder.name ASC";
075 public static final String DATA_SOURCE = "liferayDataSource";
076 public static final String SESSION_FACTORY = "liferaySessionFactory";
077 public static final String TX_MANAGER = "liferayTransactionManager";
078 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
080 true);
081 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
083 true);
084
085 public static DLFolder toModel(DLFolderSoap soapModel) {
086 DLFolder model = new DLFolderImpl();
087
088 model.setUuid(soapModel.getUuid());
089 model.setFolderId(soapModel.getFolderId());
090 model.setGroupId(soapModel.getGroupId());
091 model.setCompanyId(soapModel.getCompanyId());
092 model.setUserId(soapModel.getUserId());
093 model.setUserName(soapModel.getUserName());
094 model.setCreateDate(soapModel.getCreateDate());
095 model.setModifiedDate(soapModel.getModifiedDate());
096 model.setParentFolderId(soapModel.getParentFolderId());
097 model.setName(soapModel.getName());
098 model.setDescription(soapModel.getDescription());
099 model.setLastPostDate(soapModel.getLastPostDate());
100
101 return model;
102 }
103
104 public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
105 List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
106
107 for (DLFolderSoap soapModel : soapModels) {
108 models.add(toModel(soapModel));
109 }
110
111 return models;
112 }
113
114 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
116
117 public DLFolderModelImpl() {
118 }
119
120 public long getPrimaryKey() {
121 return _folderId;
122 }
123
124 public void setPrimaryKey(long pk) {
125 setFolderId(pk);
126 }
127
128 public Serializable getPrimaryKeyObj() {
129 return new Long(_folderId);
130 }
131
132 public String getUuid() {
133 if (_uuid == null) {
134 return StringPool.BLANK;
135 }
136 else {
137 return _uuid;
138 }
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 if (_userName == null) {
205 return StringPool.BLANK;
206 }
207 else {
208 return _userName;
209 }
210 }
211
212 public void setUserName(String userName) {
213 _userName = userName;
214 }
215
216 public Date getCreateDate() {
217 return _createDate;
218 }
219
220 public void setCreateDate(Date createDate) {
221 _createDate = createDate;
222 }
223
224 public Date getModifiedDate() {
225 return _modifiedDate;
226 }
227
228 public void setModifiedDate(Date modifiedDate) {
229 _modifiedDate = modifiedDate;
230 }
231
232 public long getParentFolderId() {
233 return _parentFolderId;
234 }
235
236 public void setParentFolderId(long parentFolderId) {
237 _parentFolderId = parentFolderId;
238
239 if (!_setOriginalParentFolderId) {
240 _setOriginalParentFolderId = true;
241
242 _originalParentFolderId = parentFolderId;
243 }
244 }
245
246 public long getOriginalParentFolderId() {
247 return _originalParentFolderId;
248 }
249
250 public String getName() {
251 if (_name == null) {
252 return StringPool.BLANK;
253 }
254 else {
255 return _name;
256 }
257 }
258
259 public void setName(String name) {
260 _name = name;
261
262 if (_originalName == null) {
263 _originalName = name;
264 }
265 }
266
267 public String getOriginalName() {
268 return GetterUtil.getString(_originalName);
269 }
270
271 public String getDescription() {
272 if (_description == null) {
273 return StringPool.BLANK;
274 }
275 else {
276 return _description;
277 }
278 }
279
280 public void setDescription(String description) {
281 _description = description;
282 }
283
284 public Date getLastPostDate() {
285 return _lastPostDate;
286 }
287
288 public void setLastPostDate(Date lastPostDate) {
289 _lastPostDate = lastPostDate;
290 }
291
292 public DLFolder toEscapedModel() {
293 if (isEscapedModel()) {
294 return (DLFolder)this;
295 }
296 else {
297 return (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
298 new Class[] { DLFolder.class }, new AutoEscapeBeanHandler(this));
299 }
300 }
301
302 public ExpandoBridge getExpandoBridge() {
303 if (_expandoBridge == null) {
304 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
305 DLFolder.class.getName(), getPrimaryKey());
306 }
307
308 return _expandoBridge;
309 }
310
311 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
312 getExpandoBridge().setAttributes(serviceContext);
313 }
314
315 public Object clone() {
316 DLFolderImpl clone = new DLFolderImpl();
317
318 clone.setUuid(getUuid());
319 clone.setFolderId(getFolderId());
320 clone.setGroupId(getGroupId());
321 clone.setCompanyId(getCompanyId());
322 clone.setUserId(getUserId());
323 clone.setUserName(getUserName());
324 clone.setCreateDate(getCreateDate());
325 clone.setModifiedDate(getModifiedDate());
326 clone.setParentFolderId(getParentFolderId());
327 clone.setName(getName());
328 clone.setDescription(getDescription());
329 clone.setLastPostDate(getLastPostDate());
330
331 return clone;
332 }
333
334 public int compareTo(DLFolder dlFolder) {
335 int value = 0;
336
337 if (getParentFolderId() < dlFolder.getParentFolderId()) {
338 value = -1;
339 }
340 else if (getParentFolderId() > dlFolder.getParentFolderId()) {
341 value = 1;
342 }
343 else {
344 value = 0;
345 }
346
347 if (value != 0) {
348 return value;
349 }
350
351 value = getName().toLowerCase()
352 .compareTo(dlFolder.getName().toLowerCase());
353
354 if (value != 0) {
355 return value;
356 }
357
358 return 0;
359 }
360
361 public boolean equals(Object obj) {
362 if (obj == null) {
363 return false;
364 }
365
366 DLFolder dlFolder = null;
367
368 try {
369 dlFolder = (DLFolder)obj;
370 }
371 catch (ClassCastException cce) {
372 return false;
373 }
374
375 long pk = dlFolder.getPrimaryKey();
376
377 if (getPrimaryKey() == pk) {
378 return true;
379 }
380 else {
381 return false;
382 }
383 }
384
385 public int hashCode() {
386 return (int)getPrimaryKey();
387 }
388
389 public String toString() {
390 StringBundler sb = new StringBundler(25);
391
392 sb.append("{uuid=");
393 sb.append(getUuid());
394 sb.append(", folderId=");
395 sb.append(getFolderId());
396 sb.append(", groupId=");
397 sb.append(getGroupId());
398 sb.append(", companyId=");
399 sb.append(getCompanyId());
400 sb.append(", userId=");
401 sb.append(getUserId());
402 sb.append(", userName=");
403 sb.append(getUserName());
404 sb.append(", createDate=");
405 sb.append(getCreateDate());
406 sb.append(", modifiedDate=");
407 sb.append(getModifiedDate());
408 sb.append(", parentFolderId=");
409 sb.append(getParentFolderId());
410 sb.append(", name=");
411 sb.append(getName());
412 sb.append(", description=");
413 sb.append(getDescription());
414 sb.append(", lastPostDate=");
415 sb.append(getLastPostDate());
416 sb.append("}");
417
418 return sb.toString();
419 }
420
421 public String toXmlString() {
422 StringBundler sb = new StringBundler(40);
423
424 sb.append("<model><model-name>");
425 sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
426 sb.append("</model-name>");
427
428 sb.append(
429 "<column><column-name>uuid</column-name><column-value><![CDATA[");
430 sb.append(getUuid());
431 sb.append("]]></column-value></column>");
432 sb.append(
433 "<column><column-name>folderId</column-name><column-value><![CDATA[");
434 sb.append(getFolderId());
435 sb.append("]]></column-value></column>");
436 sb.append(
437 "<column><column-name>groupId</column-name><column-value><![CDATA[");
438 sb.append(getGroupId());
439 sb.append("]]></column-value></column>");
440 sb.append(
441 "<column><column-name>companyId</column-name><column-value><![CDATA[");
442 sb.append(getCompanyId());
443 sb.append("]]></column-value></column>");
444 sb.append(
445 "<column><column-name>userId</column-name><column-value><![CDATA[");
446 sb.append(getUserId());
447 sb.append("]]></column-value></column>");
448 sb.append(
449 "<column><column-name>userName</column-name><column-value><![CDATA[");
450 sb.append(getUserName());
451 sb.append("]]></column-value></column>");
452 sb.append(
453 "<column><column-name>createDate</column-name><column-value><![CDATA[");
454 sb.append(getCreateDate());
455 sb.append("]]></column-value></column>");
456 sb.append(
457 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
458 sb.append(getModifiedDate());
459 sb.append("]]></column-value></column>");
460 sb.append(
461 "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
462 sb.append(getParentFolderId());
463 sb.append("]]></column-value></column>");
464 sb.append(
465 "<column><column-name>name</column-name><column-value><![CDATA[");
466 sb.append(getName());
467 sb.append("]]></column-value></column>");
468 sb.append(
469 "<column><column-name>description</column-name><column-value><![CDATA[");
470 sb.append(getDescription());
471 sb.append("]]></column-value></column>");
472 sb.append(
473 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
474 sb.append(getLastPostDate());
475 sb.append("]]></column-value></column>");
476
477 sb.append("</model>");
478
479 return sb.toString();
480 }
481
482 private String _uuid;
483 private String _originalUuid;
484 private long _folderId;
485 private long _groupId;
486 private long _originalGroupId;
487 private boolean _setOriginalGroupId;
488 private long _companyId;
489 private long _userId;
490 private String _userUuid;
491 private String _userName;
492 private Date _createDate;
493 private Date _modifiedDate;
494 private long _parentFolderId;
495 private long _originalParentFolderId;
496 private boolean _setOriginalParentFolderId;
497 private String _name;
498 private String _originalName;
499 private String _description;
500 private Date _lastPostDate;
501 private transient ExpandoBridge _expandoBridge;
502 }