Search in sources :

Example 1 with ListAttribute

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

the class TestValidateDateAttribute method testValidate_ListElement.

public void testValidate_ListElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        ListAttribute list = (ListAttribute) content.getAttribute("ListDate");
        AttributeInterface attributeIT = list.addAttribute("it");
        assertEquals(0, list.getAttributeList("en").size());
        assertEquals(1, list.getAttributeList("it").size());
        tracerIT.setListIndex(list.getAttributeList("it").size() - 1);
        tracerIT.setListLang(this.getLangManager().getLang("it"));
        tracerIT.setListElement(true);
        String formFieldItName = tracerIT.getFormFieldName(attributeIT);
        String formFieldPrefix = "List:" + attributeIT.getType() + ":";
        assertEquals(formFieldPrefix + "it_ListDate_0", formFieldItName);
        AttributeTracer tracerEN = tracerIT.clone();
        tracerEN.setLang(this.getLangManager().getLang("en"));
        tracerEN.setListLang(this.getLangManager().getLang("en"));
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "ListDateElement0Value");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "26/11/2007");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attribute2 = list.addAttribute("it");
        tracerIT.setListIndex(list.getAttributes().size() - 1);
        formFieldItName = tracerIT.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_ListDate_1", formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "26/11/2007");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attributeEN = list.addAttribute("en");
        String formFieldEnName = tracerEN.getFormFieldName(attributeEN);
        assertEquals(formFieldPrefix + "en_ListDate_0", formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldEnName, "06/07/1987");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldEnName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 2 with ListAttribute

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

the class TestValidateMonotextAttribute method testValidate_ListElement.

public void testValidate_ListElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        ListAttribute list = (ListAttribute) content.getAttribute("ListMonot");
        AttributeInterface attribute = list.addAttribute("it");
        assertEquals(0, list.getAttributeList("en").size());
        assertEquals(1, list.getAttributeList("it").size());
        tracer.setLang(this.getLangManager().getLang("it"));
        tracer.setListIndex(list.getAttributeList("it").size() - 1);
        tracer.setListLang(this.getLangManager().getLang("it"));
        tracer.setListElement(true);
        tracer.setParentAttribute(list);
        String formFieldName = tracer.getFormFieldName(attribute);
        String formFieldPrefix = "List:" + attribute.getType() + ":";
        assertEquals(formFieldPrefix + "it_ListMonot_0", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "ListMonotElement0Value");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        AttributeInterface attribute2 = list.addAttribute("it");
        tracer.setListIndex(list.getAttributes().size() - 1);
        formFieldName = tracer.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_ListMonot_1", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 3 with ListAttribute

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

the class TestValidateNumberAttribute method testValidate_ListElement.

public void testValidate_ListElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        ListAttribute list = (ListAttribute) content.getAttribute("ListNumber");
        AttributeInterface attributeIT = list.addAttribute("it");
        assertEquals(0, list.getAttributeList("en").size());
        assertEquals(1, list.getAttributeList("it").size());
        tracerIT.setListIndex(list.getAttributeList("it").size() - 1);
        tracerIT.setListLang(this.getLangManager().getLang("it"));
        tracerIT.setListElement(true);
        String formFieldItName = tracerIT.getFormFieldName(attributeIT);
        String formFieldPrefix = "List:" + attributeIT.getType() + ":";
        assertEquals(formFieldPrefix + "it_ListNumber_0", formFieldItName);
        AttributeTracer tracerEN = tracerIT.clone();
        tracerEN.setLang(this.getLangManager().getLang("en"));
        tracerEN.setListLang(this.getLangManager().getLang("en"));
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "wrongNumber");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "27");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attribute2 = list.addAttribute("it");
        tracerIT.setListIndex(list.getAttributes().size() - 1);
        formFieldItName = tracerIT.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_ListNumber_1", formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "26");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attributeEN = list.addAttribute("en");
        String formFieldEnName = tracerEN.getFormFieldName(attributeEN);
        assertEquals(formFieldPrefix + "en_ListNumber_0", formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldEnName, "57");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldEnName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 4 with ListAttribute

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

the class ListAttributeAction method moveListElement.

@Override
public String moveListElement() {
    IApsEntity entity = this.getCurrentApsEntity();
    try {
        int elementIndex = this.getElementIndex();
        ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
        if (currentAttribute instanceof MonoListAttribute) {
            List<AttributeInterface> monoList = ((MonoListAttribute) currentAttribute).getAttributes();
            this.moveListElement(monoList, elementIndex, this.getMovement());
        } else if (currentAttribute instanceof ListAttribute) {
            List<AttributeInterface> list = ((ListAttribute) currentAttribute).getAttributeList(this.getListLangCode());
            this.moveListElement(list, elementIndex, this.getMovement());
        }
        _logger.debug("Moved element of type {} of the list {} in the position {} with a '{}' movement ", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName(), elementIndex, this.getMovement());
    } catch (Throwable t) {
        _logger.error("error in moveListElement", t);
        // ApsSystemUtils.logThrowable(t, this, "moveListElement");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) List(java.util.List) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Example 5 with ListAttribute

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

the class ListAttributeAction method removeListElement.

@Override
public String removeListElement() {
    IApsEntity entity = this.getCurrentApsEntity();
    try {
        int elementIndex = this.getElementIndex();
        ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
        if (currentAttribute instanceof MonoListAttribute) {
            ((MonoListAttribute) currentAttribute).removeAttribute(elementIndex);
        } else if (currentAttribute instanceof ListAttribute) {
            ((ListAttribute) currentAttribute).removeAttribute(this.getListLangCode(), elementIndex);
        }
        _logger.debug("Element oy type {} removed fomr the list {}", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName());
    } catch (Throwable t) {
        _logger.error("error in removeListElement", t);
        // ApsSystemUtils.logThrowable(t, this, "removeListElement");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Aggregations

ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)13 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)12 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)11 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)6 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)5 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)3 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)3 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)2 CheckBoxAttribute (com.agiletec.aps.system.common.entity.model.attribute.CheckBoxAttribute)2 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)2 EnumeratorAttribute (com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute)2 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)2 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)2 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)2 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)2 ThreeStateAttribute (com.agiletec.aps.system.common.entity.model.attribute.ThreeStateAttribute)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 List (java.util.List)2 EnumeratorMapAttribute (org.entando.entando.aps.system.common.entity.model.attribute.EnumeratorMapAttribute)2