Search in sources :

Example 71 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class CategoryAction method extractCategoryFormValues.

protected String extractCategoryFormValues() {
    String selectedNode = this.getSelectedNode();
    try {
        Category category = this.getCategory(selectedNode);
        if (null == category) {
            this.addActionError(this.getText("error.category.selectCategory"));
            return "categoryTree";
        }
        this.setParentCategoryCode(category.getParentCode());
        this.setCategoryCode(category.getCode());
        this.setTitles(category.getTitles());
    } catch (Throwable t) {
        _logger.error("error in extractCategoryFormValues", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 72 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class CategoryAction method delete.

public String delete() {
    String selectedNode = this.getSelectedNode();
    try {
        String check = this.checkDelete();
        if (null != check) {
            return check;
        }
        Category currentCategory = this.getCategory(selectedNode);
        this.getCategoryManager().deleteCategory(selectedNode);
        this.setSelectedNode(currentCategory.getParent().getCode());
    } catch (Throwable t) {
        _logger.error("error in delete", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 73 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class CategoryAction method executeMoveTree.

public String executeMoveTree() {
    String selectedNode = this.getSelectedNode();
    String parentCategoryCode = this.getRequest().getParameter("parentCategoryCode");
    try {
        String check = this.checkMoveCategory(selectedNode, parentCategoryCode);
        if (null != check) {
            return check;
        }
        Category currentCategory = this.getCategory(this.getSelectedNode());
        Category parent = this.getCategory(parentCategoryCode);
        this.getCategoryManager().moveCategory(currentCategory, parent);
    } catch (Throwable t) {
        _logger.error("error in move executeMoveTree", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 74 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class CategoryAction method checkMoveCategory.

protected String checkMoveCategory(String selectedNode, String parentCategoryCode) {
    if (this.getCategoryManager().getMoveTreeStatus() != ICategoryManager.STATUS_READY) {
        this.addActionError(this.getText("error.category.move.updateReferencesRunning"));
        return "categoryTree";
    }
    Category currentCategory = this.getCategory(this.getSelectedNode());
    if (null == currentCategory) {
        _logger.info("Required a selected node");
        this.addActionError(this.getText("error.category.selectCategory"));
        return "categoryTree";
    }
    if (currentCategory.getCode().equals(this.getCategoryManager().getRoot().getCode())) {
        _logger.info("Root category cannot be moved");
        this.addActionError(this.getText("error.category.move.rootNotAllowed"));
        return "categoryTree";
    }
    if ("".equals(parentCategoryCode) || null == this.getCategoryManager().getCategory(parentCategoryCode)) {
        this.addActionError(this.getText("error.category.move.selectCategoryParent"));
        return "categoryTree";
    }
    Category parent = this.getCategory(parentCategoryCode);
    if (null == parent) {
        _logger.info("Required a selected node");
        this.addActionError(this.getText("error.category.selectCategoryParent"));
        return "categoryTree";
    }
    if (parent.getCode().equals(currentCategory.getParentCode())) {
        _logger.debug("trying to move a node under it's own parent..");
        return "categoryTree";
    }
    if (parent.isChildOf(selectedNode)) {
        List<String> args = new ArrayList<String>();
        args.add(parent.getCode());
        args.add(selectedNode);
        this.addActionError(this.getText("error.category.move.parentUnderChild.notAllowed"));
        return "categoryTree";
    }
    return null;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList)

Example 75 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class CategoryAction method getSubBreadCrumbsTargets.

private void getSubBreadCrumbsTargets(List<Category> categories, Category current) {
    categories.add(0, current);
    Category parent = current.getParent();
    if (parent != null && !parent.getCode().equals(current.getCode())) {
        this.getSubBreadCrumbsTargets(categories, parent);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Aggregations

Category (com.agiletec.aps.system.services.category.Category)85 ArrayList (java.util.ArrayList)21 ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)9 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)7 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)5 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)4 List (java.util.List)4 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 IDataObjectSearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager)4 SearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 HashSet (java.util.HashSet)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3