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());
}
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());
}
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());
}
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);
}
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;
}
Aggregations