1
14
15 package com.liferay.portlet.asset.model.impl;
16
17 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.kernel.language.LanguageUtil;
20 import com.liferay.portal.kernel.util.GetterUtil;
21 import com.liferay.portal.kernel.util.HtmlUtil;
22 import com.liferay.portal.kernel.util.LocaleUtil;
23 import com.liferay.portal.kernel.util.LocalizationUtil;
24 import com.liferay.portal.kernel.util.StringBundler;
25 import com.liferay.portal.kernel.util.StringPool;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.model.impl.BaseModelImpl;
28 import com.liferay.portal.service.ServiceContext;
29 import com.liferay.portal.util.PortalUtil;
30
31 import com.liferay.portlet.asset.model.AssetCategory;
32 import com.liferay.portlet.asset.model.AssetCategorySoap;
33 import com.liferay.portlet.expando.model.ExpandoBridge;
34 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
35
36 import java.io.Serializable;
37
38 import java.lang.reflect.Proxy;
39
40 import java.sql.Types;
41
42 import java.util.ArrayList;
43 import java.util.Date;
44 import java.util.List;
45 import java.util.Locale;
46 import java.util.Map;
47
48
67 public class AssetCategoryModelImpl extends BaseModelImpl<AssetCategory> {
68 public static final String TABLE_NAME = "AssetCategory";
69 public static final Object[][] TABLE_COLUMNS = {
70 { "uuid_", new Integer(Types.VARCHAR) },
71 { "categoryId", new Integer(Types.BIGINT) },
72 { "groupId", new Integer(Types.BIGINT) },
73 { "companyId", new Integer(Types.BIGINT) },
74 { "userId", new Integer(Types.BIGINT) },
75 { "userName", new Integer(Types.VARCHAR) },
76 { "createDate", new Integer(Types.TIMESTAMP) },
77 { "modifiedDate", new Integer(Types.TIMESTAMP) },
78 { "parentCategoryId", new Integer(Types.BIGINT) },
79 { "leftCategoryId", new Integer(Types.BIGINT) },
80 { "rightCategoryId", new Integer(Types.BIGINT) },
81 { "name", new Integer(Types.VARCHAR) },
82 { "title", new Integer(Types.VARCHAR) },
83 { "vocabularyId", new Integer(Types.BIGINT) }
84 };
85 public static final String TABLE_SQL_CREATE = "create table AssetCategory (uuid_ VARCHAR(75) null,categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,leftCategoryId LONG,rightCategoryId LONG,name VARCHAR(75) null,title STRING null,vocabularyId LONG)";
86 public static final String TABLE_SQL_DROP = "drop table AssetCategory";
87 public static final String ORDER_BY_JPQL = " ORDER BY assetCategory.name ASC";
88 public static final String ORDER_BY_SQL = " ORDER BY AssetCategory.name ASC";
89 public static final String DATA_SOURCE = "liferayDataSource";
90 public static final String SESSION_FACTORY = "liferaySessionFactory";
91 public static final String TX_MANAGER = "liferayTransactionManager";
92 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93 "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
94 true);
95 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96 "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
97 true);
98
99 public static AssetCategory toModel(AssetCategorySoap soapModel) {
100 AssetCategory model = new AssetCategoryImpl();
101
102 model.setUuid(soapModel.getUuid());
103 model.setCategoryId(soapModel.getCategoryId());
104 model.setGroupId(soapModel.getGroupId());
105 model.setCompanyId(soapModel.getCompanyId());
106 model.setUserId(soapModel.getUserId());
107 model.setUserName(soapModel.getUserName());
108 model.setCreateDate(soapModel.getCreateDate());
109 model.setModifiedDate(soapModel.getModifiedDate());
110 model.setParentCategoryId(soapModel.getParentCategoryId());
111 model.setLeftCategoryId(soapModel.getLeftCategoryId());
112 model.setRightCategoryId(soapModel.getRightCategoryId());
113 model.setName(soapModel.getName());
114 model.setTitle(soapModel.getTitle());
115 model.setVocabularyId(soapModel.getVocabularyId());
116
117 return model;
118 }
119
120 public static List<AssetCategory> toModels(AssetCategorySoap[] soapModels) {
121 List<AssetCategory> models = new ArrayList<AssetCategory>(soapModels.length);
122
123 for (AssetCategorySoap soapModel : soapModels) {
124 models.add(toModel(soapModel));
125 }
126
127 return models;
128 }
129
130 public static final String MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME = com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME;
131 public static final boolean FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES =
132 com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES;
133 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134 "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategory"));
135
136 public AssetCategoryModelImpl() {
137 }
138
139 public long getPrimaryKey() {
140 return _categoryId;
141 }
142
143 public void setPrimaryKey(long pk) {
144 setCategoryId(pk);
145 }
146
147 public Serializable getPrimaryKeyObj() {
148 return new Long(_categoryId);
149 }
150
151 public String getUuid() {
152 if (_uuid == null) {
153 return StringPool.BLANK;
154 }
155 else {
156 return _uuid;
157 }
158 }
159
160 public void setUuid(String uuid) {
161 _uuid = uuid;
162
163 if (_originalUuid == null) {
164 _originalUuid = uuid;
165 }
166 }
167
168 public String getOriginalUuid() {
169 return GetterUtil.getString(_originalUuid);
170 }
171
172 public long getCategoryId() {
173 return _categoryId;
174 }
175
176 public void setCategoryId(long categoryId) {
177 _categoryId = categoryId;
178 }
179
180 public long getGroupId() {
181 return _groupId;
182 }
183
184 public void setGroupId(long groupId) {
185 _groupId = groupId;
186
187 if (!_setOriginalGroupId) {
188 _setOriginalGroupId = true;
189
190 _originalGroupId = groupId;
191 }
192 }
193
194 public long getOriginalGroupId() {
195 return _originalGroupId;
196 }
197
198 public long getCompanyId() {
199 return _companyId;
200 }
201
202 public void setCompanyId(long companyId) {
203 _companyId = companyId;
204 }
205
206 public long getUserId() {
207 return _userId;
208 }
209
210 public void setUserId(long userId) {
211 _userId = userId;
212 }
213
214 public String getUserUuid() throws SystemException {
215 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
216 }
217
218 public void setUserUuid(String userUuid) {
219 _userUuid = userUuid;
220 }
221
222 public String getUserName() {
223 if (_userName == null) {
224 return StringPool.BLANK;
225 }
226 else {
227 return _userName;
228 }
229 }
230
231 public void setUserName(String userName) {
232 _userName = userName;
233 }
234
235 public Date getCreateDate() {
236 return _createDate;
237 }
238
239 public void setCreateDate(Date createDate) {
240 _createDate = createDate;
241 }
242
243 public Date getModifiedDate() {
244 return _modifiedDate;
245 }
246
247 public void setModifiedDate(Date modifiedDate) {
248 _modifiedDate = modifiedDate;
249 }
250
251 public long getParentCategoryId() {
252 return _parentCategoryId;
253 }
254
255 public void setParentCategoryId(long parentCategoryId) {
256 _parentCategoryId = parentCategoryId;
257
258 if (!_setOriginalParentCategoryId) {
259 _setOriginalParentCategoryId = true;
260
261 _originalParentCategoryId = parentCategoryId;
262 }
263 }
264
265 public long getOriginalParentCategoryId() {
266 return _originalParentCategoryId;
267 }
268
269 public long getLeftCategoryId() {
270 return _leftCategoryId;
271 }
272
273 public void setLeftCategoryId(long leftCategoryId) {
274 _leftCategoryId = leftCategoryId;
275 }
276
277 public long getRightCategoryId() {
278 return _rightCategoryId;
279 }
280
281 public void setRightCategoryId(long rightCategoryId) {
282 _rightCategoryId = rightCategoryId;
283 }
284
285 public String getName() {
286 if (_name == null) {
287 return StringPool.BLANK;
288 }
289 else {
290 return _name;
291 }
292 }
293
294 public void setName(String name) {
295 _name = name;
296 }
297
298 public String getTitle() {
299 if (_title == null) {
300 return StringPool.BLANK;
301 }
302 else {
303 return _title;
304 }
305 }
306
307 public String getTitle(Locale locale) {
308 String languageId = LocaleUtil.toLanguageId(locale);
309
310 return getTitle(languageId);
311 }
312
313 public String getTitle(Locale locale, boolean useDefault) {
314 String languageId = LocaleUtil.toLanguageId(locale);
315
316 return getTitle(languageId, useDefault);
317 }
318
319 public String getTitle(String languageId) {
320 String value = LocalizationUtil.getLocalization(getTitle(), languageId);
321
322 if (isEscapedModel()) {
323 return HtmlUtil.escape(value);
324 }
325 else {
326 return value;
327 }
328 }
329
330 public String getTitle(String languageId, boolean useDefault) {
331 String value = LocalizationUtil.getLocalization(getTitle(), languageId,
332 useDefault);
333
334 if (isEscapedModel()) {
335 return HtmlUtil.escape(value);
336 }
337 else {
338 return value;
339 }
340 }
341
342 public Map<Locale, String> getTitleMap() {
343 return LocalizationUtil.getLocalizationMap(getTitle());
344 }
345
346 public void setTitle(String title) {
347 _title = title;
348 }
349
350 public void setTitle(Locale locale, String title) {
351 String languageId = LocaleUtil.toLanguageId(locale);
352
353 if (Validator.isNotNull(title)) {
354 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
355 title, languageId));
356 }
357 else {
358 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
359 languageId));
360 }
361 }
362
363 public void setTitleMap(Map<Locale, String> titleMap) {
364 if (titleMap == null) {
365 return;
366 }
367
368 Locale[] locales = LanguageUtil.getAvailableLocales();
369
370 for (Locale locale : locales) {
371 String title = titleMap.get(locale);
372
373 setTitle(locale, title);
374 }
375 }
376
377 public long getVocabularyId() {
378 return _vocabularyId;
379 }
380
381 public void setVocabularyId(long vocabularyId) {
382 _vocabularyId = vocabularyId;
383 }
384
385 public AssetCategory toEscapedModel() {
386 if (isEscapedModel()) {
387 return (AssetCategory)this;
388 }
389 else {
390 return (AssetCategory)Proxy.newProxyInstance(AssetCategory.class.getClassLoader(),
391 new Class[] { AssetCategory.class },
392 new AutoEscapeBeanHandler(this));
393 }
394 }
395
396 public ExpandoBridge getExpandoBridge() {
397 if (_expandoBridge == null) {
398 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
399 AssetCategory.class.getName(), getPrimaryKey());
400 }
401
402 return _expandoBridge;
403 }
404
405 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
406 getExpandoBridge().setAttributes(serviceContext);
407 }
408
409 public Object clone() {
410 AssetCategoryImpl clone = new AssetCategoryImpl();
411
412 clone.setUuid(getUuid());
413 clone.setCategoryId(getCategoryId());
414 clone.setGroupId(getGroupId());
415 clone.setCompanyId(getCompanyId());
416 clone.setUserId(getUserId());
417 clone.setUserName(getUserName());
418 clone.setCreateDate(getCreateDate());
419 clone.setModifiedDate(getModifiedDate());
420 clone.setParentCategoryId(getParentCategoryId());
421 clone.setLeftCategoryId(getLeftCategoryId());
422 clone.setRightCategoryId(getRightCategoryId());
423 clone.setName(getName());
424 clone.setTitle(getTitle());
425 clone.setVocabularyId(getVocabularyId());
426
427 return clone;
428 }
429
430 public int compareTo(AssetCategory assetCategory) {
431 int value = 0;
432
433 value = getName().compareTo(assetCategory.getName());
434
435 if (value != 0) {
436 return value;
437 }
438
439 return 0;
440 }
441
442 public boolean equals(Object obj) {
443 if (obj == null) {
444 return false;
445 }
446
447 AssetCategory assetCategory = null;
448
449 try {
450 assetCategory = (AssetCategory)obj;
451 }
452 catch (ClassCastException cce) {
453 return false;
454 }
455
456 long pk = assetCategory.getPrimaryKey();
457
458 if (getPrimaryKey() == pk) {
459 return true;
460 }
461 else {
462 return false;
463 }
464 }
465
466 public int hashCode() {
467 return (int)getPrimaryKey();
468 }
469
470 public String toString() {
471 StringBundler sb = new StringBundler(29);
472
473 sb.append("{uuid=");
474 sb.append(getUuid());
475 sb.append(", categoryId=");
476 sb.append(getCategoryId());
477 sb.append(", groupId=");
478 sb.append(getGroupId());
479 sb.append(", companyId=");
480 sb.append(getCompanyId());
481 sb.append(", userId=");
482 sb.append(getUserId());
483 sb.append(", userName=");
484 sb.append(getUserName());
485 sb.append(", createDate=");
486 sb.append(getCreateDate());
487 sb.append(", modifiedDate=");
488 sb.append(getModifiedDate());
489 sb.append(", parentCategoryId=");
490 sb.append(getParentCategoryId());
491 sb.append(", leftCategoryId=");
492 sb.append(getLeftCategoryId());
493 sb.append(", rightCategoryId=");
494 sb.append(getRightCategoryId());
495 sb.append(", name=");
496 sb.append(getName());
497 sb.append(", title=");
498 sb.append(getTitle());
499 sb.append(", vocabularyId=");
500 sb.append(getVocabularyId());
501 sb.append("}");
502
503 return sb.toString();
504 }
505
506 public String toXmlString() {
507 StringBundler sb = new StringBundler(46);
508
509 sb.append("<model><model-name>");
510 sb.append("com.liferay.portlet.asset.model.AssetCategory");
511 sb.append("</model-name>");
512
513 sb.append(
514 "<column><column-name>uuid</column-name><column-value><![CDATA[");
515 sb.append(getUuid());
516 sb.append("]]></column-value></column>");
517 sb.append(
518 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
519 sb.append(getCategoryId());
520 sb.append("]]></column-value></column>");
521 sb.append(
522 "<column><column-name>groupId</column-name><column-value><![CDATA[");
523 sb.append(getGroupId());
524 sb.append("]]></column-value></column>");
525 sb.append(
526 "<column><column-name>companyId</column-name><column-value><![CDATA[");
527 sb.append(getCompanyId());
528 sb.append("]]></column-value></column>");
529 sb.append(
530 "<column><column-name>userId</column-name><column-value><![CDATA[");
531 sb.append(getUserId());
532 sb.append("]]></column-value></column>");
533 sb.append(
534 "<column><column-name>userName</column-name><column-value><![CDATA[");
535 sb.append(getUserName());
536 sb.append("]]></column-value></column>");
537 sb.append(
538 "<column><column-name>createDate</column-name><column-value><![CDATA[");
539 sb.append(getCreateDate());
540 sb.append("]]></column-value></column>");
541 sb.append(
542 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
543 sb.append(getModifiedDate());
544 sb.append("]]></column-value></column>");
545 sb.append(
546 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
547 sb.append(getParentCategoryId());
548 sb.append("]]></column-value></column>");
549 sb.append(
550 "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
551 sb.append(getLeftCategoryId());
552 sb.append("]]></column-value></column>");
553 sb.append(
554 "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
555 sb.append(getRightCategoryId());
556 sb.append("]]></column-value></column>");
557 sb.append(
558 "<column><column-name>name</column-name><column-value><![CDATA[");
559 sb.append(getName());
560 sb.append("]]></column-value></column>");
561 sb.append(
562 "<column><column-name>title</column-name><column-value><![CDATA[");
563 sb.append(getTitle());
564 sb.append("]]></column-value></column>");
565 sb.append(
566 "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
567 sb.append(getVocabularyId());
568 sb.append("]]></column-value></column>");
569
570 sb.append("</model>");
571
572 return sb.toString();
573 }
574
575 private String _uuid;
576 private String _originalUuid;
577 private long _categoryId;
578 private long _groupId;
579 private long _originalGroupId;
580 private boolean _setOriginalGroupId;
581 private long _companyId;
582 private long _userId;
583 private String _userUuid;
584 private String _userName;
585 private Date _createDate;
586 private Date _modifiedDate;
587 private long _parentCategoryId;
588 private long _originalParentCategoryId;
589 private boolean _setOriginalParentCategoryId;
590 private long _leftCategoryId;
591 private long _rightCategoryId;
592 private String _name;
593 private String _title;
594 private long _vocabularyId;
595 private transient ExpandoBridge _expandoBridge;
596 }