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