Search in sources :

Example 56 with Category

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

the class ResourceManagerIntegrationTest method getMockResource.

private ResourceDataBean getMockResource(String resourceType, String mainGroup, String resDescrToAdd, String categoryCodeToAdd) {
    File file = new File("target/test/entando_logo.jpg");
    MockResourceDataBean bean = new MockResourceDataBean();
    bean.setFile(file);
    bean.setDescr(resDescrToAdd);
    bean.setMainGroup(mainGroup);
    bean.setResourceType(resourceType);
    bean.setMimeType("image/jpeg");
    List<Category> categories = new ArrayList<Category>();
    ICategoryManager catManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
    Category cat = catManager.getCategory(categoryCodeToAdd);
    categories.add(cat);
    bean.setCategories(categories);
    return bean;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) MockResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.mock.MockResourceDataBean) ArrayList(java.util.ArrayList) File(java.io.File) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 57 with Category

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

the class TestSearchEngineManager method testSearchContentsId_5.

public void testSearchContentsId_5() throws Throwable {
    try {
        Thread thread = this._searchEngineManager.startReloadContentsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this._searchEngineManager;
        Category general_cat2 = this._categoryManager.getCategory("general_cat2");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general_cat2);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        assertTrue(contentsId.isEmpty());
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        String[] expected1 = { "ART111", "ART120" };
        this.verify(contentsId, expected1);
        Category general_cat1 = this._categoryManager.getCategory("general_cat1");
        categories.add(general_cat1);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART111" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) ArrayList(java.util.ArrayList)

Example 58 with Category

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

the class TestDataObjectManager method testGetXML.

public void testGetXML() throws Throwable {
    DataObject dataObject = this._dataObjectManager.createDataObject("ART");
    dataObject.setId("ART1");
    dataObject.setTypeCode("Articolo");
    dataObject.setTypeDescription("Articolo");
    dataObject.setDescription("descrizione");
    dataObject.setStatus(DataObject.STATUS_DRAFT);
    dataObject.setMainGroup("free");
    Category cat13 = new Category();
    cat13.setCode("13");
    dataObject.addCategory(cat13);
    Category cat19 = new Category();
    cat19.setCode("19");
    dataObject.addCategory(cat19);
    String xml = dataObject.getXML();
    assertNotNull(xml);
    assertTrue(xml.indexOf("<dataObject id=\"ART1\" typecode=\"Articolo\" typedescr=\"Articolo\">") != -1);
    assertTrue(xml.indexOf("<descr>descrizione</descr>") != -1);
    assertTrue(xml.indexOf("<status>" + DataObject.STATUS_DRAFT + "</status>") != -1);
    assertTrue(xml.indexOf("<category id=\"13\" />") != -1);
    assertTrue(xml.indexOf("<category id=\"19\" />") != -1);
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) Category(com.agiletec.aps.system.services.category.Category)

Example 59 with Category

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

the class ResourceAction method joinRemoveCategory.

/**
 * This method perfoms either the linking of a resource to a category or the
 * removal of such association. NOTE: in the current implementation
 * operations carried on invalid or unknown categories do not return error
 * code on purpose, since the join or unlink process does not take place.
 *
 * @param isJoin
 * if 'true' associates a resource to a category, otherwise remove it
 * @param categoryCode
 * the string code of the category to work with.
 * @return FAILURE if error detected, SUCCESS otherwise.
 */
private String joinRemoveCategory(boolean isJoin, String categoryCode) {
    try {
        Category category = this.getCategory(categoryCode);
        if (category == null)
            return SUCCESS;
        List<String> categories = this.getCategoryCodes();
        if (isJoin) {
            if (!categories.contains(categoryCode)) {
                categories.add(categoryCode);
            }
        } else {
            categories.remove(categoryCode);
        }
    } catch (Throwable t) {
        _logger.error("error in joinRemoveCategory", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 60 with Category

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

the class ResourceAction method getCategories.

@Override
public List<Category> getCategories() {
    List<Category> categories = new ArrayList<Category>(this.getCategoryCodes().size());
    Iterator<String> iter = this.getCategoryCodes().iterator();
    while (iter.hasNext()) {
        String categoryCode = iter.next();
        Category category = this.getCategoryManager().getCategory(categoryCode);
        if (null != category)
            categories.add(category);
    }
    return categories;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList)

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