Search in sources :

Example 1 with ListAttributeInterface

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

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

Example 3 with ListAttributeInterface

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

the class ListAttributeAction method addListElement.

@Override
public String addListElement() {
    IApsEntity entity = this.getCurrentApsEntity();
    try {
        ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
        if (currentAttribute instanceof MonoListAttribute) {
            ((MonoListAttribute) currentAttribute).addAttribute();
        } else if (currentAttribute instanceof ListAttribute) {
            ((ListAttribute) currentAttribute).addAttribute(this.getListLangCode());
        }
        _logger.debug("Added element of type {} to the list {}", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName());
    } catch (Throwable t) {
        _logger.error("error in addListElement", t);
        // ApsSystemUtils.logThrowable(t, this, "addListElement");
        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)

Example 4 with ListAttributeInterface

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

Aggregations

ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)4 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)4 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)3 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)2 List (java.util.List)2 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1