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

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

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

    @Override
    public MdPackages getEntidad(MdPackagesDTO mdPackages) {
        if ( mdPackages == null ) {
            return null;
        }

        MdPackages mdPackages1 = new MdPackages();

        mdPackages1.setSchemaIdFk( mdPackagesDTOToMdSchemas( mdPackages ) );
        if ( mdPackages.getId() != null ) {
            mdPackages1.setId( BigDecimal.valueOf( mdPackages.getId() ) );
        }
        mdPackages1.setName( mdPackages.getName() );
        mdPackages1.setPackageHeader( mdPackages.getPackageHeader() );
        mdPackages1.setNativeSql( mdPackages.getNativeSql() );
        mdPackages1.setNativeKey( mdPackages.getNativeKey() );
        mdPackages1.setLanguage( mdPackages.getLanguage() );
        mdPackages1.setComments( mdPackages.getComments() );
        if ( mdPackages.getSecurityGroupId() != null ) {
            mdPackages1.setSecurityGroupId( BigInteger.valueOf( mdPackages.getSecurityGroupId() ) );
        }
        mdPackages1.setCreatedOn( mdPackages.getCreatedOn() );
        mdPackages1.setCreatedBy( mdPackages.getCreatedBy() );
        mdPackages1.setLastUpdatedOn( mdPackages.getLastUpdatedOn() );
        mdPackages1.setLastUpdatedBy( mdPackages.getLastUpdatedBy() );

        return mdPackages1;
    }

    @Override
    public MdPackagesDTO getDto(MdPackages mdPackages) {
        if ( mdPackages == null ) {
            return null;
        }

        MdPackagesDTO mdPackagesDTO = new MdPackagesDTO();

        BigDecimal id = mdPackagesSchemaIdFkId( mdPackages );
        if ( id != null ) {
            mdPackagesDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdPackages.getId() != null ) {
            mdPackagesDTO.setId( mdPackages.getId().intValue() );
        }
        mdPackagesDTO.setName( mdPackages.getName() );
        mdPackagesDTO.setPackageHeader( mdPackages.getPackageHeader() );
        mdPackagesDTO.setNativeSql( mdPackages.getNativeSql() );
        mdPackagesDTO.setNativeKey( mdPackages.getNativeKey() );
        mdPackagesDTO.setLanguage( mdPackages.getLanguage() );
        mdPackagesDTO.setComments( mdPackages.getComments() );
        if ( mdPackages.getSecurityGroupId() != null ) {
            mdPackagesDTO.setSecurityGroupId( mdPackages.getSecurityGroupId().intValue() );
        }
        mdPackagesDTO.setCreatedOn( mdPackages.getCreatedOn() );
        mdPackagesDTO.setCreatedBy( mdPackages.getCreatedBy() );
        mdPackagesDTO.setLastUpdatedOn( mdPackages.getLastUpdatedOn() );
        mdPackagesDTO.setLastUpdatedBy( mdPackages.getLastUpdatedBy() );

        return mdPackagesDTO;
    }

    protected MdSchemas mdPackagesDTOToMdSchemas(MdPackagesDTO mdPackagesDTO) {
        if ( mdPackagesDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

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

        return mdSchemas;
    }

    private BigDecimal mdPackagesSchemaIdFkId(MdPackages mdPackages) {
        if ( mdPackages == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdPackages.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
