Search in sources :

Example 11 with Category

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

the class ContentManagerTest method testGetXML.

@Test
public void testGetXML() throws Throwable {
    String typeCode = "ART";
    // @formatter:off
    when(entityTypeFactory.extractEntityType(typeCode, Content.class, contentManager.getConfigItemName(), this.entityTypeDom, contentManager.getName(), this.entityDom)).thenReturn(this.createFakeEntity(typeCode, "contentview", "1"));
    // @formatter:on
    Content content = contentManager.createContentType(typeCode);
    ContentDOM contentDOM = new ContentDOM();
    contentDOM.setRootElementName("content");
    content.setEntityDOM(contentDOM);
    content.setId("ART1");
    content.setTypeCode("Articolo");
    content.setTypeDescription("Articolo");
    content.setDescription("descrizione");
    content.setStatus(Content.STATUS_DRAFT);
    content.setMainGroup("free");
    Category cat13 = new Category();
    cat13.setCode("13");
    content.addCategory(cat13);
    Category cat19 = new Category();
    cat19.setCode("19");
    content.addCategory(cat19);
    String xml = content.getXML();
    assertNotNull(xml);
    assertTrue(xml.indexOf("<content id=\"ART1\" typecode=\"Articolo\" typedescr=\"Articolo\">") != -1);
    assertTrue(xml.indexOf("<descr>descrizione</descr>") != -1);
    assertTrue(xml.indexOf("<status>" + Content.STATUS_DRAFT + "</status>") != -1);
    assertTrue(xml.indexOf("<category id=\"13\" />") != -1);
    assertTrue(xml.indexOf("<category id=\"19\" />") != -1);
}
Also used : Category(com.agiletec.aps.system.services.category.Category) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ContentDOM(com.agiletec.plugins.jacms.aps.system.services.content.parse.ContentDOM) Test(org.junit.Test)

Example 12 with Category

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

the class TestContentManager method testGetXML.

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

Example 13 with Category

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

the class ContentCategoryBulkAction method initBulkCommand.

private BaseContentPropertyBulkCommand<Category> initBulkCommand(List<Category> categories) {
    String commandBeanName = ApsAdminSystemConstants.DELETE == this.getStrutsAction() ? RemoveCategoryBulkCommand.BEAN_NAME : JoinCategoryBulkCommand.BEAN_NAME;
    WebApplicationContext applicationContext = ApsWebApplicationUtils.getWebApplicationContext(this.getRequest());
    BaseContentPropertyBulkCommand<Category> command = (BaseContentPropertyBulkCommand<Category>) applicationContext.getBean(commandBeanName);
    ContentPropertyBulkCommandContext<Category> context = new ContentPropertyBulkCommandContext<Category>(this.getSelectedIds(), categories, this.getCurrentUser(), new DefaultBulkCommandTracer<String>());
    command.init(context);
    return command;
}
Also used : BaseContentPropertyBulkCommand(org.entando.entando.plugins.jacms.aps.system.services.content.command.common.BaseContentPropertyBulkCommand) Category(com.agiletec.aps.system.services.category.Category) ContentPropertyBulkCommandContext(org.entando.entando.plugins.jacms.aps.system.services.content.command.common.ContentPropertyBulkCommandContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 14 with Category

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

the class ResourceDAO method getCategoryCodes.

/**
 * Restituisce la lista di codici di categorie associate ad una risorsa. La
 * risorsa viene sempre referenziata con la categoria "root" della tipologia
 * relativa (che corrisponde al codice della tipologia).
 *
 * @param resource La risorsa da inserire o da modificare.
 * @return Il set di codici di categorie.
 */
private Set<String> getCategoryCodes(ResourceInterface resource) {
    Set<String> codes = new HashSet<String>();
    Iterator<Category> categoryIter = resource.getCategories().iterator();
    while (categoryIter.hasNext()) {
        Category category = (Category) categoryIter.next();
        this.addCategoryCode(resource, category, codes);
    }
    return codes;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) HashSet(java.util.HashSet)

Example 15 with Category

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

the class TestResourceAction method testDelete.

/*
	 * NOTE: we create a fake resource using the manager rather than the most obvious 'save' action.
	 *
	 */
public void testDelete() throws Throwable {
    ResourceInterface resource = this._resourceManager.createResourceType("Image");
    String resourceId = null;
    String result = null;
    ResourceAction action = null;
    assertNotNull(resource);
    try {
        this.setUserOnSession("admin");
        resource.setMainGroup(Group.FREE_GROUP_NAME);
        resource.setDescr("Levò la bocca dal fero pasto quel peccator");
        resource.setCategories(new ArrayList<Category>());
        this._resourceManager.addResource(resource);
        resourceId = resource.getId();
        ResourceInterface verify = this._resourceManager.loadResource(resourceId);
        assertNotNull(verify);
        // test with invalid ID
        this.initAction("/do/jacms/Resource", "delete");
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = (ResourceAction) this.getAction();
        assertEquals(1, action.getActionErrors().size());
        // test with a valid ID
        this.initAction("/do/jacms/Resource", "delete");
        this.addParameter("resourceId", resourceId);
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        verify = this._resourceManager.loadResource(resourceId);
        assertNull(verify);
    } catch (Throwable t) {
        throw t;
    } finally {
        this._resourceManager.deleteResource(resource);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Aggregations

Category (com.agiletec.aps.system.services.category.Category)91 ArrayList (java.util.ArrayList)23 ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)9 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 List (java.util.List)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 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 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 Cache (org.springframework.cache.Cache)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 HashSet (java.util.HashSet)3