Search in sources :

Example 61 with AttributeInterface

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

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

Example 63 with AttributeInterface

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

the class CompositeAttributeConfigAction method getAllowedAttributeElementTypes.

public List<AttributeInterface> getAllowedAttributeElementTypes() {
    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();
            if (attribute.isSimple()) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error extracting the allowed types of attribute elements", t);
        // ApsSystemUtils.logThrowable(t, this, "getAllowedAttributeElementTypes");
        throw new RuntimeException("Error extracting the allowed types of attribute elements", t);
    }
    return attributes;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 64 with AttributeInterface

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

Example 65 with AttributeInterface

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

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