forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
KBTemplateModelImpl.java
690 lines (551 loc) · 17.7 KB
/
KBTemplateModelImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.knowledgebase.model.impl;
import com.liferay.knowledgebase.model.KBTemplate;
import com.liferay.knowledgebase.model.KBTemplateModel;
import com.liferay.knowledgebase.model.KBTemplateSoap;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
import java.io.Serializable;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The base model implementation for the KBTemplate service. Represents a row in the "KBTemplate" database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.liferay.knowledgebase.model.KBTemplateModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link KBTemplateImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see KBTemplateImpl
* @see com.liferay.knowledgebase.model.KBTemplate
* @see com.liferay.knowledgebase.model.KBTemplateModel
* @generated
*/
@JSON(strict = true)
public class KBTemplateModelImpl extends BaseModelImpl<KBTemplate>
implements KBTemplateModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a k b template model instance should use the {@link com.liferay.knowledgebase.model.KBTemplate} interface instead.
*/
public static final String TABLE_NAME = "KBTemplate";
public static final Object[][] TABLE_COLUMNS = {
{ "uuid_", Types.VARCHAR },
{ "kbTemplateId", Types.BIGINT },
{ "groupId", Types.BIGINT },
{ "companyId", Types.BIGINT },
{ "userId", Types.BIGINT },
{ "userName", Types.VARCHAR },
{ "createDate", Types.TIMESTAMP },
{ "modifiedDate", Types.TIMESTAMP },
{ "title", Types.VARCHAR },
{ "content", Types.CLOB }
};
public static final String TABLE_SQL_CREATE = "create table KBTemplate (uuid_ VARCHAR(75) null,kbTemplateId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title STRING null,content TEXT null)";
public static final String TABLE_SQL_DROP = "drop table KBTemplate";
public static final String ORDER_BY_JPQL = " ORDER BY kbTemplate.modifiedDate DESC";
public static final String ORDER_BY_SQL = " ORDER BY KBTemplate.modifiedDate DESC";
public static final String DATA_SOURCE = "liferayDataSource";
public static final String SESSION_FACTORY = "liferaySessionFactory";
public static final String TX_MANAGER = "liferayTransactionManager";
public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.entity.cache.enabled.com.liferay.knowledgebase.model.KBTemplate"),
true);
public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.finder.cache.enabled.com.liferay.knowledgebase.model.KBTemplate"),
true);
public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.column.bitmask.enabled.com.liferay.knowledgebase.model.KBTemplate"),
true);
public static long COMPANYID_COLUMN_BITMASK = 1L;
public static long GROUPID_COLUMN_BITMASK = 2L;
public static long UUID_COLUMN_BITMASK = 4L;
/**
* Converts the soap model instance into a normal model instance.
*
* @param soapModel the soap model instance to convert
* @return the normal model instance
*/
public static KBTemplate toModel(KBTemplateSoap soapModel) {
if (soapModel == null) {
return null;
}
KBTemplate model = new KBTemplateImpl();
model.setUuid(soapModel.getUuid());
model.setKbTemplateId(soapModel.getKbTemplateId());
model.setGroupId(soapModel.getGroupId());
model.setCompanyId(soapModel.getCompanyId());
model.setUserId(soapModel.getUserId());
model.setUserName(soapModel.getUserName());
model.setCreateDate(soapModel.getCreateDate());
model.setModifiedDate(soapModel.getModifiedDate());
model.setTitle(soapModel.getTitle());
model.setContent(soapModel.getContent());
return model;
}
/**
* Converts the soap model instances into normal model instances.
*
* @param soapModels the soap model instances to convert
* @return the normal model instances
*/
public static List<KBTemplate> toModels(KBTemplateSoap[] soapModels) {
if (soapModels == null) {
return null;
}
List<KBTemplate> models = new ArrayList<KBTemplate>(soapModels.length);
for (KBTemplateSoap soapModel : soapModels) {
models.add(toModel(soapModel));
}
return models;
}
public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
"lock.expiration.time.com.liferay.knowledgebase.model.KBTemplate"));
public KBTemplateModelImpl() {
}
public long getPrimaryKey() {
return _kbTemplateId;
}
public void setPrimaryKey(long primaryKey) {
setKbTemplateId(primaryKey);
}
public Serializable getPrimaryKeyObj() {
return new Long(_kbTemplateId);
}
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
public Class<?> getModelClass() {
return KBTemplate.class;
}
public String getModelClassName() {
return KBTemplate.class.getName();
}
@Override
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("uuid", getUuid());
attributes.put("kbTemplateId", getKbTemplateId());
attributes.put("groupId", getGroupId());
attributes.put("companyId", getCompanyId());
attributes.put("userId", getUserId());
attributes.put("userName", getUserName());
attributes.put("createDate", getCreateDate());
attributes.put("modifiedDate", getModifiedDate());
attributes.put("title", getTitle());
attributes.put("content", getContent());
return attributes;
}
@Override
public void setModelAttributes(Map<String, Object> attributes) {
String uuid = (String)attributes.get("uuid");
if (uuid != null) {
setUuid(uuid);
}
Long kbTemplateId = (Long)attributes.get("kbTemplateId");
if (kbTemplateId != null) {
setKbTemplateId(kbTemplateId);
}
Long groupId = (Long)attributes.get("groupId");
if (groupId != null) {
setGroupId(groupId);
}
Long companyId = (Long)attributes.get("companyId");
if (companyId != null) {
setCompanyId(companyId);
}
Long userId = (Long)attributes.get("userId");
if (userId != null) {
setUserId(userId);
}
String userName = (String)attributes.get("userName");
if (userName != null) {
setUserName(userName);
}
Date createDate = (Date)attributes.get("createDate");
if (createDate != null) {
setCreateDate(createDate);
}
Date modifiedDate = (Date)attributes.get("modifiedDate");
if (modifiedDate != null) {
setModifiedDate(modifiedDate);
}
String title = (String)attributes.get("title");
if (title != null) {
setTitle(title);
}
String content = (String)attributes.get("content");
if (content != null) {
setContent(content);
}
}
@JSON
public String getUuid() {
if (_uuid == null) {
return StringPool.BLANK;
}
else {
return _uuid;
}
}
public void setUuid(String uuid) {
if (_originalUuid == null) {
_originalUuid = _uuid;
}
_uuid = uuid;
}
public String getOriginalUuid() {
return GetterUtil.getString(_originalUuid);
}
@JSON
public long getKbTemplateId() {
return _kbTemplateId;
}
public void setKbTemplateId(long kbTemplateId) {
_kbTemplateId = kbTemplateId;
}
@JSON
public long getGroupId() {
return _groupId;
}
public void setGroupId(long groupId) {
_columnBitmask |= GROUPID_COLUMN_BITMASK;
if (!_setOriginalGroupId) {
_setOriginalGroupId = true;
_originalGroupId = _groupId;
}
_groupId = groupId;
}
public long getOriginalGroupId() {
return _originalGroupId;
}
@JSON
public long getCompanyId() {
return _companyId;
}
public void setCompanyId(long companyId) {
_columnBitmask |= COMPANYID_COLUMN_BITMASK;
if (!_setOriginalCompanyId) {
_setOriginalCompanyId = true;
_originalCompanyId = _companyId;
}
_companyId = companyId;
}
public long getOriginalCompanyId() {
return _originalCompanyId;
}
@JSON
public long getUserId() {
return _userId;
}
public void setUserId(long userId) {
_userId = userId;
}
public String getUserUuid() throws SystemException {
return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
}
public void setUserUuid(String userUuid) {
_userUuid = userUuid;
}
@JSON
public String getUserName() {
if (_userName == null) {
return StringPool.BLANK;
}
else {
return _userName;
}
}
public void setUserName(String userName) {
_userName = userName;
}
@JSON
public Date getCreateDate() {
return _createDate;
}
public void setCreateDate(Date createDate) {
_createDate = createDate;
}
@JSON
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_columnBitmask = -1L;
_modifiedDate = modifiedDate;
}
@JSON
public String getTitle() {
if (_title == null) {
return StringPool.BLANK;
}
else {
return _title;
}
}
public void setTitle(String title) {
_title = title;
}
@JSON
public String getContent() {
if (_content == null) {
return StringPool.BLANK;
}
else {
return _content;
}
}
public void setContent(String content) {
_content = content;
}
public long getColumnBitmask() {
return _columnBitmask;
}
@Override
public KBTemplate toEscapedModel() {
if (_escapedModelProxy == null) {
_escapedModelProxy = (KBTemplate)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelProxyInterfaces,
new AutoEscapeBeanHandler(this));
}
return _escapedModelProxy;
}
@Override
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
KBTemplate.class.getName(), getPrimaryKey());
}
@Override
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
@Override
public Object clone() {
KBTemplateImpl kbTemplateImpl = new KBTemplateImpl();
kbTemplateImpl.setUuid(getUuid());
kbTemplateImpl.setKbTemplateId(getKbTemplateId());
kbTemplateImpl.setGroupId(getGroupId());
kbTemplateImpl.setCompanyId(getCompanyId());
kbTemplateImpl.setUserId(getUserId());
kbTemplateImpl.setUserName(getUserName());
kbTemplateImpl.setCreateDate(getCreateDate());
kbTemplateImpl.setModifiedDate(getModifiedDate());
kbTemplateImpl.setTitle(getTitle());
kbTemplateImpl.setContent(getContent());
kbTemplateImpl.resetOriginalValues();
return kbTemplateImpl;
}
public int compareTo(KBTemplate kbTemplate) {
int value = 0;
value = DateUtil.compareTo(getModifiedDate(),
kbTemplate.getModifiedDate());
value = value * -1;
if (value != 0) {
return value;
}
return 0;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
KBTemplate kbTemplate = null;
try {
kbTemplate = (KBTemplate)obj;
}
catch (ClassCastException cce) {
return false;
}
long primaryKey = kbTemplate.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
@Override
public int hashCode() {
return (int)getPrimaryKey();
}
@Override
public void resetOriginalValues() {
KBTemplateModelImpl kbTemplateModelImpl = this;
kbTemplateModelImpl._originalUuid = kbTemplateModelImpl._uuid;
kbTemplateModelImpl._originalGroupId = kbTemplateModelImpl._groupId;
kbTemplateModelImpl._setOriginalGroupId = false;
kbTemplateModelImpl._originalCompanyId = kbTemplateModelImpl._companyId;
kbTemplateModelImpl._setOriginalCompanyId = false;
kbTemplateModelImpl._columnBitmask = 0;
}
@Override
public CacheModel<KBTemplate> toCacheModel() {
KBTemplateCacheModel kbTemplateCacheModel = new KBTemplateCacheModel();
kbTemplateCacheModel.uuid = getUuid();
String uuid = kbTemplateCacheModel.uuid;
if ((uuid != null) && (uuid.length() == 0)) {
kbTemplateCacheModel.uuid = null;
}
kbTemplateCacheModel.kbTemplateId = getKbTemplateId();
kbTemplateCacheModel.groupId = getGroupId();
kbTemplateCacheModel.companyId = getCompanyId();
kbTemplateCacheModel.userId = getUserId();
kbTemplateCacheModel.userName = getUserName();
String userName = kbTemplateCacheModel.userName;
if ((userName != null) && (userName.length() == 0)) {
kbTemplateCacheModel.userName = null;
}
Date createDate = getCreateDate();
if (createDate != null) {
kbTemplateCacheModel.createDate = createDate.getTime();
}
else {
kbTemplateCacheModel.createDate = Long.MIN_VALUE;
}
Date modifiedDate = getModifiedDate();
if (modifiedDate != null) {
kbTemplateCacheModel.modifiedDate = modifiedDate.getTime();
}
else {
kbTemplateCacheModel.modifiedDate = Long.MIN_VALUE;
}
kbTemplateCacheModel.title = getTitle();
String title = kbTemplateCacheModel.title;
if ((title != null) && (title.length() == 0)) {
kbTemplateCacheModel.title = null;
}
kbTemplateCacheModel.content = getContent();
String content = kbTemplateCacheModel.content;
if ((content != null) && (content.length() == 0)) {
kbTemplateCacheModel.content = null;
}
return kbTemplateCacheModel;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(21);
sb.append("{uuid=");
sb.append(getUuid());
sb.append(", kbTemplateId=");
sb.append(getKbTemplateId());
sb.append(", groupId=");
sb.append(getGroupId());
sb.append(", companyId=");
sb.append(getCompanyId());
sb.append(", userId=");
sb.append(getUserId());
sb.append(", userName=");
sb.append(getUserName());
sb.append(", createDate=");
sb.append(getCreateDate());
sb.append(", modifiedDate=");
sb.append(getModifiedDate());
sb.append(", title=");
sb.append(getTitle());
sb.append(", content=");
sb.append(getContent());
sb.append("}");
return sb.toString();
}
public String toXmlString() {
StringBundler sb = new StringBundler(34);
sb.append("<model><model-name>");
sb.append("com.liferay.knowledgebase.model.KBTemplate");
sb.append("</model-name>");
sb.append(
"<column><column-name>uuid</column-name><column-value><![CDATA[");
sb.append(getUuid());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kbTemplateId</column-name><column-value><![CDATA[");
sb.append(getKbTemplateId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>groupId</column-name><column-value><![CDATA[");
sb.append(getGroupId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>companyId</column-name><column-value><![CDATA[");
sb.append(getCompanyId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>userId</column-name><column-value><![CDATA[");
sb.append(getUserId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>userName</column-name><column-value><![CDATA[");
sb.append(getUserName());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>createDate</column-name><column-value><![CDATA[");
sb.append(getCreateDate());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
sb.append(getModifiedDate());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>title</column-name><column-value><![CDATA[");
sb.append(getTitle());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>content</column-name><column-value><![CDATA[");
sb.append(getContent());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = KBTemplate.class.getClassLoader();
private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
KBTemplate.class
};
private String _uuid;
private String _originalUuid;
private long _kbTemplateId;
private long _groupId;
private long _originalGroupId;
private boolean _setOriginalGroupId;
private long _companyId;
private long _originalCompanyId;
private boolean _setOriginalCompanyId;
private long _userId;
private String _userUuid;
private String _userName;
private Date _createDate;
private Date _modifiedDate;
private String _title;
private String _content;
private long _columnBitmask;
private KBTemplate _escapedModelProxy;
}