Search in sources :

Example 26 with IApsEntity

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

the class AbstractApsEntityFinderAction method createBaseFilters.

protected void createBaseFilters() {
    try {
        int initSize = this.getFilters().length;
        EntitySearchFilter[] roleFilters = this.getEntityActionHelper().getRoleFilters(this);
        this.addFilters(roleFilters);
        IApsEntity prototype = this.getEntityPrototype();
        if (null != prototype) {
            EntitySearchFilter filterToAdd = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, prototype.getTypeCode(), false);
            this.addFilter(filterToAdd);
            EntitySearchFilter[] filters = this.getEntityActionHelper().getAttributeFilters(this, prototype);
            this.addFilters(filters);
        }
        this.setAddedAttributeFilter(this.getFilters().length > initSize);
    } catch (Throwable t) {
        _logger.error("Error while creating entity filters", t);
        // ApsSystemUtils.logThrowable(t, this, "createBaseFilters");
        throw new RuntimeException("Error while creating entity filters", t);
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 27 with IApsEntity

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

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

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

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

IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)70 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)24 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)16 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)12 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)11 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)11 ArrayList (java.util.ArrayList)9 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)6 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)5 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 List (java.util.List)4 BeanComparator (org.apache.commons.beanutils.BeanComparator)4 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)3 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)3 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 Widget (com.agiletec.aps.system.services.page.Widget)2 ApsProperties (com.agiletec.aps.util.ApsProperties)2 EntityAttributeConfigAction (com.agiletec.apsadmin.system.entity.type.EntityAttributeConfigAction)2