From bf70d3fb00cfe3a1b385b9c4a1970b24348609a4 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 21 Nov 2020 21:57:44 +0100 Subject: [PATCH] CategoryManagement Former-commit-id: 8a1effe4bb890f439726cfd9282dbaef13678019 --- .../categories/CategoriesController.java | 96 ++++++++---- .../categories/CategoryDetailsModel.java | 100 ++++++++++++- .../categories/CategoryFormController.java | 49 +++++-- .../admin/categories/CategoryNodeModel.java | 58 ++++++-- .../admin/categories/CategoryPathModel.java | 63 ++++++++ .../CategorySystemDetailsModel.java | 26 +++- .../ui/admin/categories/CategoryTableRow.java | 137 ------------------ .../ui/admin/categories/DomainNodeModel.java | 61 ++++++++ .../components/libreccm/deleteDialog.xhtml | 26 ++-- .../libreccm/localizedStringEditor.xhtml | 3 +- .../admin/categories/category-details.xhtml | 46 ++++-- .../ui/admin/categories/category-form.xhtml | 27 ++-- .../categories/categorysystem-details.xhtml | 5 +- .../org/libreccm/ui/AdminBundle.properties | 54 +++++++ .../org/libreccm/ui/AdminBundle_de.properties | 54 +++++++ 15 files changed, 565 insertions(+), 240 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java delete mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java index af84030bb..794122db0 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java @@ -30,6 +30,8 @@ import org.libreccm.ui.Message; import org.libreccm.ui.MessageType; import org.libreccm.ui.admin.AdminMessages; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Locale; import java.util.Optional; @@ -38,13 +40,17 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.mvc.Models; -import javax.mvc.MvcContext; +import javax.servlet.http.HttpServletRequest; import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.Encoded; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; /** * @@ -72,7 +78,7 @@ public class CategoriesController { @Inject private Models models; - + @GET @Path("/{categoryIdentifier}") @AuthorizationRequired @@ -163,7 +169,37 @@ public class CategoriesController { public String newSubCategory( @PathParam("categoryIdentifier") final String categoryIdentifier ) { - return "org/libreccm/ui/admin/categories/category-form.xhtml"; + final Identifier identifier = identifierParser.parseIdentifier( + categoryIdentifier + ); + final Optional result; + switch (identifier.getType()) { + case ID: + result = categoryRepository.findById( + Long.parseLong(identifier.getIdentifier()) + ); + break; + default: + result = categoryRepository.findByUuid( + identifier.getIdentifier() + ); + break; + } + + if (result.isPresent()) { + categoryDetailsModel.setParentCategory(result.get()); + return "org/libreccm/ui/admin/categories/category-form.xhtml"; + } else { + categoryDetailsModel.addMessage( + new Message( + adminMessages.getMessage( + "categories.not_found.message", + Arrays.asList(categoryIdentifier) + ), MessageType.WARNING + ) + ); + return "org/libreccm/ui/admin/categories/category-not-found.xhtml"; + } } @POST @@ -306,17 +342,16 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}/title/add") + @Path("/{identifier}/title/add") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String addTitle( - @PathParam("categoryIdentifier") - final String categoryIdentifierParam, + @PathParam("identifier") final String identifierParam, @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { final Identifier identifier = identifierParser.parseIdentifier( - categoryIdentifierParam + identifierParam ); final Optional result; switch (identifier.getType()) { @@ -347,7 +382,7 @@ public class CategoriesController { new Message( adminMessages.getMessage( "categories.not_found.message", - Arrays.asList(categoryIdentifierParam) + Arrays.asList(identifierParam) ), MessageType.WARNING ) ); @@ -356,17 +391,16 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}/title/${locale}/edit") + @Path("/{identifier}/title/{locale}/edit") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String editTitle( - @PathParam("categoryIdentifier") - final String categoryIdentifierParam, + @PathParam("identifier") final String identifierParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { final Identifier identifier = identifierParser.parseIdentifier( - categoryIdentifierParam + identifierParam ); final Optional result; switch (identifier.getType()) { @@ -397,7 +431,7 @@ public class CategoriesController { new Message( adminMessages.getMessage( "categories.not_found.message", - Arrays.asList(categoryIdentifierParam) + Arrays.asList(identifierParam) ), MessageType.WARNING ) ); @@ -406,10 +440,11 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}/title/${locale}/remove") + @Path("/{identifier}/title/{locale}/remove") @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) public String removeTitle( - @PathParam("categoryIdentifier") + @PathParam("identifier") final String categoryIdentifierParam, @PathParam("locale") final String localeParam ) { @@ -454,16 +489,16 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}description/add") + @Path("/{identifier}decsription/add") @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) public String addDescription( - @PathParam("categoryIdentifier") - final String categoryIdentifierParam, + @PathParam("identifier") final String identifierParam, @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { final Identifier identifier = identifierParser.parseIdentifier( - categoryIdentifierParam + identifierParam ); final Optional result; switch (identifier.getType()) { @@ -494,7 +529,7 @@ public class CategoriesController { new Message( adminMessages.getMessage( "categories.not_found.message", - Arrays.asList(categoryIdentifierParam) + Arrays.asList(identifierParam) ), MessageType.WARNING ) ); @@ -503,16 +538,17 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}/description/${locale}/edit") + @Path("/{identifier}/description/{locale}/edit") + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) public String editDescription( - @PathParam("categoryIdentifier") - final String categoryIdentifierParam, + @PathParam("identifier") final String identifierParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { final Identifier identifier = identifierParser.parseIdentifier( - categoryIdentifierParam + identifierParam ); final Optional result; switch (identifier.getType()) { @@ -543,7 +579,7 @@ public class CategoriesController { new Message( adminMessages.getMessage( "categories.not_found.message", - Arrays.asList(categoryIdentifierParam) + Arrays.asList(identifierParam) ), MessageType.WARNING ) ); @@ -552,15 +588,15 @@ public class CategoriesController { } @POST - @Path("/{categoryIdentifier}/description/${locale}/remove") + @Path("/{identifier}/description/{locale}/remove") @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) public String removeDescription( - @PathParam("categoryIdentifier") - final String categoryIdentifierParam, + @PathParam("identifier") final String identifierParam, @PathParam("locale") final String localeParam ) { final Identifier identifier = identifierParser.parseIdentifier( - categoryIdentifierParam + identifierParam ); final Optional result; switch (identifier.getType()) { @@ -591,7 +627,7 @@ public class CategoriesController { new Message( adminMessages.getMessage( "categories.not_found.message", - Arrays.asList(categoryIdentifierParam) + Arrays.asList(identifierParam) ), MessageType.WARNING ) ); diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java index 0aba4b14a..c34a21867 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java @@ -20,14 +20,19 @@ package org.libreccm.ui.admin.categories; import org.libreccm.categorization.Category; import org.libreccm.categorization.CategoryManager; +import org.libreccm.categorization.Domain; +import org.libreccm.categorization.DomainRepository; +import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.ui.Message; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -47,6 +52,12 @@ public class CategoryDetailsModel { @Inject private CategoryManager categoryManager; + @Inject + private DomainRepository domainRepository; + + @Inject + private GlobalizationHelper globalizationHelper; + private long categoryId; private String uuid; @@ -59,8 +70,12 @@ public class CategoryDetailsModel { private Map title; + private List unusedTitleLocales; + private Map description; + private List unusedDescriptionLocales; + private boolean enabled; private boolean visible; @@ -71,6 +86,8 @@ public class CategoryDetailsModel { private CategoryNodeModel parentCategory; + private CategoryPathModel categoryPath; + private long categoryOrder; private final List messages; @@ -109,10 +126,26 @@ public class CategoryDetailsModel { return Collections.unmodifiableMap(title); } + public List getUnusedTitleLocales() { + return Collections.unmodifiableList(unusedTitleLocales); + } + + public boolean hasUnusedTitleLocales() { + return !unusedTitleLocales.isEmpty(); + } + public Map getDescription() { return Collections.unmodifiableMap(description); } + public List getUnusedDescriptionLocales() { + return Collections.unmodifiableList(unusedDescriptionLocales); + } + + public boolean hasUnusedDescriptionLocales() { + return !unusedDescriptionLocales.isEmpty(); + } + public boolean isEnabled() { return enabled; } @@ -137,6 +170,10 @@ public class CategoryDetailsModel { parentCategory = buildCategoryNodeModel(parent); } + public CategoryPathModel getCategoryPath() { + return categoryPath; + } + public long getCategoryOrder() { return categoryOrder; } @@ -174,6 +211,9 @@ public class CategoryDetailsModel { uniqueId = category.getUniqueId(); name = category.getName(); path = categoryManager.getCategoryPath(category); + + final List availableLocales = globalizationHelper + .getAvailableLocales(); title = category .getTitle() .getValues() @@ -185,6 +225,16 @@ public class CategoryDetailsModel { entry -> entry.getValue() ) ); + final Set titleLocales = category + .getTitle() + .getAvailableLocales(); + unusedTitleLocales = availableLocales + .stream() + .filter(locale -> !titleLocales.contains(locale)) + .map(Locale::toString) + .sorted() + .collect(Collectors.toList()); + description = category .getDescription() .getValues() @@ -196,6 +246,16 @@ public class CategoryDetailsModel { entry -> entry.getValue() ) ); + final Set descriptionLocales = category + .getDescription() + .getAvailableLocales(); + unusedDescriptionLocales = availableLocales + .stream() + .filter(locale -> !descriptionLocales.contains(locale)) + .map(Locale::toString) + .sorted() + .collect(Collectors.toList()); + enabled = category.isEnabled(); visible = category.isVisible(); abstractCategory = category.isAbstractCategory(); @@ -205,10 +265,23 @@ public class CategoryDetailsModel { .map(this::buildCategoryNodeModel) .sorted() .collect(Collectors.toList()); - parentCategory = buildCategoryNodeModel(category.getParentCategory()); + if (category.getParentCategory() != null) { + parentCategory + = buildCategoryNodeModel(category.getParentCategory()); + } + categoryPath = buildCategoryPathModel(category); categoryOrder = category.getCategoryOrder(); } + private DomainNodeModel buildDomainNodeModel(final Domain domain) { + final DomainNodeModel model = new DomainNodeModel(); + model.setDomainId(domain.getObjectId()); + model.setUuid(domain.getUuid()); + model.setDomainKey(domain.getDomainKey()); + + return model; + } + private CategoryNodeModel buildCategoryNodeModel(final Category category) { final CategoryNodeModel model = new CategoryNodeModel(); model.setCategoryId(category.getObjectId()); @@ -217,7 +290,32 @@ public class CategoryDetailsModel { model.setName(category.getName()); model.setPath(categoryManager.getCategoryPath(category)); model.setCategoryOrder(category.getCategoryOrder()); + model.setEnabled(category.isEnabled()); + model.setVisible(category.isVisible()); + model.setAbstractCategory(category.isAbstractCategory()); return model; } + private CategoryPathModel buildCategoryPathModel(final Category category) { + return buildCategoryPathModel(category, new CategoryPathModel()); + } + + private CategoryPathModel buildCategoryPathModel( + final Category category, + final CategoryPathModel categoryPathModel + ) { + categoryPathModel.addCategoryAtBegin(buildCategoryNodeModel(category)); + final Category parent = category.getParentCategory(); + if (parent == null) { + final Optional domain = domainRepository + .findByRootCategory(category); + if (domain.isPresent()) { + categoryPathModel.setDomain(buildDomainNodeModel(domain.get())); + } + return categoryPathModel; + } else { + return buildCategoryPathModel(parent, categoryPathModel); + } + } + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java index 3ecaa31b8..36e88016f 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java @@ -23,6 +23,8 @@ import org.libreccm.api.IdentifierParser; import org.libreccm.categorization.Category; import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryRepository; +import org.libreccm.categorization.Domain; +import org.libreccm.categorization.DomainRepository; import org.libreccm.core.CoreConstants; import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.RequiresPrivilege; @@ -63,6 +65,9 @@ public class CategoryFormController { @Inject private CategoryRepository categoryRepository; + @Inject + private DomainRepository domainRepository; + @Inject private IdentifierParser identifierParser; @@ -73,13 +78,13 @@ public class CategoryFormController { private String name; @FormParam("enabled") - private boolean enabled; + private String enabled; @FormParam("visible") - private boolean visible; + private String visible; @FormParam("abstractCategory") - private boolean abstractCategory; + private String abstractCategory; @POST @Path("/{parentCategoryIdentifier}/new") @@ -113,17 +118,33 @@ public class CategoryFormController { final Category category = new Category(); category.setUniqueId(uniqueId); category.setName(name); - category.setEnabled(enabled); - category.setVisible(visible); - category.setAbstractCategory(abstractCategory); + category.setEnabled(enabled != null); + category.setVisible(visible != null); + category.setAbstractCategory(abstractCategory != null); categoryRepository.save(category); categoryManager.addSubCategoryToCategory(category, parentCategory); - return String.format( - "redirect:categorymanager/categories/ID-%s", - parentCategory.getObjectId() - ); + if (parentCategory.getParentCategory() == null) { + final Optional categorySystem = domainRepository + .findByRootCategory(parentCategory); + if (categorySystem.isPresent()) { + return String.format( + "redirect:categorymanager/categorysystems/ID-%d/details", + categorySystem.get().getObjectId() + ); + } else { + return String.format( + "redirect:categorymanager/categories/ID-%d/details", + parentCategory.getObjectId() + ); + } + } else { + return String.format( + "redirect:categorymanager/categories/ID-%d/details", + parentCategory.getObjectId() + ); + } } else { categoryDetailsModel.addMessage( new Message( @@ -143,7 +164,7 @@ public class CategoryFormController { @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) @Transactional(Transactional.TxType.REQUIRED) public String updateCategory( - @PathParam("categoryIdentifierParam") + @PathParam("categoryIdentifier") final String categoryIdentifierParam ) { final Identifier identifier = identifierParser.parseIdentifier( @@ -169,9 +190,9 @@ public class CategoryFormController { final Category category = result.get(); category.setUniqueId(uniqueId); category.setName(name); - category.setEnabled(enabled); - category.setVisible(visible); - category.setAbstractCategory(abstractCategory); + category.setEnabled(enabled != null); + category.setVisible(visible != null); + category.setAbstractCategory(abstractCategory != null); categoryRepository.save(category); diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java index f435f7a37..3ff21db32 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java @@ -18,8 +18,6 @@ */ package org.libreccm.ui.admin.categories; -import org.libreccm.categorization.Category; - import java.util.Objects; /** @@ -35,9 +33,15 @@ public class CategoryNodeModel implements Comparable { private String uniqueId; private String name; - + private String path; + private boolean enabled; + + private boolean visible; + + private boolean abstractCategory; + private long categoryOrder; public long getCategoryId() { @@ -47,15 +51,15 @@ public class CategoryNodeModel implements Comparable { protected void setCategoryId(final long categoryId) { this.categoryId = categoryId; } - + public String getIdentifier() { return String.format("ID-%d", categoryId); } - + public String getUuid() { return uuid; } - + protected void setUuid(final String uuid) { this.uuid = uuid; } @@ -63,7 +67,7 @@ public class CategoryNodeModel implements Comparable { public String getUniqueId() { return uniqueId; } - + protected void setUniqueId(final String uniqueId) { this.uniqueId = uniqueId; } @@ -71,15 +75,15 @@ public class CategoryNodeModel implements Comparable { public String getName() { return name; } - + protected void setName(final String name) { this.name = name; } - + public String getPath() { return path; } - + protected void setPath(final String path) { this.path = path; } @@ -91,22 +95,46 @@ public class CategoryNodeModel implements Comparable { protected void setCategoryOrder(final long categoryOrder) { this.categoryOrder = categoryOrder; } - + + public boolean isEnabled() { + return enabled; + } + + protected void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + public boolean isVisible() { + return visible; + } + + protected void setVisible(final boolean visible) { + this.visible = visible; + } + + public boolean isAbstractCategory() { + return abstractCategory; + } + + protected void setAbstractCategory(final boolean abstractCategory) { + this.abstractCategory = abstractCategory; + } + @Override public int compareTo(final CategoryNodeModel other) { int result = Long.compare( categoryOrder, Objects.requireNonNull(other).getCategoryOrder() ); - + if (result == 0) { result = Objects.compare( - name, - Objects.requireNonNull(other).getName(), + name, + Objects.requireNonNull(other).getName(), String::compareTo ); } - + return result; } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java new file mode 100644 index 000000000..181bb8ea1 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2020 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.ui.admin.categories; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * + * @author Jens Pelzetter + */ +public class CategoryPathModel { + + private DomainNodeModel domain; + + private List categories; + + public CategoryPathModel() { + categories = new ArrayList<>(); + } + + public DomainNodeModel getDomain() { + return domain; + } + + protected void setDomain(final DomainNodeModel domain) { + this.domain = domain; + } + + public List getCategories() { + return Collections.unmodifiableList(categories); + } + + protected void addCategory(final CategoryNodeModel category) { + categories.add(category); + } + + protected void addCategoryAtBegin(final CategoryNodeModel category) { + categories.add(0, category); + } + + protected void setCategories(final List categories) { + this.categories = new ArrayList<>(categories); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java index 2487a9535..9dbc13ed9 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java @@ -18,6 +18,8 @@ */ package org.libreccm.ui.admin.categories; +import org.libreccm.categorization.Category; +import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.Domain; import org.libreccm.categorization.DomainOwnership; import org.libreccm.l10n.GlobalizationHelper; @@ -54,6 +56,9 @@ public class CategorySystemDetailsModel { @Inject private ApplicationRepository applicationRepository; + @Inject + private CategoryManager categoryManager; + @Inject private GlobalizationHelper globalizationHelper; @@ -83,7 +88,7 @@ public class CategorySystemDetailsModel { private String rootIdentifier; - private List categories; + private List categories; private final List messages; @@ -194,7 +199,7 @@ public class CategorySystemDetailsModel { return Collections.unmodifiableList(ownerOptions); } - public List getCategories() { + public List getCategories() { return Collections.unmodifiableList(categories); } @@ -238,6 +243,7 @@ public class CategorySystemDetailsModel { .withZone(ZoneOffset.systemDefault()) .format(domain.getReleased()); } + final List availableLocales = globalizationHelper .getAvailableLocales(); title = domain @@ -310,7 +316,7 @@ public class CategorySystemDetailsModel { .getRoot() .getSubCategories() .stream() - .map(CategoryTableRow::new) + .map(this::buildCategoryTableRow) .sorted() .collect(Collectors.toList()); } @@ -331,5 +337,19 @@ public class CategorySystemDetailsModel { return ownerRow; } + + private CategoryNodeModel buildCategoryTableRow(final Category category) { + final CategoryNodeModel row = new CategoryNodeModel(); + row.setCategoryId(category.getObjectId()); + row.setUuid(category.getUuid()); + row.setUniqueId(category.getUniqueId()); + row.setName(category.getName()); + row.setPath(categoryManager.getCategoryPath(category)); + row.setEnabled(category.isEnabled()); + row.setVisible(category.isVisible()); + row.setAbstractCategory(category.isAbstractCategory()); + row.setCategoryOrder(category.getCategoryOrder()); + return row; + } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java deleted file mode 100644 index ddb95eb26..000000000 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2020 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package org.libreccm.ui.admin.categories; - -import org.libreccm.categorization.Category; - -import java.util.Objects; - -/** - * - * @author Jens Pelzetter - */ -public class CategoryTableRow implements Comparable { - - private long categoryId; - - private String uuid; - - private String uniqueId; - - private String name; - - private boolean enabled; - - private boolean visible; - - private boolean abstractCategory; - - private long categoryOrder; - - public CategoryTableRow() { - super(); - } - - public CategoryTableRow(final Category category) { - categoryId = category.getObjectId(); - uuid = category.getUuid(); - uniqueId = category.getUniqueId(); - name = category.getName(); - enabled = category.isEnabled(); - visible = category.isVisible(); - abstractCategory = category.isAbstractCategory(); - categoryOrder = category.getCategoryOrder(); - } - - public long getCategoryId() { - return categoryId; - } - - protected void setCategoryId(final long categoryId) { - this.categoryId = categoryId; - } - - public String getUuid() { - return uuid; - } - - protected void setUuid(final String uuid) { - this.uuid = uuid; - } - - public String getIdentifier() { - return String.format("UUID-%s", uuid); - } - - public String getUniqueId() { - return uniqueId; - } - - protected void setUniqueId(final String uniqueId) { - this.uniqueId = uniqueId; - } - - public String getName() { - return name; - } - - protected void setName(final String name) { - this.name = name; - } - - public boolean isEnabled() { - return enabled; - } - - protected void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - public boolean isVisible() { - return visible; - } - - protected void setVisible(final boolean visible) { - this.visible = visible; - } - - public boolean isAbstractCategory() { - return abstractCategory; - } - - protected void setAbstractCategory(final boolean abstractCategory) { - this.abstractCategory = abstractCategory; - } - - public long getCategoryOrder() { - return categoryOrder; - } - - protected void setCategoryOrder(final long categoryOrder) { - this.categoryOrder = categoryOrder; - } - - @Override - public int compareTo(final CategoryTableRow other) { - return Long.compare( - categoryOrder, Objects.requireNonNull(other).getCategoryOrder() - ); - } - -} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java new file mode 100644 index 000000000..b5ec284f1 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2020 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.ui.admin.categories; + +/** + * + * @author Jens Pelzetter + */ +public class DomainNodeModel { + + private long domainId; + + private String uuid; + + private String domainKey; + + public long getDomainId() { + return domainId; + } + + protected void setDomainId(final long domainId) { + this.domainId = domainId; + } + + public String getIdentifier() { + return String.format("ID-%s", domainId); + } + + public String getUuid() { + return uuid; + } + + protected void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getDomainKey() { + return domainKey; + } + + protected void setDomainKey(final String domainKey) { + this.domainKey = domainKey; + } + +} diff --git a/ccm-core/src/main/resources/META-INF/resources/components/libreccm/deleteDialog.xhtml b/ccm-core/src/main/resources/META-INF/resources/components/libreccm/deleteDialog.xhtml index a84166be1..c661863db 100644 --- a/ccm-core/src/main/resources/META-INF/resources/components/libreccm/deleteDialog.xhtml +++ b/ccm-core/src/main/resources/META-INF/resources/components/libreccm/deleteDialog.xhtml @@ -9,7 +9,7 @@ shortDescription="URL to POST request is send." /> + id="#{cc.attrs.dialogId}-dialog-title">#{cc.attrs.dialogTitle} + id="#{cc.attrs.dialogId}-dialog-title">#{cc.attrs.dialogTitle} + id="#{cc.attrs.dialogId}-dialog-title">#{cc.attrs.dialogTitle} + id="#{cc.attrs.dialogId}-dialog-title">#{cc.attrs.dialogTitle} + id="#{cc.attrs.dialogId}-dialog-title">#{cc.attrs.dialogTitle} -
#{cc.attrs.addDialogTitle}
+
#{cc.attrs.dialogTitle}
- +