Search in sources :

Example 31 with MonoListAttribute

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

the class ListAttributeAction method addListElement.

@Override
public String addListElement() {
    try {
        super.addListElement();
        Content content = this.getContent();
        int index = -1;
        ListAttributeInterface currentAttribute = (ListAttributeInterface) content.getAttribute(this.getAttributeName());
        String nestedType = currentAttribute.getNestedAttributeTypeCode();
        if (!nestedType.equals("Attach") && !nestedType.equals("Image") && !nestedType.equals("Link")) {
            return SUCCESS;
        }
        if (currentAttribute instanceof MonoListAttribute) {
            List<AttributeInterface> attributes = ((MonoListAttribute) currentAttribute).getAttributes();
            index = attributes.size() - 1;
        } else if (currentAttribute instanceof ListAttribute) {
            List<AttributeInterface> attributes = ((ListAttribute) currentAttribute).getAttributeList(this.getListLangCode());
            index = attributes.size() - 1;
        }
        this.setElementIndex(index);
        if (nestedType.equals("Attach") || nestedType.equals("Image")) {
            this.setResourceTypeCode(nestedType);
            return "chooseResource";
        } else {
            return "chooseLink";
        }
    } catch (Throwable t) {
        _logger.error("error in addListElement", t);
        // ApsSystemUtils.logThrowable(t, this, "addListElement");
        return FAILURE;
    }
}
Also used : ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) 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) 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 32 with MonoListAttribute

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

the class ResourceAttributeActionHelper method joinResource.

/**
 * Associa la risorsa all'attributo del contenuto o all'elemento dell'attributo lista
 * o all'elemento dell'attributo Composito (sia semplice che in lista).
 */
private static void joinResource(AttributeInterface attribute, ResourceInterface resource, HttpSession session) {
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        joinResource(includedAttribute, resource, session);
    } else if (attribute instanceof ResourceAttributeInterface) {
        String langCode = (String) session.getAttribute(RESOURCE_LANG_CODE_SESSION_PARAM);
        langCode = (langCode != null && !"".equals(langCode)) ? langCode : null;
        ((ResourceAttributeInterface) attribute).setResource(resource, langCode);
        ((AbstractResourceAttribute) attribute).setText(resource.getDescription(), langCode);
    } else if (attribute instanceof MonoListAttribute) {
        int elementIndex = ((Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM)).intValue();
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex);
        joinResource(attributeElement, resource, session);
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 33 with MonoListAttribute

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

the class TestValidateBooleanAttributes method validateMonolistCompositeElement.

protected void validateMonolistCompositeElement(String monolistAttributeName, String attributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
        CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute(attributeName);
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracer.setListIndex(monolist.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeElement);
        String formFieldName = tracer.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + monolistAttributeName + "_" + attributeName + "_0", formFieldName);
        String monolistElementName = tracer.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + monolistAttributeName + "_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "false");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : 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) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 34 with MonoListAttribute

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

the class TestValidateDateAttribute method testValidate_MonolistCompositeElement.

public void testValidate_MonolistCompositeElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute("Date");
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracer.setListIndex(monolist.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeElement);
        String formFieldName = tracer.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "MonoLCom_Date_0", formFieldName);
        String monolistElementName = tracer.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "wrongDateValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: start range 10/10/1971
        this.addParameter(formFieldName, "24/10/1961");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: start range 10/10/1971
        this.addParameter(formFieldName, "10/10/2008");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: end range attribute "Date"
        this.addParameter("Date:Date", "10/10/1999");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : 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) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 35 with MonoListAttribute

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

the class TestValidateMonotextAttribute method testValidate_MonolistCompositeElement.

public void testValidate_MonolistCompositeElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute("Monotext");
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracer.setListIndex(monolist.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeElement);
        String formFieldName = tracer.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "MonoLCom_Monotext_0", formFieldName);
        String monolistElementName = tracer.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "MonotextValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : 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) 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