Search in sources :

Example 21 with Content

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

the class TestContentManager method testSearchWorkContents_3.

public void testSearchWorkContents_3() throws Throwable {
    List<String> groupCodes = new ArrayList<String>();
    groupCodes.add(Group.ADMINS_GROUP_NAME);
    EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
    creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { creationOrder };
    String[] categories_1 = { "general_cat2" };
    List<String> contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
    String[] order_a = { "ART120", "ART112", "ART111", "EVN193", "ART179" };
    assertEquals(order_a.length, contents.size());
    this.verifyOrder(contents, order_a);
    String[] categories_2 = { "general_cat1", "general_cat2" };
    contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
    String[] order_b = { "ART111", "ART179" };
    assertEquals(order_b.length, contents.size());
    assertEquals(order_b[0], contents.get(0));
    Content newContent = this._contentManager.loadContent("EVN193", false);
    newContent.setId(null);
    try {
        this._contentManager.saveContent(newContent);
        contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
        String[] order_c = { newContent.getId(), "ART120", "ART112", "ART111", "EVN193", "ART179" };
        assertEquals(order_c.length, contents.size());
        this.verifyOrder(contents, order_c);
        ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
        newContent.addCategory(categoryManager.getCategory("general_cat1"));
        this._contentManager.saveContent(newContent);
        contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
        String[] order_d = { newContent.getId(), "ART111", "ART179" };
        assertEquals(order_d.length, contents.size());
        this.verifyOrder(contents, order_d);
    } catch (Throwable t) {
        throw t;
    } finally {
        this._contentManager.deleteContent(newContent);
        assertNull(this._contentManager.loadContent(newContent.getId(), false));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 22 with Content

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

the class TestContentManager method addDraftContentsForTest.

protected String[] addDraftContentsForTest(String[] masterContentIds, boolean publish) throws Throwable {
    String[] newContentIds = new String[masterContentIds.length];
    for (int i = 0; i < masterContentIds.length; i++) {
        Content content = this._contentManager.loadContent(masterContentIds[i], false);
        content.setId(null);
        this._contentManager.saveContent(content);
        newContentIds[i] = content.getId();
        if (publish) {
            this._contentManager.insertOnLineContent(content);
        }
    }
    for (int i = 0; i < newContentIds.length; i++) {
        Content content = this._contentManager.loadContent(newContentIds[i], false);
        assertNotNull(content);
    }
    return newContentIds;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 23 with Content

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

the class TestContentManager method testCreateContentWithViewPage.

public void testCreateContentWithViewPage() {
    Content content = _contentManager.createContentType("ART");
    String viewPage = content.getViewPage();
    assertEquals(viewPage, "contentview");
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 24 with Content

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

the class TestValidateContent method testValidate_4.

public void testValidate_4() throws Throwable {
    String shortTitle = "short";
    String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; " + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
    try {
        Content content = this.createNewVoid("RAH", "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        ITextAttribute textAttribute = (ITextAttribute) content.getAttribute("Titolo");
        textAttribute.setText(shortTitle, "it");
        List<FieldError> errors = content.validate(this._groupManager);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
        textAttribute.setText(longTitle, "it");
        errors = content.validate(this._groupManager);
        assertEquals(1, errors.size());
        error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
        textAttribute.setText(shortTitle, "en");
        errors = content.validate(this._groupManager);
        assertEquals(2, errors.size());
        error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
        error = errors.get(1);
        assertEquals("Text:en_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) FieldError(com.agiletec.aps.system.common.entity.model.FieldError)

Example 25 with Content

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

the class TestValidateContent method testValidate_1.

public void testValidate_1() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        Content content = this.createNewVoid("ART", insertedDescr, Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        List<FieldError> errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.MANDATORY, error.getErrorCode());
        String monolistAttributeName = "Autori";
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
        monolist.addAttribute();
        assertEquals(1, monolist.getAttributes().size());
        errors = content.validate(this._groupManager);
        assertEquals(2, errors.size());
        error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.MANDATORY, error.getErrorCode());
        error = errors.get(1);
        // Verifica non valido elemento 1 in attributo lista "Autori"
        assertEquals("Monolist:Monotext:Autori_0", error.getFieldCode());
        assertEquals(FieldError.INVALID, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) FieldError(com.agiletec.aps.system.common.entity.model.FieldError)

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