001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.portlet.asset.model.AssetCategory;
021 import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
022
023 import java.util.ArrayList;
024 import java.util.List;
025
026
029 public class AssetCategoryImpl extends AssetCategoryBaseImpl {
030
031 public AssetCategoryImpl() {
032 }
033
034 public List<AssetCategory> getAncestors()
035 throws PortalException, SystemException {
036
037 List<AssetCategory> categories = new ArrayList<AssetCategory>();
038
039 AssetCategory category = this;
040
041 while (!category.isRootCategory()) {
042 category = AssetCategoryLocalServiceUtil.getAssetCategory(
043 category.getParentCategoryId());
044
045 categories.add(category);
046 }
047
048 return categories;
049 }
050
051 @Override
052 public String getTitle(String languageId) {
053 String value = super.getTitle(languageId);
054
055 if (Validator.isNull(value)) {
056 value = getName();
057 }
058
059 return value;
060 }
061
062 @Override
063 public String getTitle(String languageId, boolean useDefault) {
064 String value = super.getTitle(languageId, useDefault);
065
066 if (Validator.isNull(value)) {
067 value = getName();
068 }
069
070 return value;
071 }
072
073 public boolean isRootCategory() {
074 if (getParentCategoryId() == 0) {
075 return true;
076 }
077
078 return false;
079 }
080
081 }