All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.tools.horreum.mapper.ValidationErrorMapper Maven / Gradle / Ivy

The newest version!
package io.hyperfoil.tools.horreum.mapper;

import org.jboss.logging.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;

import io.hyperfoil.tools.horreum.api.data.ValidationError;
import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO;
import io.hyperfoil.tools.horreum.svc.Util;

public class ValidationErrorMapper {

    private static final Logger log = Logger.getLogger(ValidationErrorMapper.class);

    public static ValidationError fromValidationError(ValidationErrorDAO ve) {
        ValidationError dto = new ValidationError();
        dto.schemaId = ve.getSchemaId();
        try {
            dto.error = Util.OBJECT_MAPPER.treeToValue(ve.error, ValidationError.ErrorDetails.class);
        } catch (JsonProcessingException e) {
            log.error("Could not map ValidationErrorDAO to ValidationError", e);
        }
        return dto;
    }

    public static ValidationErrorDAO toValidationError(ValidationError dto) {
        ValidationErrorDAO ve = new ValidationErrorDAO();
        ve.error = Util.OBJECT_MAPPER.valueToTree(dto.error);
        return ve;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy