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

import com.qsoft.rs.sincoar.dto.MdPartitionsDTO;
import com.qsoft.rs.sincoar.model.MdPartitions;
import com.qsoft.rs.sincoar.model.MdTables;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MdPartitions getEntidad(MdPartitionsDTO mdPartitions) {
        if ( mdPartitions == null ) {
            return null;
        }

        MdPartitions mdPartitions1 = new MdPartitions();

        mdPartitions1.setTableIdFk( mdPartitionsDTOToMdTables( mdPartitions ) );
        if ( mdPartitions.getId() != null ) {
            mdPartitions1.setId( BigDecimal.valueOf( mdPartitions.getId() ) );
        }
        mdPartitions1.setNativeSql( mdPartitions.getNativeSql() );
        mdPartitions1.setPartitionExpression( mdPartitions.getPartitionExpression() );
        mdPartitions1.setComments( mdPartitions.getComments() );
        if ( mdPartitions.getSecurityGroupId() != null ) {
            mdPartitions1.setSecurityGroupId( BigInteger.valueOf( mdPartitions.getSecurityGroupId() ) );
        }
        mdPartitions1.setCreatedBy( mdPartitions.getCreatedBy() );
        mdPartitions1.setCreatedOn( mdPartitions.getCreatedOn() );
        mdPartitions1.setLastUpdatedBy( mdPartitions.getLastUpdatedBy() );
        mdPartitions1.setLastUpdatedOn( mdPartitions.getLastUpdatedOn() );

        return mdPartitions1;
    }

    @Override
    public MdPartitionsDTO getDto(MdPartitions mdPartitions) {
        if ( mdPartitions == null ) {
            return null;
        }

        MdPartitionsDTO mdPartitionsDTO = new MdPartitionsDTO();

        BigDecimal id = mdPartitionsTableIdFkId( mdPartitions );
        if ( id != null ) {
            mdPartitionsDTO.setTableIdFk( id.intValue() );
        }
        if ( mdPartitions.getId() != null ) {
            mdPartitionsDTO.setId( mdPartitions.getId().intValue() );
        }
        mdPartitionsDTO.setNativeSql( mdPartitions.getNativeSql() );
        mdPartitionsDTO.setPartitionExpression( mdPartitions.getPartitionExpression() );
        mdPartitionsDTO.setComments( mdPartitions.getComments() );
        if ( mdPartitions.getSecurityGroupId() != null ) {
            mdPartitionsDTO.setSecurityGroupId( mdPartitions.getSecurityGroupId().intValue() );
        }
        mdPartitionsDTO.setCreatedBy( mdPartitions.getCreatedBy() );
        mdPartitionsDTO.setCreatedOn( mdPartitions.getCreatedOn() );
        mdPartitionsDTO.setLastUpdatedBy( mdPartitions.getLastUpdatedBy() );
        mdPartitionsDTO.setLastUpdatedOn( mdPartitions.getLastUpdatedOn() );

        return mdPartitionsDTO;
    }

    protected MdTables mdPartitionsDTOToMdTables(MdPartitionsDTO mdPartitionsDTO) {
        if ( mdPartitionsDTO == null ) {
            return null;
        }

        MdTables mdTables = new MdTables();

        if ( mdPartitionsDTO.getTableIdFk() != null ) {
            mdTables.setId( BigDecimal.valueOf( mdPartitionsDTO.getTableIdFk() ) );
        }

        return mdTables;
    }

    private BigDecimal mdPartitionsTableIdFkId(MdPartitions mdPartitions) {
        if ( mdPartitions == null ) {
            return null;
        }
        MdTables tableIdFk = mdPartitions.getTableIdFk();
        if ( tableIdFk == null ) {
            return null;
        }
        BigDecimal id = tableIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
