Search in sources :

Example 26 with MonoListAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.

the class TestValidateContent method testValidate_2.

public void testValidate_2() throws Throwable {
    try {
        Content content = this._contentManager.loadContent("EVN191", true);
        content.setId(null);
        // Valorizzo il gruppo proprietario
        content.setMainGroup(Group.FREE_GROUP_NAME);
        content.getGroups().add("customers");
        MonoListAttribute linksCorrelati = (MonoListAttribute) content.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        List<FieldError> errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
        assertEquals(FieldError.INVALID, error.getErrorCode());
        // AGGIUNGO LINK SU PAGINA COACH
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        // Contenuto di coach
        symbolicLink.setDestinationToContent("EVN103");
        linkAttribute.setSymbolicLink(symbolicLink);
        errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        error = errors.get(0);
        assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
        assertEquals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) 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) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 27 with MonoListAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.

the class TestContentAction method testValidate_1.

public void testValidate_1() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    String contentTypeCode = "ART";
    Content prototype = this.getContentManager().createContentType(contentTypeCode);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(prototype, ApsAdminSystemConstants.ADD);
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, insertedDescr, Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        assertEquals(insertedDescr, contentOnSession.getDescription());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
        assertEquals(1, fieldErrors.size());
        List<String> titleFieldErrors = fieldErrors.get("Text:it_Titolo");
        assertNotNull(titleFieldErrors);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals(1, titleFieldErrors.size());
        String monolistAttributeName = "Autori";
        contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        MonoListAttribute monolist = (MonoListAttribute) contentOnSession.getAttribute(monolistAttributeName);
        assertEquals(0, monolist.getAttributes().size());
        monolist.addAttribute();
        assertEquals(1, monolist.getAttributes().size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(2, fieldErrors.size());
        titleFieldErrors = fieldErrors.get("Text:it_Titolo");
        assertNotNull(titleFieldErrors);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals(1, titleFieldErrors.size());
        List<String> autoriFieldErrors = fieldErrors.get("Monolist:Monotext:Autori_0");
        assertNotNull(autoriFieldErrors);
        // Verifica non valido elemento 1 in attributo lista "Autori"
        assertEquals(1, autoriFieldErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) List(java.util.List)

Example 28 with MonoListAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.

the class TestContentAction method testValidate_2.

public void testValidate_2() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        Content contentForTest = this.getContentManager().loadContent("EVN191", true);
        String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
        contentForTest.setId(null);
        contentForTest.setDescription(insertedDescr);
        // Valorizzo il gruppo proprietario
        contentForTest.setMainGroup("coach");
        contentForTest.getGroups().add("customers");
        // AGGIUNGO LINK SU PAGINA COACH
        MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        // Contenuto di coach
        symbolicLink.setDestinationToContent("EVN103");
        linkAttribute.setSymbolicLink(symbolicLink);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 29 with MonoListAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.

the class TestLinkAttributeAction method testChooseLink_2.

public void testChooseLink_2() throws Throwable {
    String contentId = "EVN191";
    String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
    this.executeEdit(contentId, "admin");
    this.initContentAction("/do/jacms/Content", "chooseLink", contentOnSessionMarker);
    this.addParameter("attributeName", "LinkCorrelati");
    this.addParameter("elementIndex", "0");
    this.addParameter("langCode", "it");
    String result = this.executeAction();
    // FALLIMENTO PER LISTA VUOTA
    assertEquals(BaseAction.FAILURE, result);
    Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
    MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("LinkCorrelati");
    List<AttributeInterface> attributes = monoListAttribute.getAttributes();
    assertEquals(0, attributes.size());
    this.initContentAction("/do/jacms/Content", "addListElement", contentOnSessionMarker);
    this.addParameter("attributeName", "LinkCorrelati");
    this.addParameter("listLangCode", "it");
    result = this.executeAction();
    assertEquals("chooseLink", result);
    currentContent = this.getContentOnEdit(contentOnSessionMarker);
    monoListAttribute = (MonoListAttribute) currentContent.getAttribute("LinkCorrelati");
    attributes = monoListAttribute.getAttributes();
    assertEquals(1, attributes.size());
    this.initContentAction("/do/jacms/Content", "chooseLink", contentOnSessionMarker);
    this.addParameter("attributeName", "LinkCorrelati");
    this.addParameter("elementIndex", "0");
    this.addParameter("langCode", "it");
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    HttpSession session = this.getRequest().getSession();
    assertEquals("LinkCorrelati", session.getAttribute(ILinkAttributeActionHelper.ATTRIBUTE_NAME_SESSION_PARAM));
    assertEquals("it", session.getAttribute(ILinkAttributeActionHelper.LINK_LANG_CODE_SESSION_PARAM));
    assertNotNull(session.getAttribute(ILinkAttributeActionHelper.LIST_ELEMENT_INDEX_SESSION_PARAM));
    assertEquals(new Integer(0), session.getAttribute(ILinkAttributeActionHelper.LIST_ELEMENT_INDEX_SESSION_PARAM));
    currentContent = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(currentContent);
    assertEquals("EVN191", currentContent.getId());
    assertEquals("Evento 1", currentContent.getDescription());
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) HttpSession(javax.servlet.http.HttpSession) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 30 with MonoListAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.

the class LinkAttributeActionHelper method getLinkAttribute.

protected AttributeInterface getLinkAttribute(AttributeInterface attribute, HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        return getLinkAttribute(includedAttribute, request);
    } else if (attribute instanceof MonoListAttribute) {
        Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
        return getLinkAttribute(attributeElement, request);
    } else if (attribute instanceof LinkAttribute) {
        return attribute;
    } else {
        throw new RuntimeException("Caso non gestito : Atttributo tipo " + attribute.getClass());
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) HttpSession(javax.servlet.http.HttpSession) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)41 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)34 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)25 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)16 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)14 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)9 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)6 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)5 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)5 HttpSession (javax.servlet.http.HttpSession)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)4 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)4 List (java.util.List)4 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)3 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3