Search in sources :

Example 66 with Category

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

the class TestCategoryAction method testTrashCategory.

public void testTrashCategory() throws Throwable {
    String categoryCode = "cat_temp";
    assertNull(this._categoryManager.getCategory(categoryCode));
    try {
        String result = this.saveNewCategory("admin", categoryCode);
        assertEquals(Action.SUCCESS, result);
        Category category = this._categoryManager.getCategory(categoryCode);
        assertNotNull(category);
        this.initAction("/do/Category", "trash");
        this.addParameter("selectedNode", categoryCode);
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        category = this._categoryManager.getCategory(categoryCode);
        assertNotNull(category);
    } catch (Throwable t) {
        throw t;
    } finally {
        this._categoryManager.deleteCategory(categoryCode);
        assertNull(this._categoryManager.getCategory(categoryCode));
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 67 with Category

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

the class TestCategoryAction method testDeleteCategory_2.

public void testDeleteCategory_2() throws Throwable {
    this.setUserOnSession("admin");
    String categoryCode = "general_cat1";
    assertNotNull(this._categoryManager.getCategory(categoryCode));
    try {
        this.initAction("/do/Category", "trash");
        this.addParameter("selectedNode", categoryCode);
        String result = this.executeAction();
        assertEquals("references", result);
        Category category = this._categoryManager.getCategory(categoryCode);
        assertNotNull(category);
        Map<String, Object> references = ((CategoryAction) this.getAction()).getReferences();
        assertNotNull(references);
        assertEquals(2, references.size());
        this.initAction("/do/Category", "delete");
        this.addParameter("selectedNode", categoryCode);
        result = this.executeAction();
        assertEquals("references", result);
        category = this._categoryManager.getCategory(categoryCode);
        assertNotNull(category);
        references = ((CategoryAction) this.getAction()).getReferences();
        assertNotNull(references);
        assertEquals(2, references.size());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 68 with Category

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

the class ContentCategoryAction method joinCategory.

/**
 * Performs the action of adding of a category to the content.
 * @return The result code.
 */
public String joinCategory() {
    this.updateContentOnSession();
    try {
        String categoryCode = this.getCategoryCode();
        Category category = this.getCategoryManager().getCategory(categoryCode);
        if (null != category && !category.getCode().equals(category.getParentCode()) && !this.getContent().getCategories().contains(category)) {
            this.getContent().addCategory(category);
        }
    } catch (Throwable t) {
        _logger.error("error in joinCategory", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 69 with Category

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

the class ContentFinderAction method getContents.

/**
 * Restituisce la lista identificativi di contenuti che deve essere erogata
 * dall'interfaccia di visualizzazione dei contenuti. La lista deve essere
 * filtrata secondo i parametri di ricerca impostati.
 *
 * @return La lista di contenuti che deve essere erogata dall'interfaccia di
 *         visualizzazione dei contenuti.
 */
public List<String> getContents() {
    List<String> result = null;
    try {
        ContentFinderSearchInfo searchInfo = getContentSearchInfo();
        List<String> allowedGroups = this.getContentGroupCodes();
        String[] categories = null;
        Category category = this.getCategoryManager().getCategory(this.getCategoryCode());
        if (null != category && !category.isRoot()) {
            String catCode = this.getCategoryCode().trim();
            categories = new String[] { catCode };
            searchInfo.setCategoryCode(catCode);
        } else {
            searchInfo.setCategoryCode(null);
        }
        result = this.getContentManager().loadWorkContentsId(categories, this.getFilters(), allowedGroups);
    } catch (Throwable t) {
        _logger.error("error in getContents", t);
        throw new RuntimeException("error in getContents", t);
    }
    return result;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 70 with Category

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

the class CategoryAction method checkDelete.

/**
 * Perform all the needed checks before deleting a category. When errors are
 * detected a new actionMessaged, containing the appropriate error code and
 * messaged, is created.
 *
 * @return null if the deletion operation is successful, otherwise the error
 * code
 */
protected String checkDelete() {
    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(currentCategory.getParentCode())) {
        _logger.info("Home category not deletable");
        this.addActionError(this.getText("error.category.homeDelete.notAllowed"));
        return "categoryTree";
    }
    if (currentCategory.getChildrenCodes().length != 0) {
        _logger.info("Category with children not deletable");
        this.addActionError(this.getText("error.category.deleteWithChildren.notAllowed"));
        return "categoryTree";
    }
    this.extractReferencingObjects(this.getSelectedNode());
    if (null != this.getReferences() && this.getReferences().size() > 0) {
        return "references";
    }
    return null;
}
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