Search in sources :

Example 16 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 17 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentManagerTest method testCreateContent.

@Test
public void testCreateContent() throws ApsSystemException {
    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 = this.contentManager.createContentType(typeCode);
    assertThat(content, is(not(nullValue())));
    assertThat(content.getViewPage(), is("contentview"));
    assertThat(content.getDefaultModel(), is("1"));
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) Test(org.junit.Test)

Example 18 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 19 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentManager method testLoadOrderedPublicEvents_4.

public void testLoadOrderedPublicEvents_4() throws Throwable {
    Content masterContent = this._contentManager.loadContent("EVN193", true);
    masterContent.setId(null);
    DateAttribute dateAttribute = (DateAttribute) masterContent.getAttribute("DataInizio");
    dateAttribute.setDate(DateConverter.parseDate("17/06/2019", "dd/MM/yyyy"));
    try {
        this._contentManager.saveContent(masterContent);
        this._contentManager.insertOnLineContent(masterContent);
        this.waitNotifyingThread();
        EntitySearchFilter filterForDate = new EntitySearchFilter("DataInizio", true);
        filterForDate.setOrder(EntitySearchFilter.DESC_ORDER);
        EntitySearchFilter[] filters = { filterForDate };
        List<String> contents = _contentManager.loadPublicContentsId("EVN", null, filters, null);
        String[] expectedFreeOrderedContentsId = { "EVN194", masterContent.getId(), "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
        assertEquals(expectedFreeOrderedContentsId.length, contents.size());
        for (int i = 0; i < expectedFreeOrderedContentsId.length; i++) {
            assertEquals(expectedFreeOrderedContentsId[i], contents.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != masterContent.getId() && !"EVN193".equals(masterContent.getId())) {
            this._contentManager.removeOnLineContent(masterContent);
            this._contentManager.deleteContent(masterContent);
        }
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 20 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentManager method deleteContents.

private void deleteContents(String[] contentIds) throws Throwable {
    for (int i = 0; i < contentIds.length; i++) {
        Content content = this._contentManager.loadContent(contentIds[i], false);
        if (null != content) {
            this._contentManager.removeOnLineContent(content);
            this._contentManager.deleteContent(content);
        }
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6