use of com.agiletec.aps.system.common.entity.model.attribute.util.IAttributeValidationRules in project entando-core by entando.
the class AbstractAttribute method setAttributeConfig.
@Override
public void setAttributeConfig(Element attributeElement) throws ApsSystemException {
try {
String name = this.extractXmlAttribute(attributeElement, "name", true);
this.setName(name);
String description = this.extractXmlAttribute(attributeElement, "description", false);
this.setDescription(description);
String searchable = this.extractXmlAttribute(attributeElement, "searchable", false);
// to guaranted compatibility with previsous version of Entando 4.0.1 *** Start Block
if (null == searchable) {
searchable = this.extractXmlAttribute(attributeElement, "searcheable", false);
}
// to guaranted compatibility with previsous version of Entando 4.0.1 *** End Block
this.setSearchable(null != searchable && searchable.equalsIgnoreCase("true"));
IAttributeValidationRules validationCondition = this.getValidationRules();
validationCondition.setConfig(attributeElement);
// to guaranted compatibility with previsous version of jAPS 2.0.12 *** Start Block
String required = this.extractXmlAttribute(attributeElement, "required", false);
if (null != required && required.equalsIgnoreCase("true")) {
this.setRequired(true);
}
// to guaranted compatibility with previsous version of jAPS 2.0.12 *** End Block
String indexingType = this.extractXmlAttribute(attributeElement, "indexingtype", false);
if (null != indexingType) {
this.setIndexingType(indexingType);
} else {
this.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_NONE);
}
Element disablingCodesElements = attributeElement.getChild("disablingCodes");
if (null != disablingCodesElements) {
String[] disablingCodes = this.extractValues(disablingCodesElements, "code");
this.setDisablingCodes(disablingCodes);
} else {
// to guaranted compatibility with previsous version of jAPS 2.0.12 *** Start Block
String disablingCodesStr = this.extractXmlAttribute(attributeElement, "disablingCodes", false);
if (disablingCodesStr != null) {
String[] disablingCodes = disablingCodesStr.split(",");
this.setDisablingCodes(disablingCodes);
}
// to guaranted compatibility with previsous version of jAPS 2.0.12 *** End Block
}
Element rolesElements = attributeElement.getChild("roles");
if (null != rolesElements) {
String[] roles = this.extractValues(rolesElements, "role");
this.setRoles(roles);
}
} catch (Throwable t) {
String message = "Error detected while creating the attribute config '" + this.getName() + "' type '" + this.getType() + "'";
_logger.error("Error detected while creating the attribute config '{}' type '{}'", this.getName(), this.getType(), t);
throw new RuntimeException(message, t);
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.util.IAttributeValidationRules in project entando-core by entando.
the class AbstractAttribute method validate.
@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
List<AttributeFieldError> errors = new ArrayList<>();
try {
if (this.getStatus().equals(Status.INCOMPLETE)) {
errors.add(new AttributeFieldError(this, FieldError.INVALID, tracer));
} else {
IAttributeValidationRules validationRules = this.getValidationRules();
if (null == validationRules) {
return errors;
}
List<AttributeFieldError> validationRulesErrors = validationRules.validate(this, tracer, this.getLangManager());
if (null != validationRulesErrors) {
errors.addAll(validationRulesErrors);
}
}
} catch (Throwable t) {
_logger.error("Error validating Attribute '{}'", this.getName(), t);
throw new RuntimeException("Error validating Attribute '" + this.getName() + "'", t);
}
return errors;
}
Aggregations