Search in sources :

Example 6 with AbstractListAttribute

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

the class EntityAttributeConfigAction method fillAttributeFields.

/**
 * Fill attribute fields.
 *
 * @param attribute The attribute to edit with the form values.
 * @return A custom return code in the attribute neads a extra
 * configuration, else null.
 */
@Override
protected String fillAttributeFields(AttributeInterface attribute) {
    super.fillAttributeFields(attribute);
    AttributeInterface nestedType = null;
    if (attribute instanceof AbstractListAttribute) {
        AbstractListAttribute listAttribute = (AbstractListAttribute) attribute;
        if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT && listAttribute.getNestedAttributeTypeCode().equals(this.getListNestedType())) {
            if (listAttribute instanceof ListAttribute) {
                Lang defaultLang = this.getLangManager().getDefaultLang();
                // Composite Element
                nestedType = ((ListAttribute) listAttribute).addAttribute(defaultLang.getCode());
                ((ListAttribute) listAttribute).getAttributeList(defaultLang.getCode()).clear();
            } else {
                // Composite Element
                nestedType = ((MonoListAttribute) listAttribute).addAttribute();
                ((MonoListAttribute) listAttribute).getAttributes().clear();
            }
        } else {
            nestedType = this.getAttributePrototype(this.getListNestedType());
            if (nestedType != null) {
                nestedType.setName(this.getAttributeName());
            } else {
                _logger.info("******** List Type NULL!!!!");
            }
        }
        listAttribute.setNestedAttributeType(nestedType);
        nestedType.setName(attribute.getName());
    }
    if ((attribute instanceof CompositeAttribute) || (nestedType != null && nestedType instanceof CompositeAttribute)) {
        CompositeAttribute composite = ((attribute instanceof CompositeAttribute) ? (CompositeAttribute) attribute : (CompositeAttribute) nestedType);
        if (null != nestedType) {
            this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
        }
        this.getRequest().getSession().setAttribute(ICompositeAttributeConfigAction.COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM, composite);
        return "configureCompositeAttribute";
    }
    if (nestedType != null) {
        this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
        this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ELEMENT_ON_EDIT_SESSION_PARAM, nestedType);
        return "configureListElementAttribute";
    }
    return null;
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Aggregations

AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)6 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)6 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)3 EnumeratorAttribute (com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute)2 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)2 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)2 ArrayList (java.util.ArrayList)2 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)1 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)1 AbstractComplexAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractComplexAttribute)1 IAttributeValidationRules (com.agiletec.aps.system.common.entity.model.attribute.util.IAttributeValidationRules)1 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)1 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 AttributeRoleDto (org.entando.entando.aps.system.services.entity.model.AttributeRoleDto)1