}
private static Material toEntity(MaterialDTO materialDTO) {
Material material = Material.createUnvalidated(StringUtils
.trim(materialDTO.code), StringUtils
.trim(materialDTO.description), materialDTO.defaultPrice,
materialDTO.disabled);
if (materialDTO.unitType != null) {
try {
UnitType unitType = Registry.getUnitTypeDAO()
.findByCodeAnotherTransaction(
materialDTO.unitType);
material.setUnitType(unitType);
} catch (InstanceNotFoundException e) {
throw new ValidationException("unit type code not found");
}
}