Search in sources :

Example 1 with AttributeManagerInterface

use of com.agiletec.apsadmin.system.entity.attribute.manager.AttributeManagerInterface in project entando-core by entando.

the class EntityActionHelper method scanEntity.

@Override
public void scanEntity(IApsEntity currentEntity, ActionSupport action) {
    try {
        List<AttributeInterface> attributes = currentEntity.getAttributeList();
        for (int i = 0; i < attributes.size(); i++) {
            AttributeInterface entityAttribute = attributes.get(i);
            if (entityAttribute.isActive()) {
                List<AttributeFieldError> errors = entityAttribute.validate(new AttributeTracer());
                if (null != errors && errors.size() > 0) {
                    for (int j = 0; j < errors.size(); j++) {
                        AttributeFieldError attributeFieldError = errors.get(j);
                        AttributeTracer tracer = attributeFieldError.getTracer();
                        AttributeInterface attribute = attributeFieldError.getAttribute();
                        String messageAttributePositionPrefix = this.createErrorMessageAttributePositionPrefix(action, attribute, tracer);
                        AttributeManagerInterface attributeManager = this.getManager(attribute);
                        String errorMessage = attributeManager.getErrorMessage(attributeFieldError, action);
                        String formFieldName = tracer.getFormFieldName(attributeFieldError.getAttribute());
                        action.addFieldError(formFieldName, messageAttributePositionPrefix + " " + errorMessage);
                    }
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error scanning Entity", t);
        throw new RuntimeException("Error scanning Entity", t);
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) AttributeManagerInterface(com.agiletec.apsadmin.system.entity.attribute.manager.AttributeManagerInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)1 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 AttributeManagerInterface (com.agiletec.apsadmin.system.entity.attribute.manager.AttributeManagerInterface)1