Search in sources :

Example 66 with AttributeInterface

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

the class EntityAttributeConfigAction method getAllowedNestedTypes.

public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
        while (attributeIter.hasNext()) {
            AttributeInterface attribute = attributeIter.next();
            boolean simple = attribute.isSimple();
            boolean multiLanguage = attribute.isMultilingual();
            if ((listType instanceof ListAttribute && simple && !multiLanguage) || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error while extracting Allowed Nested Types", t);
        // ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
        throw new RuntimeException("Error while extracting Allowed Nested Types", t);
    }
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) 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)

Example 67 with AttributeInterface

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

the class EntityAttributeConfigAction method editAttribute.

@Override
public String editAttribute() {
    this.setStrutsAction(ApsAdminSystemConstants.EDIT);
    this.getRequest().getSession().removeAttribute(ICompositeAttributeConfigAction.COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
    this.getRequest().getSession().removeAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
    this.getRequest().getSession().removeAttribute(IListElementAttributeConfigAction.LIST_ELEMENT_ON_EDIT_SESSION_PARAM);
    try {
        AttributeInterface attribute = (AttributeInterface) this.getEntityType().getAttribute(this.getAttributeName());
        this.valueFormFields(attribute);
        if (attribute instanceof AbstractListAttribute) {
            AbstractListAttribute listAttribute = (AbstractListAttribute) attribute;
            this.setListNestedType(listAttribute.getNestedAttributeTypeCode());
        }
    } catch (Throwable t) {
        _logger.error("error in editAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "editAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)

Example 68 with AttributeInterface

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

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

the class EntityTypeConfigAction method addAttribute.

@Override
public String addAttribute() {
    this.updateEntityOnSession();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        if (null == attributeTypes.get(this.getAttributeTypeCode())) {
            String[] args = { this.getAttributeTypeCode() };
            this.addFieldError("attributeTypeCode", this.getText("error.attribute.not.exists", args));
            return INPUT;
        }
    } catch (Throwable t) {
        _logger.error("error in addAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "addAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 70 with AttributeInterface

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

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7