CategoryModel now provides link for category
parent
e7cebdd9ff
commit
b174fe4b75
|
|
@ -20,7 +20,6 @@ package org.librecms.pages.models;
|
||||||
|
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
import org.libreccm.categorization.CategoryManager;
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.categorization.CategoryRepository;
|
|
||||||
import org.libreccm.categorization.Domain;
|
import org.libreccm.categorization.Domain;
|
||||||
import org.libreccm.categorization.DomainRepository;
|
import org.libreccm.categorization.DomainRepository;
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
@ -28,6 +27,7 @@ import org.librecms.contentsection.ContentItemVersion;
|
||||||
import org.librecms.pages.PagesService;
|
import org.librecms.pages.PagesService;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -57,9 +57,6 @@ public class CategoryModel implements Serializable {
|
||||||
@Inject
|
@Inject
|
||||||
private GlobalizationHelper globalizationHelper;
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PagesService pagesService;
|
|
||||||
|
|
||||||
private CategoryDomainData domain;
|
private CategoryDomainData domain;
|
||||||
|
|
||||||
private CategoryData category;
|
private CategoryData category;
|
||||||
|
|
@ -126,6 +123,11 @@ public class CategoryModel implements Serializable {
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public CategoryTreeNode getCategoryTree() {
|
public CategoryTreeNode getCategoryTree() {
|
||||||
|
if (domain == null) {
|
||||||
|
final CategoryTreeNode emptyNode = new CategoryTreeNode();
|
||||||
|
emptyNode.setSubCategories(Collections.emptyList());
|
||||||
|
return emptyNode;
|
||||||
|
}
|
||||||
final Domain currentDomain = domainRepository
|
final Domain currentDomain = domainRepository
|
||||||
.findById(domain.getDomainId())
|
.findById(domain.getDomainId())
|
||||||
.orElseThrow(
|
.orElseThrow(
|
||||||
|
|
@ -148,6 +150,13 @@ public class CategoryModel implements Serializable {
|
||||||
) {
|
) {
|
||||||
final CategoryTreeNode node = new CategoryTreeNode();
|
final CategoryTreeNode node = new CategoryTreeNode();
|
||||||
node.setCategoryPath(categoryManager.getCategoryPath(fromCategory));
|
node.setCategoryPath(categoryManager.getCategoryPath(fromCategory));
|
||||||
|
node.setCategoyLink(
|
||||||
|
String.format(
|
||||||
|
"/pages/%s/index.%s.html",
|
||||||
|
node.getCategoryPath(),
|
||||||
|
globalizationHelper.getNegotiatedLocale().toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
node.setDescription(
|
node.setDescription(
|
||||||
globalizationHelper.getValueFromLocalizedString(
|
globalizationHelper.getValueFromLocalizedString(
|
||||||
fromCategory.getDescription())
|
fromCategory.getDescription())
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ public class CategoryTreeNode {
|
||||||
|
|
||||||
private String categoryPath;
|
private String categoryPath;
|
||||||
|
|
||||||
|
private String categoryLink;
|
||||||
|
|
||||||
private boolean visible;
|
private boolean visible;
|
||||||
|
|
||||||
private boolean selected;
|
private boolean selected;
|
||||||
|
|
@ -88,6 +90,14 @@ public class CategoryTreeNode {
|
||||||
this.categoryPath = categoryPath;
|
this.categoryPath = categoryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCategoryLink() {
|
||||||
|
return categoryLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCategoyLink(final String categoryLink) {
|
||||||
|
this.categoryLink = categoryLink;
|
||||||
|
}
|
||||||
|
|
||||||
public List<CategoryTreeNode> getSubCategories() {
|
public List<CategoryTreeNode> getSubCategories() {
|
||||||
return Collections.unmodifiableList(subCategories);
|
return Collections.unmodifiableList(subCategories);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,6 @@ public class PageUrlModel {
|
||||||
|
|
||||||
breadcrumbs = new ArrayList<>();
|
breadcrumbs = new ArrayList<>();
|
||||||
breadcrumbs = buildBreadcrumbs(categoryModel.getCategoryTree());
|
breadcrumbs = buildBreadcrumbs(categoryModel.getCategoryTree());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProtocol() {
|
public String getProtocol() {
|
||||||
|
|
@ -151,7 +150,10 @@ public class PageUrlModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BreadcrumbData> getBreadcrumbs() {
|
public List<BreadcrumbData> getBreadcrumbs() {
|
||||||
return Collections.unmodifiableList(breadcrumbs);
|
return Optional
|
||||||
|
.ofNullable(breadcrumbs)
|
||||||
|
.map(Collections::unmodifiableList)
|
||||||
|
.orElse(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPageName() {
|
public String getPageName() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue