Search in sources :

Example 11 with MonoListAttribute

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

the class TestValidateTextAttribute method testValidate_MonoListElement_2.

public void testValidate_MonoListElement_2() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLText");
        AttributeInterface textAttribute = monolistAttribute.addAttribute();
        String formFieldPrefix = "Monolist:" + textAttribute.getType() + ":";
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerIT.setListLang(this.getLangManager().getDefaultLang());
        tracerIT.setMonoListElement(true);
        tracerIT.setParentAttribute(monolistAttribute);
        AttributeTracer tracerEN = tracerIT.clone();
        tracerEN.setLang(this.getLangManager().getLang("en"));
        String monolistElementName = tracerIT.getMonolistElementFieldName(textAttribute);
        assertEquals(formFieldPrefix + "MonoLText_0", monolistElementName);
        String formITFieldName = tracerIT.getFormFieldName(textAttribute);
        assertEquals(formFieldPrefix + "it_MonoLText_0", formITFieldName);
        String formENFieldName = tracerEN.getFormFieldName(textAttribute);
        assertEquals(formFieldPrefix + "en_MonoLText_0", formENFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName, "MonoLMonotElement0ValueEN");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName, "MonoLMonotElement0ValueEN");
        this.addParameter(formITFieldName, "MonoLMonotElement0ValueIT");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName);
        AttributeInterface attribute2 = monolistAttribute.addAttribute();
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerEN.setListIndex(monolistAttribute.getAttributes().size() - 1);
        String formITFieldName2 = tracerIT.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_MonoLText_1", formITFieldName2);
        String formENFieldName2 = tracerEN.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "en_MonoLText_1", formENFieldName2);
        String monolistElementName2 = tracerIT.getMonolistElementFieldName(attribute2);
        assertEquals(formFieldPrefix + "MonoLText_1", monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName2, "MonoLMonotElement1ValueEN");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName2, "MonoLMonotElement1ValueEN");
        this.addParameter(formITFieldName2, "MonoLMonotElement1ValueIT");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName2);
    } 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) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 12 with MonoListAttribute

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

the class LinkAttributeActionHelper method removeLink.

protected void removeLink(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);
        removeLink(includedAttribute, request);
    } else if (attribute instanceof LinkAttribute) {
        ((LinkAttribute) attribute).setSymbolicLink(null);
        ((LinkAttribute) attribute).getTextMap().clear();
    } else if (attribute instanceof MonoListAttribute) {
        Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
        removeLink(attributeElement, request);
    }
}
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)

Example 13 with MonoListAttribute

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

the class LinkAttributeActionHelper method joinLink.

protected void joinLink(AttributeInterface attribute, String[] destinations, int destType, 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);
        updateLink(includedAttribute, destinations, destType);
    } else if (attribute instanceof MonoListAttribute) {
        Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
        joinLink(attributeElement, destinations, destType, request);
    } else if (attribute instanceof LinkAttribute) {
        updateLink(attribute, destinations, destType);
    }
}
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)

Example 14 with MonoListAttribute

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

the class ResourceAttributeActionHelper method removeResource.

private static void removeResource(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);
        removeResource(includedAttribute, request);
    } else if (attribute instanceof AbstractResourceAttribute) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, request);
        String langCode = (String) session.getAttribute(RESOURCE_LANG_CODE_SESSION_PARAM);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) attribute;
        if (langCode == null || langCode.length() == 0 || langManager.getDefaultLang().getCode().equals(langCode)) {
            resourceAttribute.getResources().clear();
            resourceAttribute.getTextMap().clear();
        } else {
            resourceAttribute.setResource(null, langCode);
            resourceAttribute.setText(null, langCode);
        }
    } else if (attribute instanceof MonoListAttribute) {
        int elementIndex = ((Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM)).intValue();
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex);
        removeResource(attributeElement, request);
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) HttpSession(javax.servlet.http.HttpSession) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 15 with MonoListAttribute

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

the class CompositeAttributeConfigAction method saveCompositeAttribute.

@Override
public String saveCompositeAttribute() {
    try {
        CompositeAttribute composite = this.getCompositeAttributeOnEdit();
        IApsEntity entityType = this.getEntityType();
        AttributeInterface attribute = (AttributeInterface) entityType.getAttribute(composite.getName());
        if (attribute instanceof MonoListAttribute) {
            ((MonoListAttribute) attribute).setNestedAttributeType(composite);
        } else if (!attribute.getName().equals(composite.getName())) {
            throw new ApsSystemException("Attribute Name '" + attribute.getName() + "' incompatible with composite Attribute name '" + composite.getName() + "'");
        } else if (!attribute.getType().equals(composite.getType())) {
            throw new ApsSystemException("Attribute Type '" + attribute.getType() + "' incompatible with composite Attribute type '" + composite.getType() + "'");
        }
        this.getRequest().getSession().removeAttribute(COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
    } catch (Throwable t) {
        _logger.error("error in saveAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "saveAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) 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