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

import com.qsoft.rs.sincoar.dto.MdCatalogsDTO;
import com.qsoft.rs.sincoar.model.MdCatalogs;
import com.qsoft.rs.sincoar.model.MdConnections;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MdCatalogs getEntidad(MdCatalogsDTO mdCatalogs) {
        if ( mdCatalogs == null ) {
            return null;
        }

        MdCatalogs mdCatalogs1 = new MdCatalogs();

        mdCatalogs1.setConnectionIdFk( mdCatalogsDTOToMdConnections( mdCatalogs ) );
        if ( mdCatalogs.getId() != null ) {
            mdCatalogs1.setId( BigDecimal.valueOf( mdCatalogs.getId() ) );
        }
        mdCatalogs1.setCatalogName( mdCatalogs.getCatalogName() );
        mdCatalogs1.setDummyFlag( mdCatalogs.getDummyFlag() );
        mdCatalogs1.setNativeSql( mdCatalogs.getNativeSql() );
        mdCatalogs1.setNativeKey( mdCatalogs.getNativeKey() );
        mdCatalogs1.setComments( mdCatalogs.getComments() );
        if ( mdCatalogs.getSecurityGroupId() != null ) {
            mdCatalogs1.setSecurityGroupId( BigInteger.valueOf( mdCatalogs.getSecurityGroupId() ) );
        }
        mdCatalogs1.setCreatedOn( mdCatalogs.getCreatedOn() );
        mdCatalogs1.setCreatedBy( mdCatalogs.getCreatedBy() );
        mdCatalogs1.setLastUpdatedOn( mdCatalogs.getLastUpdatedOn() );
        mdCatalogs1.setLastUpdatedBy( mdCatalogs.getLastUpdatedBy() );

        return mdCatalogs1;
    }

    @Override
    public MdCatalogsDTO getDto(MdCatalogs mdCatalogs) {
        if ( mdCatalogs == null ) {
            return null;
        }

        MdCatalogsDTO mdCatalogsDTO = new MdCatalogsDTO();

        BigDecimal id = mdCatalogsConnectionIdFkId( mdCatalogs );
        if ( id != null ) {
            mdCatalogsDTO.setConnectionIdFk( id.intValue() );
        }
        if ( mdCatalogs.getId() != null ) {
            mdCatalogsDTO.setId( mdCatalogs.getId().intValue() );
        }
        mdCatalogsDTO.setCatalogName( mdCatalogs.getCatalogName() );
        mdCatalogsDTO.setDummyFlag( mdCatalogs.getDummyFlag() );
        mdCatalogsDTO.setNativeSql( mdCatalogs.getNativeSql() );
        mdCatalogsDTO.setNativeKey( mdCatalogs.getNativeKey() );
        mdCatalogsDTO.setComments( mdCatalogs.getComments() );
        if ( mdCatalogs.getSecurityGroupId() != null ) {
            mdCatalogsDTO.setSecurityGroupId( mdCatalogs.getSecurityGroupId().intValue() );
        }
        mdCatalogsDTO.setCreatedOn( mdCatalogs.getCreatedOn() );
        mdCatalogsDTO.setCreatedBy( mdCatalogs.getCreatedBy() );
        mdCatalogsDTO.setLastUpdatedOn( mdCatalogs.getLastUpdatedOn() );
        mdCatalogsDTO.setLastUpdatedBy( mdCatalogs.getLastUpdatedBy() );

        return mdCatalogsDTO;
    }

    protected MdConnections mdCatalogsDTOToMdConnections(MdCatalogsDTO mdCatalogsDTO) {
        if ( mdCatalogsDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

        if ( mdCatalogsDTO.getConnectionIdFk() != null ) {
            mdConnections.setId( BigDecimal.valueOf( mdCatalogsDTO.getConnectionIdFk() ) );
        }

        return mdConnections;
    }

    private BigDecimal mdCatalogsConnectionIdFkId(MdCatalogs mdCatalogs) {
        if ( mdCatalogs == null ) {
            return null;
        }
        MdConnections connectionIdFk = mdCatalogs.getConnectionIdFk();
        if ( connectionIdFk == null ) {
            return null;
        }
        BigDecimal id = connectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
