Search in sources :

Example 6 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute 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 7 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute 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 8 with CompositeAttribute

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

the class CompositeAttributeManager method updateAttribute.

@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
    List<AttributeInterface> attributes = ((CompositeAttribute) attribute).getAttributes();
    for (int i = 0; i < attributes.size(); i++) {
        AttributeInterface attributeElement = attributes.get(i);
        AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
        elementTracer.setCompositeElement(true);
        elementTracer.setParentAttribute(attribute);
        AbstractAttributeManager elementManager = (AbstractAttributeManager) this.getManager(attributeElement);
        if (elementManager != null) {
            elementManager.updateAttribute(attributeElement, elementTracer, request);
        }
    }
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 9 with CompositeAttribute

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

the class CompositeAttributeConfigAction method saveAttributeElement.

@Override
public String saveAttributeElement() {
    try {
        CompositeAttribute composite = this.getCompositeAttributeOnEdit();
        if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
            throw new RuntimeException("The edit operation on this attribute is not supported");
        } else {
            AttributeInterface attribute = this.getAttributePrototype(this.getAttributeTypeCode());
            attribute.setName(this.getAttributeName());
            super.fillAttributeFields(attribute);
            composite.getAttributes().add(attribute);
            composite.getAttributeMap().put(attribute.getName(), attribute);
        }
    } catch (Throwable t) {
        _logger.error("error in saveAttributeElement", t);
        // ApsSystemUtils.logThrowable(t, this, "saveAttributeElement");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 10 with CompositeAttribute

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

the class CompositeAttributeConfigAction method removeAttributeElement.

@Override
public String removeAttributeElement() {
    try {
        int elementIndex = this.getAttributeIndex();
        CompositeAttribute composite = this.getCompositeAttributeOnEdit();
        AttributeInterface attributeToRemove = composite.getAttributes().get(elementIndex);
        composite.getAttributes().remove(elementIndex);
        composite.getAttributeMap().remove(attributeToRemove.getName());
    } catch (Throwable t) {
        _logger.error("error in removeAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "removeAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)28 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)27 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)15 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)13 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)13 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)4 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)4 HttpSession (javax.servlet.http.HttpSession)4 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)3 EnumeratorAttribute (com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute)3 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)3 CheckBoxAttribute (com.agiletec.aps.system.common.entity.model.attribute.CheckBoxAttribute)2 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)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 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)2