1
14
15 package com.liferay.portlet.asset.model.impl;
16
17 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
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.StringBundler;
24 import com.liferay.portal.kernel.util.Validator;
25 import com.liferay.portal.model.impl.BaseModelImpl;
26 import com.liferay.portal.service.ServiceContext;
27 import com.liferay.portal.util.PortalUtil;
28
29 import com.liferay.portlet.asset.model.AssetCategory;
30 import com.liferay.portlet.asset.model.AssetCategorySoap;
31 import com.liferay.portlet.expando.model.ExpandoBridge;
32 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
33
34 import com.liferay.util.LocalizationUtil;
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 return GetterUtil.getString(_uuid);
153 }
154
155 public void setUuid(String uuid) {
156 _uuid = uuid;
157
158 if (_originalUuid == null) {
159 _originalUuid = uuid;
160 }
161 }
162
163 public String getOriginalUuid() {
164 return GetterUtil.getString(_originalUuid);
165 }
166
167 public long getCategoryId() {
168 return _categoryId;
169 }
170
171 public void setCategoryId(long categoryId) {
172 _categoryId = categoryId;
173 }
174
175 public long getGroupId() {
176 return _groupId;
177 }
178
179 public void setGroupId(long groupId) {
180 _groupId = groupId;
181
182 if (!_setOriginalGroupId) {
183 _setOriginalGroupId = true;
184
185 _originalGroupId = groupId;
186 }
187 }
188
189 public long getOriginalGroupId() {
190 return _originalGroupId;
191 }
192
193 public long getCompanyId() {
194 return _companyId;
195 }
196
197 public void setCompanyId(long companyId) {
198 _companyId = companyId;
199 }
200
201 public long getUserId() {
202 return _userId;
203 }
204
205 public void setUserId(long userId) {
206 _userId = userId;
207 }
208
209 public String getUserUuid() throws SystemException {
210 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
211 }
212
213 public void setUserUuid(String userUuid) {
214 _userUuid = userUuid;
215 }
216
217 public String getUserName() {
218 return GetterUtil.getString(_userName);
219 }
220
221 public void setUserName(String userName) {
222 _userName = userName;
223 }
224
225 public Date getCreateDate() {
226 return _createDate;
227 }
228
229 public void setCreateDate(Date createDate) {
230 _createDate = createDate;
231 }
232
233 public Date getModifiedDate() {
234 return _modifiedDate;
235 }
236
237 public void setModifiedDate(Date modifiedDate) {
238 _modifiedDate = modifiedDate;
239 }
240
241 public long getParentCategoryId() {
242 return _parentCategoryId;
243 }
244
245 public void setParentCategoryId(long parentCategoryId) {
246 _parentCategoryId = parentCategoryId;
247
248 if (!_setOriginalParentCategoryId) {
249 _setOriginalParentCategoryId = true;
250
251 _originalParentCategoryId = parentCategoryId;
252 }
253 }
254
255 public long getOriginalParentCategoryId() {
256 return _originalParentCategoryId;
257 }
258
259 public long getLeftCategoryId() {
260 return _leftCategoryId;
261 }
262
263 public void setLeftCategoryId(long leftCategoryId) {
264 _leftCategoryId = leftCategoryId;
265 }
266
267 public long getRightCategoryId() {
268 return _rightCategoryId;
269 }
270
271 public void setRightCategoryId(long rightCategoryId) {
272 _rightCategoryId = rightCategoryId;
273 }
274
275 public String getName() {
276 return GetterUtil.getString(_name);
277 }
278
279 public void setName(String name) {
280 _name = name;
281 }
282
283 public String getTitle() {
284 return GetterUtil.getString(_title);
285 }
286
287 public String getTitle(Locale locale) {
288 String languageId = LocaleUtil.toLanguageId(locale);
289
290 return getTitle(languageId);
291 }
292
293 public String getTitle(Locale locale, boolean useDefault) {
294 String languageId = LocaleUtil.toLanguageId(locale);
295
296 return getTitle(languageId, useDefault);
297 }
298
299 public String getTitle(String languageId) {
300 String value = LocalizationUtil.getLocalization(getTitle(), languageId);
301
302 if (isEscapedModel()) {
303 return HtmlUtil.escape(value);
304 }
305 else {
306 return value;
307 }
308 }
309
310 public String getTitle(String languageId, boolean useDefault) {
311 String value = LocalizationUtil.getLocalization(getTitle(), languageId,
312 useDefault);
313
314 if (isEscapedModel()) {
315 return HtmlUtil.escape(value);
316 }
317 else {
318 return value;
319 }
320 }
321
322 public Map<Locale, String> getTitleMap() {
323 return LocalizationUtil.getLocalizationMap(getTitle());
324 }
325
326 public void setTitle(String title) {
327 _title = title;
328 }
329
330 public void setTitle(Locale locale, String title) {
331 String languageId = LocaleUtil.toLanguageId(locale);
332
333 if (Validator.isNotNull(title)) {
334 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
335 title, languageId));
336 }
337 else {
338 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
339 languageId));
340 }
341 }
342
343 public void setTitleMap(Map<Locale, String> titleMap) {
344 if (titleMap == null) {
345 return;
346 }
347
348 Locale[] locales = LanguageUtil.getAvailableLocales();
349
350 for (Locale locale : locales) {
351 String title = titleMap.get(locale);
352
353 setTitle(locale, title);
354 }
355 }
356
357 public long getVocabularyId() {
358 return _vocabularyId;
359 }
360
361 public void setVocabularyId(long vocabularyId) {
362 _vocabularyId = vocabularyId;
363 }
364
365 public AssetCategory toEscapedModel() {
366 if (isEscapedModel()) {
367 return (AssetCategory)this;
368 }
369 else {
370 AssetCategory model = new AssetCategoryImpl();
371
372 model.setNew(isNew());
373 model.setEscapedModel(true);
374
375 model.setUuid(HtmlUtil.escape(getUuid()));
376 model.setCategoryId(getCategoryId());
377 model.setGroupId(getGroupId());
378 model.setCompanyId(getCompanyId());
379 model.setUserId(getUserId());
380 model.setUserName(HtmlUtil.escape(getUserName()));
381 model.setCreateDate(getCreateDate());
382 model.setModifiedDate(getModifiedDate());
383 model.setParentCategoryId(getParentCategoryId());
384 model.setLeftCategoryId(getLeftCategoryId());
385 model.setRightCategoryId(getRightCategoryId());
386 model.setName(HtmlUtil.escape(getName()));
387 model.setTitle(getTitle());
388 model.setVocabularyId(getVocabularyId());
389
390 model = (AssetCategory)Proxy.newProxyInstance(AssetCategory.class.getClassLoader(),
391 new Class[] { AssetCategory.class },
392 new ReadOnlyBeanHandler(model));
393
394 return model;
395 }
396 }
397
398 public ExpandoBridge getExpandoBridge() {
399 if (_expandoBridge == null) {
400 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
401 AssetCategory.class.getName(), getPrimaryKey());
402 }
403
404 return _expandoBridge;
405 }
406
407 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
408 getExpandoBridge().setAttributes(serviceContext);
409 }
410
411 public Object clone() {
412 AssetCategoryImpl clone = new AssetCategoryImpl();
413
414 clone.setUuid(getUuid());
415 clone.setCategoryId(getCategoryId());
416 clone.setGroupId(getGroupId());
417 clone.setCompanyId(getCompanyId());
418 clone.setUserId(getUserId());
419 clone.setUserName(getUserName());
420 clone.setCreateDate(getCreateDate());
421 clone.setModifiedDate(getModifiedDate());
422 clone.setParentCategoryId(getParentCategoryId());
423 clone.setLeftCategoryId(getLeftCategoryId());
424 clone.setRightCategoryId(getRightCategoryId());
425 clone.setName(getName());
426 clone.setTitle(getTitle());
427 clone.setVocabularyId(getVocabularyId());
428
429 return clone;
430 }
431
432 public int compareTo(AssetCategory assetCategory) {
433 int value = 0;
434
435 value = getName().compareTo(assetCategory.getName());
436
437 if (value != 0) {
438 return value;
439 }
440
441 return 0;
442 }
443
444 public boolean equals(Object obj) {
445 if (obj == null) {
446 return false;
447 }
448
449 AssetCategory assetCategory = null;
450
451 try {
452 assetCategory = (AssetCategory)obj;
453 }
454 catch (ClassCastException cce) {
455 return false;
456 }
457
458 long pk = assetCategory.getPrimaryKey();
459
460 if (getPrimaryKey() == pk) {
461 return true;
462 }
463 else {
464 return false;
465 }
466 }
467
468 public int hashCode() {
469 return (int)getPrimaryKey();
470 }
471
472 public String toString() {
473 StringBundler sb = new StringBundler(29);
474
475 sb.append("{uuid=");
476 sb.append(getUuid());
477 sb.append(", categoryId=");
478 sb.append(getCategoryId());
479 sb.append(", groupId=");
480 sb.append(getGroupId());
481 sb.append(", companyId=");
482 sb.append(getCompanyId());
483 sb.append(", userId=");
484 sb.append(getUserId());
485 sb.append(", userName=");
486 sb.append(getUserName());
487 sb.append(", createDate=");
488 sb.append(getCreateDate());
489 sb.append(", modifiedDate=");
490 sb.append(getModifiedDate());
491 sb.append(", parentCategoryId=");
492 sb.append(getParentCategoryId());
493 sb.append(", leftCategoryId=");
494 sb.append(getLeftCategoryId());
495 sb.append(", rightCategoryId=");
496 sb.append(getRightCategoryId());
497 sb.append(", name=");
498 sb.append(getName());
499 sb.append(", title=");
500 sb.append(getTitle());
501 sb.append(", vocabularyId=");
502 sb.append(getVocabularyId());
503 sb.append("}");
504
505 return sb.toString();
506 }
507
508 public String toXmlString() {
509 StringBundler sb = new StringBundler(46);
510
511 sb.append("<model><model-name>");
512 sb.append("com.liferay.portlet.asset.model.AssetCategory");
513 sb.append("</model-name>");
514
515 sb.append(
516 "<column><column-name>uuid</column-name><column-value><![CDATA[");
517 sb.append(getUuid());
518 sb.append("]]></column-value></column>");
519 sb.append(
520 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
521 sb.append(getCategoryId());
522 sb.append("]]></column-value></column>");
523 sb.append(
524 "<column><column-name>groupId</column-name><column-value><![CDATA[");
525 sb.append(getGroupId());
526 sb.append("]]></column-value></column>");
527 sb.append(
528 "<column><column-name>companyId</column-name><column-value><![CDATA[");
529 sb.append(getCompanyId());
530 sb.append("]]></column-value></column>");
531 sb.append(
532 "<column><column-name>userId</column-name><column-value><![CDATA[");
533 sb.append(getUserId());
534 sb.append("]]></column-value></column>");
535 sb.append(
536 "<column><column-name>userName</column-name><column-value><![CDATA[");
537 sb.append(getUserName());
538 sb.append("]]></column-value></column>");
539 sb.append(
540 "<column><column-name>createDate</column-name><column-value><![CDATA[");
541 sb.append(getCreateDate());
542 sb.append("]]></column-value></column>");
543 sb.append(
544 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
545 sb.append(getModifiedDate());
546 sb.append("]]></column-value></column>");
547 sb.append(
548 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
549 sb.append(getParentCategoryId());
550 sb.append("]]></column-value></column>");
551 sb.append(
552 "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
553 sb.append(getLeftCategoryId());
554 sb.append("]]></column-value></column>");
555 sb.append(
556 "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
557 sb.append(getRightCategoryId());
558 sb.append("]]></column-value></column>");
559 sb.append(
560 "<column><column-name>name</column-name><column-value><![CDATA[");
561 sb.append(getName());
562 sb.append("]]></column-value></column>");
563 sb.append(
564 "<column><column-name>title</column-name><column-value><![CDATA[");
565 sb.append(getTitle());
566 sb.append("]]></column-value></column>");
567 sb.append(
568 "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
569 sb.append(getVocabularyId());
570 sb.append("]]></column-value></column>");
571
572 sb.append("</model>");
573
574 return sb.toString();
575 }
576
577 private String _uuid;
578 private String _originalUuid;
579 private long _categoryId;
580 private long _groupId;
581 private long _originalGroupId;
582 private boolean _setOriginalGroupId;
583 private long _companyId;
584 private long _userId;
585 private String _userUuid;
586 private String _userName;
587 private Date _createDate;
588 private Date _modifiedDate;
589 private long _parentCategoryId;
590 private long _originalParentCategoryId;
591 private boolean _setOriginalParentCategoryId;
592 private long _leftCategoryId;
593 private long _rightCategoryId;
594 private String _name;
595 private String _title;
596 private long _vocabularyId;
597 private transient ExpandoBridge _expandoBridge;
598 }