From 30ee6ddd2a6900133aef695d9c51b46fb8875fbf Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Tue, 3 Aug 2021 20:52:14 +0200 Subject: [PATCH] CategoryStep finished --- .../documents/CategorizationStep.java | 50 ++++++++++++++----- .../documents/CategorizationTreeNode.java | 22 ++++---- .../documents/categorization-tree-node.xhtml | 3 +- .../documents/categorization.xhtml | 14 ++++-- .../ui/DefaultAuthoringStepsBundle.properties | 1 + .../DefaultAuthoringStepsBundle_de.properties | 1 + 6 files changed, 64 insertions(+), 27 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationStep.java index 43728c384..5cdceb408 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationStep.java @@ -301,7 +301,7 @@ public class CategorizationStep extends AbstractMvcAuthoringStep { ) { final List assigned = new ArrayList<>(); if (node.isAssigned()) { - assigned.add(String.join("/", parentPath, node.getTitle())); + assigned.add(String.join("/", parentPath, getCategoryLabel(node))); } if (node.isSubCategoryAssigned()) { @@ -311,7 +311,11 @@ public class CategorizationStep extends AbstractMvcAuthoringStep { .stream() .map( subCat -> buildAssignedCategoriesList( - subCat, String.join("/", node.getTitle() + subCat, + String.join( + "/", + parentPath, + getCategoryLabel(node) ) ) ) @@ -355,16 +359,17 @@ public class CategorizationStep extends AbstractMvcAuthoringStep { .map(this::buildCategorizationTreeNode) .collect(Collectors.toList()) ); - node.setSubCategoryAssigned( - category - .getSubCategories() - .stream() - .allMatch( - subCat -> categoryManager.isAssignedToCategory( - subCat, document - ) - ) - ); +// node.setSubCategoryAssigned( +// isSubCategoryAssigned(category) +//// category +//// .getSubCategories() +//// .stream() +//// .allMatch( +//// subCat -> categoryManager.isAssignedToCategory( +//// subCat, document +//// ) +//// ) +// ); node.setTitle( globalizationHelper.getValueFromLocalizedString( category.getTitle() @@ -375,4 +380,25 @@ public class CategorizationStep extends AbstractMvcAuthoringStep { return node; } +// private boolean isSubCategoryAssigned(final Category category) { +// boolean result = false; +// for (final Category subCategory : category.getSubCategories()) { +// result = result || categoryManager.isAssignedToCategory(subCategory, getDocument()); +// +// if (!subCategory.getSubCategories().isEmpty()) { +// result = result || isSubCategoryAssigned(subCategory); +// } +// } +// +// return result; +// } + + private String getCategoryLabel(final CategorizationTreeNode node) { + if (node.getTitle() == null || node.getTitle().isBlank()) { + return node.getCategoryName(); + } else { + return node.getTitle(); + } + } + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationTreeNode.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationTreeNode.java index 994b12d01..0f5909d05 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationTreeNode.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CategorizationTreeNode.java @@ -71,11 +71,11 @@ public class CategorizationTreeNode { */ private boolean assigned; - /** - * Is any subcategory of the category represented by this node assigned to - * the current content item? - */ - private boolean subCategoryAssigned; +// /** +// * Is any subcategory of the category represented by this node assigned to +// * the current content item? +// */ +// private boolean subCategoryAssigned; /** * Nodes for the subcategories of the category represented by this node. @@ -139,12 +139,16 @@ public class CategorizationTreeNode { } public boolean isSubCategoryAssigned() { - return subCategoryAssigned; +// return subCategoryAssigned; + return subCategories + .stream() + .map(CategorizationTreeNode::isAssigned) + .reduce(false, (value1, value2) -> value1 || value2); } - public void setSubCategoryAssigned(final boolean subCategoryAssigned) { - this.subCategoryAssigned = subCategoryAssigned; - } +// public void setSubCategoryAssigned(final boolean subCategoryAssigned) { +// this.subCategoryAssigned = subCategoryAssigned; +// } public List getSubCategories() { return Collections.unmodifiableList(subCategories); diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-tree-node.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-tree-node.xhtml index 9d751d942..216f15ab8 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-tree-node.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-tree-node.xhtml @@ -34,12 +34,13 @@ -
    diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization.xhtml index 09549bf9f..caa1e7a17 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization.xhtml @@ -7,12 +7,14 @@ +

    #{CmsDefaultStepsMessageBundle.getMessage('categorization.title', [CmsSelectedDocumentModel.itemTitle])}

    +

    #{tree.domainTitle}

    - #{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']} + #{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']}