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