use of com.agiletec.aps.system.common.entity.model.attribute.DefaultJAXBAttributeType in project entando-core by entando.
the class JAXBEntityType method buildEntityType.
public IApsEntity buildEntityType(Class entityClass, Map<String, AttributeInterface> attributes) throws ApiException, Throwable {
List<ApiError> errors = new ArrayList<ApiError>();
IApsEntity entityType = null;
try {
entityType = (IApsEntity) entityClass.newInstance();
entityType.setTypeCode(this.getTypeCode());
entityType.setTypeDescr(this.getTypeDescription());
List<DefaultJAXBAttributeType> jabxAttributes = this.getAttributes();
for (int i = 0; i < jabxAttributes.size(); i++) {
try {
DefaultJAXBAttributeType jaxbAttributeType = jabxAttributes.get(i);
AttributeInterface attribute = jaxbAttributeType.createAttribute(attributes);
if (null != entityType.getAttribute(attribute.getName())) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Attribute '" + attribute.getName() + "' already defined");
}
entityType.addAttribute(attribute);
} catch (ApiException e) {
errors.addAll(e.getErrors());
}
}
} catch (Throwable t) {
_logger.error("error in buildEntityType", t);
// ApsSystemUtils.logThrowable(t, this, "buildEntityType");
throw t;
}
if (!errors.isEmpty())
throw new ApiException(errors);
return entityType;
}
Aggregations