package com.qsoft.rs.sincoar.dominio.mapper;

import com.qsoft.rs.sincoar.dto.MdViewsDTO;
import com.qsoft.rs.sincoar.model.MdSchemas;
import com.qsoft.rs.sincoar.model.MdViews;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2022-09-02T16:14:47-0500",
    comments = "version: 1.5.2.Final, compiler: javac, environment: Java 17.0.4 (Private Build)"
)
public class MdViewsMapperImpl implements MdViewsMapper {

    @Override
    public MdViews getEntidad(MdViewsDTO mdViews) {
        if ( mdViews == null ) {
            return null;
        }

        MdViews mdViews1 = new MdViews();

        mdViews1.setSchemaIdFk( mdViewsDTOToMdSchemas( mdViews ) );
        if ( mdViews.getId() != null ) {
            mdViews1.setId( BigDecimal.valueOf( mdViews.getId() ) );
        }
        mdViews1.setViewName( mdViews.getViewName() );
        mdViews1.setNativeSql( mdViews.getNativeSql() );
        mdViews1.setNativeKey( mdViews.getNativeKey() );
        mdViews1.setLanguage( mdViews.getLanguage() );
        mdViews1.setComments( mdViews.getComments() );
        if ( mdViews.getLinecount() != null ) {
            mdViews1.setLinecount( BigInteger.valueOf( mdViews.getLinecount() ) );
        }
        if ( mdViews.getSecurityGroupId() != null ) {
            mdViews1.setSecurityGroupId( BigInteger.valueOf( mdViews.getSecurityGroupId() ) );
        }
        mdViews1.setCreatedOn( mdViews.getCreatedOn() );
        mdViews1.setCreatedBy( mdViews.getCreatedBy() );
        mdViews1.setLastUpdatedOn( mdViews.getLastUpdatedOn() );
        mdViews1.setLastUpdatedBy( mdViews.getLastUpdatedBy() );

        return mdViews1;
    }

    @Override
    public MdViewsDTO getDto(MdViews mdViews) {
        if ( mdViews == null ) {
            return null;
        }

        MdViewsDTO mdViewsDTO = new MdViewsDTO();

        BigDecimal id = mdViewsSchemaIdFkId( mdViews );
        if ( id != null ) {
            mdViewsDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdViews.getId() != null ) {
            mdViewsDTO.setId( mdViews.getId().intValue() );
        }
        mdViewsDTO.setViewName( mdViews.getViewName() );
        mdViewsDTO.setNativeSql( mdViews.getNativeSql() );
        mdViewsDTO.setNativeKey( mdViews.getNativeKey() );
        mdViewsDTO.setLanguage( mdViews.getLanguage() );
        mdViewsDTO.setComments( mdViews.getComments() );
        if ( mdViews.getLinecount() != null ) {
            mdViewsDTO.setLinecount( mdViews.getLinecount().intValue() );
        }
        if ( mdViews.getSecurityGroupId() != null ) {
            mdViewsDTO.setSecurityGroupId( mdViews.getSecurityGroupId().intValue() );
        }
        mdViewsDTO.setCreatedOn( mdViews.getCreatedOn() );
        mdViewsDTO.setCreatedBy( mdViews.getCreatedBy() );
        mdViewsDTO.setLastUpdatedOn( mdViews.getLastUpdatedOn() );
        mdViewsDTO.setLastUpdatedBy( mdViews.getLastUpdatedBy() );

        return mdViewsDTO;
    }

    protected MdSchemas mdViewsDTOToMdSchemas(MdViewsDTO mdViewsDTO) {
        if ( mdViewsDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

        if ( mdViewsDTO.getSchemaIdFk() != null ) {
            mdSchemas.setId( BigDecimal.valueOf( mdViewsDTO.getSchemaIdFk() ) );
        }

        return mdSchemas;
    }

    private BigDecimal mdViewsSchemaIdFkId(MdViews mdViews) {
        if ( mdViews == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdViews.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
