Search in sources :

Example 31 with IApsEntity

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

the class EntityAttributeConfigAction method validate.

@Override
public void validate() {
    super.validate();
    IApsEntity entityType = this.getEntityType();
    String attributeName = this.getAttributeName().trim();
    if (this.getStrutsAction() == ApsAdminSystemConstants.ADD && null != entityType.getAttribute(attributeName)) {
        String[] args = { attributeName };
        this.addFieldError("attributeName", this.getText("error.entity.attribute.name.already.exists", args));
    }
    AttributeInterface attributePrototype = this.getAttributePrototype(this.getAttributeTypeCode());
    if (null == attributePrototype) {
        String[] args = { this.getAttributeTypeCode() };
        this.addFieldError("attributeTypeCode", this.getText("error.entity.attribute.type.invalid", args));
    } else {
        if ((attributePrototype instanceof EnumeratorAttribute) && (this.getEnumeratorStaticItems() == null || this.getEnumeratorStaticItems().trim().length() == 0) && (null == this.getEnumeratorExtractorBean() || this.getEnumeratorExtractorBean().trim().length() == 0)) {
            String[] args = { this.getAttributeTypeCode() };
            this.addFieldError("enumeratorStaticItems", this.getText("error.entity.attribute.enumerator.items.missing", args));
        }
        if ((attributePrototype instanceof AbstractListAttribute) && (StringUtils.isBlank(this.getListNestedType()) || null == this.getAttributePrototype(this.getAttributeTypeCode()))) {
            String[] args = { this.getAttributeTypeCode() };
            this.addFieldError("listNestedType", this.getText("error.entity.attribute.list.handled.missing", args));
        }
    }
}
Also used : EnumeratorAttribute(com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)

Example 32 with IApsEntity

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

the class EntityTypeConfigAction method removeAttribute.

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

Example 33 with IApsEntity

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

the class EntityTypeConfigAction method addEntityType.

@Override
public String addEntityType() {
    try {
        String checkEntityManagerResult = this.checkEntityManager();
        if (null != checkEntityManagerResult)
            return checkEntityManagerResult;
        Class entityClass = this.getEntityManager().getEntityClass();
        IApsEntity entityType = (IApsEntity) entityClass.newInstance();
        this.initSessionParams(entityType, ApsAdminSystemConstants.ADD);
    } catch (Throwable t) {
        _logger.error("error in addEntityType", t);
        // ApsSystemUtils.logThrowable(t, this, "addEntityType");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 34 with IApsEntity

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

the class EntityTypeConfigAction method editEntityType.

@Override
public String editEntityType() {
    try {
        String checkEntityManagerResult = this.checkEntityManager();
        if (null != checkEntityManagerResult)
            return checkEntityManagerResult;
        IApsEntity entityType = this.getEntityPrototype(this.getEntityTypeCode());
        if (null == entityType) {
            String[] args = { this.getEntityTypeCode() };
            this.addFieldError("entityTypeCode", this.getText("error.entity.type.null", args));
            return INPUT;
        }
        this.initSessionParams(entityType, ApsAdminSystemConstants.EDIT);
    } catch (Throwable t) {
        _logger.error("error in editEntityType", t);
        // ApsSystemUtils.logThrowable(t, this, "editEntityType");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 35 with IApsEntity

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

the class EntityTypeConfigAction method moveAttribute.

@Override
public String moveAttribute() {
    IApsEntity entity = this.updateEntityOnSession();
    try {
        int elementIndex = this.getAttributeIndex();
        String movement = this.getMovement();
        List<AttributeInterface> attributes = entity.getAttributeList();
        if (!(elementIndex == 0 && movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) && !(elementIndex == attributes.size() - 1 && movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE))) {
            AttributeInterface attributeToMove = attributes.get(elementIndex);
            attributes.remove(elementIndex);
            if (movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) {
                attributes.add(elementIndex - 1, attributeToMove);
            }
            if (movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE)) {
                attributes.add(elementIndex + 1, attributeToMove);
            }
        }
    } catch (Throwable t) {
        _logger.error("error in moveAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "moveAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) 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