Search in sources :

Example 56 with AttributeInterface

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

the class MonoTextAttributeManager method getCustomAttributeErrorMessage.

@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    AttributeInterface attribute = attributeFieldError.getAttribute();
    TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules();
    if (null != valRules) {
        ITextAttribute textAttribute = (ITextAttribute) attribute;
        String text = textAttribute.getTextForLang(null);
        String errorCode = attributeFieldError.getErrorCode();
        if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) {
            String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMinLength()) };
            return action.getText("MonotextAttribute.fieldError.invalidMinLength", args);
        } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) {
            String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()) };
            return action.getText("MonotextAttribute.fieldError.invalidMaxLength", args);
        } else if (errorCode.equals(FieldError.INVALID_FORMAT)) {
            return action.getText("MonotextAttribute.fieldError.invalidInsertedText");
        }
    }
    return action.getText(this.getInvalidAttributeMessage());
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) TextAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.TextAttributeValidationRules)

Example 57 with AttributeInterface

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

the class NumberAttributeManager method getCustomAttributeErrorMessage.

@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    AttributeInterface attribute = attributeFieldError.getAttribute();
    NumberAttributeValidationRules valRules = (NumberAttributeValidationRules) attribute.getValidationRules();
    if (null != valRules) {
        String errorCode = attributeFieldError.getErrorCode();
        if (errorCode.equals(FieldError.LESS_THAN_ALLOWED)) {
            Integer startValue = (valRules.getRangeStart() != null) ? (Integer) valRules.getRangeStart() : this.getOtherAttributeValue(attribute, valRules.getRangeStartAttribute());
            String[] args = { startValue.toString() };
            return action.getText("NumberAttribute.fieldError.lessValue", args);
        } else if (errorCode.equals(FieldError.GREATER_THAN_ALLOWED)) {
            Integer endValue = (valRules.getRangeEnd() != null) ? (Integer) valRules.getRangeEnd() : this.getOtherAttributeValue(attribute, valRules.getRangeEndAttribute());
            String[] args = { endValue.toString() };
            return action.getText("NumberAttribute.fieldError.greaterValue", args);
        } else if (errorCode.equals(FieldError.NOT_EQUALS_THAN_ALLOWED)) {
            Integer value = (valRules.getValue() != null) ? (Integer) valRules.getValue() : this.getOtherAttributeValue(attribute, valRules.getValueAttribute());
            String[] args = { value.toString() };
            return action.getText("NumberAttribute.fieldError.wrongValue", args);
        }
    }
    return action.getText(this.getInvalidAttributeMessage());
}
Also used : AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) NumberAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.NumberAttributeValidationRules)

Example 58 with AttributeInterface

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

the class TextAttributeManager method getCustomAttributeErrorMessage.

@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    AttributeInterface attribute = attributeFieldError.getAttribute();
    TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules();
    if (null != valRules) {
        ITextAttribute textAttribute = (ITextAttribute) attribute;
        Lang lang = attributeFieldError.getTracer().getLang();
        String langCode = (null != lang) ? lang.getCode() : null;
        String text = textAttribute.getTextForLang(langCode);
        String errorCode = attributeFieldError.getErrorCode();
        if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) {
            String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMinLength()), lang.getDescr() };
            return action.getText("TextAttribute.fieldError.invalidMinLength", args);
        } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) {
            String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()), lang.getDescr() };
            return action.getText("TextAttribute.fieldError.invalidMaxLength", args);
        } else if (errorCode.equals(FieldError.INVALID_FORMAT)) {
            String[] args = { lang.getDescr() };
            return action.getText("TextAttribute.fieldError.invalidInsertedText", args);
        }
    }
    return action.getText(this.getInvalidAttributeMessage());
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) TextAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.TextAttributeValidationRules)

Example 59 with AttributeInterface

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

the class AbstractBaseEntityAttributeConfigAction method getAttributePrototype.

public AttributeInterface getAttributePrototype(String typeCode) {
    IEntityManager entityManager = this.getEntityManager();
    Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
    return attributeTypes.get(typeCode);
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 60 with AttributeInterface

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

the class AbstractBaseEntityAttributeConfigAction method getSameAttributes.

/**
 * Return the list of the other entity attributes of the same type of the current on edit.
 * @return The list of the other entity attributes of the same type.
 */
public List<AttributeInterface> getSameAttributes() {
    AttributeInterface attributePrototype = this.getAttributePrototype(this.getAttributeTypeCode());
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    List<AttributeInterface> currentEntityAttributes = this.getEntityType().getAttributeList();
    for (int i = 0; i < currentEntityAttributes.size(); i++) {
        AttributeInterface attribute = currentEntityAttributes.get(i);
        if (attribute.getClass().isInstance(attributePrototype) && (null == this.getAttributeName() || !attribute.getName().equals(this.getAttributeName()))) {
            attributes.add(attribute);
        }
    }
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) 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