001
014
015 package com.liferay.portlet.asset.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.language.LanguageUtil;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.HtmlUtil;
022 import com.liferay.portal.kernel.util.LocaleUtil;
023 import com.liferay.portal.kernel.util.LocalizationUtil;
024 import com.liferay.portal.kernel.util.StringBundler;
025 import com.liferay.portal.kernel.util.StringPool;
026 import com.liferay.portal.kernel.util.Validator;
027 import com.liferay.portal.model.impl.BaseModelImpl;
028 import com.liferay.portal.service.ServiceContext;
029 import com.liferay.portal.util.PortalUtil;
030
031 import com.liferay.portlet.asset.model.AssetCategory;
032 import com.liferay.portlet.asset.model.AssetCategoryModel;
033 import com.liferay.portlet.asset.model.AssetCategorySoap;
034 import com.liferay.portlet.expando.model.ExpandoBridge;
035 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
036
037 import java.io.Serializable;
038
039 import java.lang.reflect.Proxy;
040
041 import java.sql.Types;
042
043 import java.util.ArrayList;
044 import java.util.Date;
045 import java.util.List;
046 import java.util.Locale;
047 import java.util.Map;
048
049
061 public class AssetCategoryModelImpl extends BaseModelImpl<AssetCategory>
062 implements AssetCategoryModel {
063 public static final String TABLE_NAME = "AssetCategory";
064 public static final Object[][] TABLE_COLUMNS = {
065 { "uuid_", new Integer(Types.VARCHAR) },
066 { "categoryId", new Integer(Types.BIGINT) },
067 { "groupId", new Integer(Types.BIGINT) },
068 { "companyId", new Integer(Types.BIGINT) },
069 { "userId", new Integer(Types.BIGINT) },
070 { "userName", new Integer(Types.VARCHAR) },
071 { "createDate", new Integer(Types.TIMESTAMP) },
072 { "modifiedDate", new Integer(Types.TIMESTAMP) },
073 { "parentCategoryId", new Integer(Types.BIGINT) },
074 { "leftCategoryId", new Integer(Types.BIGINT) },
075 { "rightCategoryId", new Integer(Types.BIGINT) },
076 { "name", new Integer(Types.VARCHAR) },
077 { "title", new Integer(Types.VARCHAR) },
078 { "vocabularyId", new Integer(Types.BIGINT) }
079 };
080 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)";
081 public static final String TABLE_SQL_DROP = "drop table AssetCategory";
082 public static final String ORDER_BY_JPQL = " ORDER BY assetCategory.name ASC";
083 public static final String ORDER_BY_SQL = " ORDER BY AssetCategory.name ASC";
084 public static final String DATA_SOURCE = "liferayDataSource";
085 public static final String SESSION_FACTORY = "liferaySessionFactory";
086 public static final String TX_MANAGER = "liferayTransactionManager";
087 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088 "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
089 true);
090 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091 "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
092 true);
093
094 public static AssetCategory toModel(AssetCategorySoap soapModel) {
095 AssetCategory model = new AssetCategoryImpl();
096
097 model.setUuid(soapModel.getUuid());
098 model.setCategoryId(soapModel.getCategoryId());
099 model.setGroupId(soapModel.getGroupId());
100 model.setCompanyId(soapModel.getCompanyId());
101 model.setUserId(soapModel.getUserId());
102 model.setUserName(soapModel.getUserName());
103 model.setCreateDate(soapModel.getCreateDate());
104 model.setModifiedDate(soapModel.getModifiedDate());
105 model.setParentCategoryId(soapModel.getParentCategoryId());
106 model.setLeftCategoryId(soapModel.getLeftCategoryId());
107 model.setRightCategoryId(soapModel.getRightCategoryId());
108 model.setName(soapModel.getName());
109 model.setTitle(soapModel.getTitle());
110 model.setVocabularyId(soapModel.getVocabularyId());
111
112 return model;
113 }
114
115 public static List<AssetCategory> toModels(AssetCategorySoap[] soapModels) {
116 List<AssetCategory> models = new ArrayList<AssetCategory>(soapModels.length);
117
118 for (AssetCategorySoap soapModel : soapModels) {
119 models.add(toModel(soapModel));
120 }
121
122 return models;
123 }
124
125 public static final String MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME = com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME;
126 public static final boolean FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES =
127 com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES;
128 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129 "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategory"));
130
131 public AssetCategoryModelImpl() {
132 }
133
134 public long getPrimaryKey() {
135 return _categoryId;
136 }
137
138 public void setPrimaryKey(long pk) {
139 setCategoryId(pk);
140 }
141
142 public Serializable getPrimaryKeyObj() {
143 return new Long(_categoryId);
144 }
145
146 public String getUuid() {
147 if (_uuid == null) {
148 return StringPool.BLANK;
149 }
150 else {
151 return _uuid;
152 }
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 if (_userName == null) {
219 return StringPool.BLANK;
220 }
221 else {
222 return _userName;
223 }
224 }
225
226 public void setUserName(String userName) {
227 _userName = userName;
228 }
229
230 public Date getCreateDate() {
231 return _createDate;
232 }
233
234 public void setCreateDate(Date createDate) {
235 _createDate = createDate;
236 }
237
238 public Date getModifiedDate() {
239 return _modifiedDate;
240 }
241
242 public void setModifiedDate(Date modifiedDate) {
243 _modifiedDate = modifiedDate;
244 }
245
246 public long getParentCategoryId() {
247 return _parentCategoryId;
248 }
249
250 public void setParentCategoryId(long parentCategoryId) {
251 _parentCategoryId = parentCategoryId;
252
253 if (!_setOriginalParentCategoryId) {
254 _setOriginalParentCategoryId = true;
255
256 _originalParentCategoryId = parentCategoryId;
257 }
258 }
259
260 public long getOriginalParentCategoryId() {
261 return _originalParentCategoryId;
262 }
263
264 public long getLeftCategoryId() {
265 return _leftCategoryId;
266 }
267
268 public void setLeftCategoryId(long leftCategoryId) {
269 _leftCategoryId = leftCategoryId;
270 }
271
272 public long getRightCategoryId() {
273 return _rightCategoryId;
274 }
275
276 public void setRightCategoryId(long rightCategoryId) {
277 _rightCategoryId = rightCategoryId;
278 }
279
280 public String getName() {
281 if (_name == null) {
282 return StringPool.BLANK;
283 }
284 else {
285 return _name;
286 }
287 }
288
289 public void setName(String name) {
290 _name = name;
291
292 if (_originalName == null) {
293 _originalName = name;
294 }
295 }
296
297 public String getOriginalName() {
298 return GetterUtil.getString(_originalName);
299 }
300
301 public String getTitle() {
302 if (_title == null) {
303 return StringPool.BLANK;
304 }
305 else {
306 return _title;
307 }
308 }
309
310 public String getTitle(Locale locale) {
311 String languageId = LocaleUtil.toLanguageId(locale);
312
313 return getTitle(languageId);
314 }
315
316 public String getTitle(Locale locale, boolean useDefault) {
317 String languageId = LocaleUtil.toLanguageId(locale);
318
319 return getTitle(languageId, useDefault);
320 }
321
322 public String getTitle(String languageId) {
323 String value = LocalizationUtil.getLocalization(getTitle(), languageId);
324
325 if (isEscapedModel()) {
326 return HtmlUtil.escape(value);
327 }
328 else {
329 return value;
330 }
331 }
332
333 public String getTitle(String languageId, boolean useDefault) {
334 String value = LocalizationUtil.getLocalization(getTitle(), languageId,
335 useDefault);
336
337 if (isEscapedModel()) {
338 return HtmlUtil.escape(value);
339 }
340 else {
341 return value;
342 }
343 }
344
345 public Map<Locale, String> getTitleMap() {
346 return LocalizationUtil.getLocalizationMap(getTitle());
347 }
348
349 public void setTitle(String title) {
350 _title = title;
351 }
352
353 public void setTitle(Locale locale, String title) {
354 String languageId = LocaleUtil.toLanguageId(locale);
355
356 if (Validator.isNotNull(title)) {
357 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
358 title, languageId));
359 }
360 else {
361 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
362 languageId));
363 }
364 }
365
366 public void setTitleMap(Map<Locale, String> titleMap) {
367 if (titleMap == null) {
368 return;
369 }
370
371 Locale[] locales = LanguageUtil.getAvailableLocales();
372
373 for (Locale locale : locales) {
374 String title = titleMap.get(locale);
375
376 setTitle(locale, title);
377 }
378 }
379
380 public long getVocabularyId() {
381 return _vocabularyId;
382 }
383
384 public void setVocabularyId(long vocabularyId) {
385 _vocabularyId = vocabularyId;
386
387 if (!_setOriginalVocabularyId) {
388 _setOriginalVocabularyId = true;
389
390 _originalVocabularyId = vocabularyId;
391 }
392 }
393
394 public long getOriginalVocabularyId() {
395 return _originalVocabularyId;
396 }
397
398 public AssetCategory toEscapedModel() {
399 if (isEscapedModel()) {
400 return (AssetCategory)this;
401 }
402 else {
403 return (AssetCategory)Proxy.newProxyInstance(AssetCategory.class.getClassLoader(),
404 new Class[] { AssetCategory.class },
405 new AutoEscapeBeanHandler(this));
406 }
407 }
408
409 public ExpandoBridge getExpandoBridge() {
410 if (_expandoBridge == null) {
411 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
412 AssetCategory.class.getName(), getPrimaryKey());
413 }
414
415 return _expandoBridge;
416 }
417
418 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
419 getExpandoBridge().setAttributes(serviceContext);
420 }
421
422 public Object clone() {
423 AssetCategoryImpl clone = new AssetCategoryImpl();
424
425 clone.setUuid(getUuid());
426 clone.setCategoryId(getCategoryId());
427 clone.setGroupId(getGroupId());
428 clone.setCompanyId(getCompanyId());
429 clone.setUserId(getUserId());
430 clone.setUserName(getUserName());
431 clone.setCreateDate(getCreateDate());
432 clone.setModifiedDate(getModifiedDate());
433 clone.setParentCategoryId(getParentCategoryId());
434 clone.setLeftCategoryId(getLeftCategoryId());
435 clone.setRightCategoryId(getRightCategoryId());
436 clone.setName(getName());
437 clone.setTitle(getTitle());
438 clone.setVocabularyId(getVocabularyId());
439
440 return clone;
441 }
442
443 public int compareTo(AssetCategory assetCategory) {
444 int value = 0;
445
446 value = getName().compareTo(assetCategory.getName());
447
448 if (value != 0) {
449 return value;
450 }
451
452 return 0;
453 }
454
455 public boolean equals(Object obj) {
456 if (obj == null) {
457 return false;
458 }
459
460 AssetCategory assetCategory = null;
461
462 try {
463 assetCategory = (AssetCategory)obj;
464 }
465 catch (ClassCastException cce) {
466 return false;
467 }
468
469 long pk = assetCategory.getPrimaryKey();
470
471 if (getPrimaryKey() == pk) {
472 return true;
473 }
474 else {
475 return false;
476 }
477 }
478
479 public int hashCode() {
480 return (int)getPrimaryKey();
481 }
482
483 public String toString() {
484 StringBundler sb = new StringBundler(29);
485
486 sb.append("{uuid=");
487 sb.append(getUuid());
488 sb.append(", categoryId=");
489 sb.append(getCategoryId());
490 sb.append(", groupId=");
491 sb.append(getGroupId());
492 sb.append(", companyId=");
493 sb.append(getCompanyId());
494 sb.append(", userId=");
495 sb.append(getUserId());
496 sb.append(", userName=");
497 sb.append(getUserName());
498 sb.append(", createDate=");
499 sb.append(getCreateDate());
500 sb.append(", modifiedDate=");
501 sb.append(getModifiedDate());
502 sb.append(", parentCategoryId=");
503 sb.append(getParentCategoryId());
504 sb.append(", leftCategoryId=");
505 sb.append(getLeftCategoryId());
506 sb.append(", rightCategoryId=");
507 sb.append(getRightCategoryId());
508 sb.append(", name=");
509 sb.append(getName());
510 sb.append(", title=");
511 sb.append(getTitle());
512 sb.append(", vocabularyId=");
513 sb.append(getVocabularyId());
514 sb.append("}");
515
516 return sb.toString();
517 }
518
519 public String toXmlString() {
520 StringBundler sb = new StringBundler(46);
521
522 sb.append("<model><model-name>");
523 sb.append("com.liferay.portlet.asset.model.AssetCategory");
524 sb.append("</model-name>");
525
526 sb.append(
527 "<column><column-name>uuid</column-name><column-value><![CDATA[");
528 sb.append(getUuid());
529 sb.append("]]></column-value></column>");
530 sb.append(
531 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
532 sb.append(getCategoryId());
533 sb.append("]]></column-value></column>");
534 sb.append(
535 "<column><column-name>groupId</column-name><column-value><![CDATA[");
536 sb.append(getGroupId());
537 sb.append("]]></column-value></column>");
538 sb.append(
539 "<column><column-name>companyId</column-name><column-value><![CDATA[");
540 sb.append(getCompanyId());
541 sb.append("]]></column-value></column>");
542 sb.append(
543 "<column><column-name>userId</column-name><column-value><![CDATA[");
544 sb.append(getUserId());
545 sb.append("]]></column-value></column>");
546 sb.append(
547 "<column><column-name>userName</column-name><column-value><![CDATA[");
548 sb.append(getUserName());
549 sb.append("]]></column-value></column>");
550 sb.append(
551 "<column><column-name>createDate</column-name><column-value><![CDATA[");
552 sb.append(getCreateDate());
553 sb.append("]]></column-value></column>");
554 sb.append(
555 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
556 sb.append(getModifiedDate());
557 sb.append("]]></column-value></column>");
558 sb.append(
559 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
560 sb.append(getParentCategoryId());
561 sb.append("]]></column-value></column>");
562 sb.append(
563 "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
564 sb.append(getLeftCategoryId());
565 sb.append("]]></column-value></column>");
566 sb.append(
567 "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
568 sb.append(getRightCategoryId());
569 sb.append("]]></column-value></column>");
570 sb.append(
571 "<column><column-name>name</column-name><column-value><![CDATA[");
572 sb.append(getName());
573 sb.append("]]></column-value></column>");
574 sb.append(
575 "<column><column-name>title</column-name><column-value><![CDATA[");
576 sb.append(getTitle());
577 sb.append("]]></column-value></column>");
578 sb.append(
579 "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
580 sb.append(getVocabularyId());
581 sb.append("]]></column-value></column>");
582
583 sb.append("</model>");
584
585 return sb.toString();
586 }
587
588 private String _uuid;
589 private String _originalUuid;
590 private long _categoryId;
591 private long _groupId;
592 private long _originalGroupId;
593 private boolean _setOriginalGroupId;
594 private long _companyId;
595 private long _userId;
596 private String _userUuid;
597 private String _userName;
598 private Date _createDate;
599 private Date _modifiedDate;
600 private long _parentCategoryId;
601 private long _originalParentCategoryId;
602 private boolean _setOriginalParentCategoryId;
603 private long _leftCategoryId;
604 private long _rightCategoryId;
605 private String _name;
606 private String _originalName;
607 private String _title;
608 private long _vocabularyId;
609 private long _originalVocabularyId;
610 private boolean _setOriginalVocabularyId;
611 private transient ExpandoBridge _expandoBridge;
612 }