Search in sources :

Example 46 with Category

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

the class TestSearchEngineManager method testSearchContentsId_6.

public void testSearchContentsId_6() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(contentsId, expected1);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 47 with Category

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

the class TestSearchEngineManager method testSearchFacetedContents_1.

public void testSearchFacetedContents_1() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
        assertNotNull(result);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(result.getContentsId(), expected1);
        assertEquals(4, result.getOccurrences().size());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : FacetedContentsResult(org.entando.entando.aps.system.services.searchengine.FacetedContentsResult) Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 48 with Category

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

the class CategoryService method updateCategory.

@Override
public CategoryDto updateCategory(CategoryDto categoryDto) {
    Category parentCategory = this.getCategoryManager().getCategory(categoryDto.getParentCode());
    if (null == parentCategory) {
        throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_PARENT_CATEGORY_NOT_FOUND, "parent category", categoryDto.getParentCode());
    }
    Category category = this.getCategoryManager().getCategory(categoryDto.getCode());
    if (null == category) {
        throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_CATEGORY_NOT_FOUND, "category", categoryDto.getCode());
    }
    CategoryDto dto = null;
    try {
        category.setParentCode(categoryDto.getParentCode());
        category.getTitles().clear();
        category.getTitles().putAll(categoryDto.getTitles());
        this.getCategoryManager().updateCategory(category);
        dto = this.getDtoBuilder().convert(this.getCategoryManager().getCategory(categoryDto.getCode()));
    } catch (Exception e) {
        logger.error("error updating category " + categoryDto.getCode(), e);
        throw new RestServerError("error updating category " + categoryDto.getCode(), e);
    }
    return dto;
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) CategoryDto(org.entando.entando.aps.system.services.category.model.CategoryDto) Category(com.agiletec.aps.system.services.category.Category) RestServerError(org.entando.entando.aps.system.exception.RestServerError) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException)

Example 49 with Category

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

the class DataObjectDAO method addCategoryCode.

private void addCategoryCode(Category category, Set<String> codes) {
    codes.add(category.getCode());
    Category parentCategory = (Category) category.getParent();
    if (null != parentCategory && !parentCategory.getCode().equals(parentCategory.getParentCode())) {
        this.addCategoryCode(parentCategory, codes);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 50 with Category

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

the class CategoryValidator method validatePutReferences.

public void validatePutReferences(String categoryCode, CategoryDto request, BindingResult bindingResult) {
    if (!StringUtils.equals(categoryCode, request.getCode())) {
        bindingResult.rejectValue("code", ERRCODE_URINAME_MISMATCH, new String[] { categoryCode, request.getCode() }, "category.code.mismatch");
        throw new ValidationGenericException(bindingResult);
    }
    Category category = this.getCategoryManager().getCategory(request.getCode());
    if (null == category) {
        bindingResult.reject(ERRCODE_CATEGORY_NOT_FOUND, new String[] { request.getCode() }, "category.notexists");
        throw new RestRourceNotFoundException(bindingResult);
    }
    Category parent = this.getCategoryManager().getCategory(request.getParentCode());
    if (null == parent) {
        bindingResult.reject(ERRCODE_PARENT_CATEGORY_NOT_FOUND, new String[] { request.getCode() }, "category.parent.notexists");
        throw new RestRourceNotFoundException(bindingResult);
    } else if (!parent.getCode().equals(category.getParentCode())) {
        bindingResult.reject(ERRCODE_PARENT_CATEGORY_CANNOT_BE_CHANGED, new String[] {}, "category.parent.cannotBeChanged");
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) Category(com.agiletec.aps.system.services.category.Category) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException)

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