Search in sources :

Example 61 with Category

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

the class ResourceAction method detail.

public String detail() {
    try {
        ResourceInterface resource = this.loadResource(this.getResourceId());
        if (null == resource) {
            return INPUT;
        }
        this.setResourceTypeCode(resource.getType());
        this.setDescr(resource.getDescription());
        List<Category> resCategories = resource.getCategories();
        for (int i = 0; i < resCategories.size(); i++) {
            Category resCat = resCategories.get(i);
            this.getCategoryCodes().add(resCat.getCode());
        }
        this.setMainGroup(resource.getMainGroup());
    } catch (Throwable t) {
        _logger.error("error in detail", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 62 with Category

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

the class ContentCategoryBulkAction method join.

public String join() {
    try {
        String categoryCode = this.getCategoryCode();
        Category category = this.getCategoryManager().getCategory(categoryCode);
        if (null != category && !category.isRoot()) {
            this.getCategoryCodes().add(categoryCode);
        }
    } catch (Throwable t) {
        _logger.error("Error joining category for bulk action", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 63 with Category

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

the class ContentBulkActionHelper method getCategoriesToManage.

@Override
public List<Category> getCategoriesToManage(Collection<String> categoryCodes, ValidationAware validation, TextProvider textProvider) {
    boolean allowed = true;
    List<Category> categories = new ArrayList<Category>();
    if (categoryCodes == null || categoryCodes.isEmpty()) {
        validation.addActionError(textProvider.getText("error.bulk.categories.empty"));
        allowed = false;
    } else {
        ICategoryManager categoryManager = this.getCategoryManager();
        for (String categoryCode : categoryCodes) {
            Category category = categoryManager.getCategory(categoryCode);
            if (category == null || category.isRoot()) {
                validation.addActionError(textProvider.getText("error.bulk.categories.notAllowed", new String[] { categoryCode }));
                allowed = false;
            } else {
                categories.add(category);
            }
        }
    }
    return allowed ? categories : null;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 64 with Category

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

the class TestCategoryAction method testAddCategory_2.

public void testAddCategory_2() throws Throwable {
    String expectedCategoryCode = "titolo_italiano";
    assertNull(this._categoryManager.getCategory(expectedCategoryCode));
    try {
        Map<String, String> params = new HashMap<String, String>();
        params.put("parentCategoryCode", this._categoryManager.getRoot().getCode());
        params.put("strutsAction", "1");
        params.put("langit", "Titolo Italiano");
        params.put("langen", "English Title");
        String result = this.executeSaveCategory("admin", params);
        assertEquals(Action.SUCCESS, result);
        Category category = this._categoryManager.getCategory(expectedCategoryCode);
        assertNotNull(category);
        assertEquals("Titolo Italiano", category.getTitles().getProperty("it"));
        assertEquals(this._categoryManager.getRoot().getCode(), category.getParent().getCode());
    } catch (Throwable t) {
        throw t;
    } finally {
        this._categoryManager.deleteCategory(expectedCategoryCode);
        assertNull(this._categoryManager.getCategory(expectedCategoryCode));
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) HashMap(java.util.HashMap)

Example 65 with Category

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

the class TestCategoryAction method testCategoryDetails_2.

public void testCategoryDetails_2() throws Throwable {
    String categoryCode = "general_cat1";
    Category category = this._categoryManager.getCategory(categoryCode);
    assertNotNull(category);
    try {
        String result = this.executeCategoryDetail("admin", categoryCode);
        assertEquals(Action.SUCCESS, result);
        CategoryAction action = (CategoryAction) this.getAction();
        assertEquals(category.getCode(), action.getCategoryCode());
        assertEquals(category.getTitle("it"), action.getTitles().get("it"));
        assertEquals(category.getTitle("en"), action.getTitles().get("en"));
        assertNotNull(action.getReferences());
        assertEquals(2, action.getReferences().size());
    } catch (Throwable t) {
        throw t;
    }
}
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