Search in sources :

Example 6 with MonoListAttribute

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

the class TestListAttributeAction method testRemoveListElement.

public void testRemoveListElement() throws Throwable {
    String contentOnSessionMarker = this.initEditContent();
    this.initContentAction("/do/jacms/Content", "removeListElement", contentOnSessionMarker);
    this.addParameter("attributeName", "Autori");
    this.addParameter("elementIndex", "1");
    this.addParameter("listLangCode", "it");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
    MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
    List<AttributeInterface> attributes = monoListAttribute.getAttributes();
    String[] expected = { "Pippo", "Pluto" };
    this.verifyText(attributes, expected);
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 7 with MonoListAttribute

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

the class TestListAttributeAction method testMoveListElement.

public void testMoveListElement() throws Throwable {
    String contentOnSessionMarker = this.initEditContent();
    this.initContentAction("/do/jacms/Content", "moveListElement", contentOnSessionMarker);
    this.addParameter("attributeName", "Autori");
    this.addParameter("elementIndex", "1");
    this.addParameter("listLangCode", "it");
    this.addParameter("movement", IListAttributeAction.MOVEMENT_UP_CODE);
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
    MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
    List<AttributeInterface> attributes = monoListAttribute.getAttributes();
    String[] expected = { "Paperino", "Pippo", "Pluto" };
    this.verifyText(attributes, expected);
    this.initContentAction("/do/jacms/Content", "moveListElement", contentOnSessionMarker);
    this.addParameter("attributeName", "Autori");
    this.addParameter("elementIndex", "1");
    this.addParameter("listLangCode", "it");
    this.addParameter("movement", IListAttributeAction.MOVEMENT_DOWN_CODE);
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    currentContent = this.getContentOnEdit(contentOnSessionMarker);
    monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
    attributes = monoListAttribute.getAttributes();
    String[] expected2 = { "Paperino", "Pluto", "Pippo" };
    this.verifyText(attributes, expected2);
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 8 with MonoListAttribute

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

the class TestListAttributeAction method testAddListElement.

public void testAddListElement() throws Throwable {
    String contentOnSessionMarker = this.initEditContent();
    this.initContentAction("/do/jacms/Content", "addListElement", contentOnSessionMarker);
    this.addParameter("attributeName", "Autori");
    this.addParameter("listLangCode", "it");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
    MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
    List<AttributeInterface> attributes = monoListAttribute.getAttributes();
    String[] expected = { "Pippo", "Paperino", "Pluto", "" };
    this.verifyText(attributes, expected);
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 9 with MonoListAttribute

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

the class TestValidateResourceAttribute method testValidate_MonolistCompositeElement.

protected void testValidate_MonolistCompositeElement(String elementName, String testResourceId) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolistAttribute.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute(elementName);
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerIT.setListLang(this.getLangManager().getDefaultLang());
        tracerIT.setMonoListElement(true);
        tracerIT.setCompositeElement(true);
        tracerIT.setParentAttribute(compositeElement);
        String formITFieldName = tracerIT.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "it_MonoLCom_" + elementName + "_0", formITFieldName);
        String monolistElementName = tracerIT.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formITFieldName, "itValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldPrefix + "MonoLCom_" + elementName + "_0");
        content = this.getContentOnEdit(contentOnSessionMarker);
        monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
        compositeElement = (CompositeAttribute) monolistAttribute.getAttribute(0);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) compositeElement.getAttribute(elementName);
        ResourceInterface resource = this._resourceManager.loadResource(testResourceId);
        resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, "MonoLCom_" + elementName + "_0");
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 10 with MonoListAttribute

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

the class TestValidateResourceAttribute method testValidate_MonoListElement.

protected void testValidate_MonoListElement(String mlAttributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute(mlAttributeName);
        AttributeInterface newResourceAttribute = monolistAttribute.addAttribute();
        String monolistElementFieldPrefix = "Monolist:" + newResourceAttribute.getType() + ":";
        tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setParentAttribute(monolistAttribute);
        String monolistElementName = tracer.getMonolistElementFieldName(newResourceAttribute);
        assertEquals(monolistElementFieldPrefix + mlAttributeName + "_0", monolistElementName);
        String formFieldName = tracer.getFormFieldName(newResourceAttribute);
        assertEquals(monolistElementFieldPrefix + "it_" + mlAttributeName + "_0", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "resourceDescrMonolElement0Value");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        content = this.getContentOnEdit(contentOnSessionMarker);
        monolistAttribute = (MonoListAttribute) content.getAttribute(mlAttributeName);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) monolistAttribute.getAttribute(0);
        ResourceInterface resource = this._resourceManager.loadResource("7");
        resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName);
        AttributeInterface attribute2 = monolistAttribute.addAttribute();
        tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
        String formFieldName2 = tracer.getFormFieldName(attribute2);
        assertEquals(monolistElementFieldPrefix + "it_" + mlAttributeName + "_1", formFieldName2);
        String monolistElementName2 = tracer.getMonolistElementFieldName(attribute2);
        assertEquals(monolistElementFieldPrefix + mlAttributeName + "_1", monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName2);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) 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