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

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

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

    @Override
    public MdMigrParameter getEntidad(MdMigrParameterDTO mdMigrParameter) {
        if ( mdMigrParameter == null ) {
            return null;
        }

        MdMigrParameter mdMigrParameter1 = new MdMigrParameter();

        mdMigrParameter1.setConnectionIdFk( mdMigrParameterDTOToMdConnections( mdMigrParameter ) );
        if ( mdMigrParameter.getId() != null ) {
            mdMigrParameter1.setId( BigDecimal.valueOf( mdMigrParameter.getId() ) );
        }
        if ( mdMigrParameter.getObjectId() != null ) {
            mdMigrParameter1.setObjectId( BigInteger.valueOf( mdMigrParameter.getObjectId() ) );
        }
        mdMigrParameter1.setObjectType( mdMigrParameter.getObjectType() );
        if ( mdMigrParameter.getParamExisting() != null ) {
            mdMigrParameter1.setParamExisting( BigInteger.valueOf( mdMigrParameter.getParamExisting() ) );
        }
        if ( mdMigrParameter.getParamOrder() != null ) {
            mdMigrParameter1.setParamOrder( BigInteger.valueOf( mdMigrParameter.getParamOrder() ) );
        }
        mdMigrParameter1.setParamName( mdMigrParameter.getParamName() );
        mdMigrParameter1.setParamType( mdMigrParameter.getParamType() );
        mdMigrParameter1.setParamDataType( mdMigrParameter.getParamDataType() );
        if ( mdMigrParameter.getPercision() != null ) {
            mdMigrParameter1.setPercision( BigInteger.valueOf( mdMigrParameter.getPercision() ) );
        }
        if ( mdMigrParameter.getScale() != null ) {
            mdMigrParameter1.setScale( BigInteger.valueOf( mdMigrParameter.getScale() ) );
        }
        mdMigrParameter1.setNullable( mdMigrParameter.getNullable() );
        mdMigrParameter1.setDefaultValue( mdMigrParameter.getDefaultValue() );
        if ( mdMigrParameter.getSecurityGroupId() != null ) {
            mdMigrParameter1.setSecurityGroupId( BigInteger.valueOf( mdMigrParameter.getSecurityGroupId() ) );
        }
        mdMigrParameter1.setCreatedOn( mdMigrParameter.getCreatedOn() );
        mdMigrParameter1.setCreatedBy( mdMigrParameter.getCreatedBy() );
        mdMigrParameter1.setLastUpdatedOn( mdMigrParameter.getLastUpdatedOn() );
        mdMigrParameter1.setLastUpdatedBy( mdMigrParameter.getLastUpdatedBy() );

        return mdMigrParameter1;
    }

    @Override
    public MdMigrParameterDTO getDto(MdMigrParameter mdMigrParameter) {
        if ( mdMigrParameter == null ) {
            return null;
        }

        MdMigrParameterDTO mdMigrParameterDTO = new MdMigrParameterDTO();

        BigDecimal id = mdMigrParameterConnectionIdFkId( mdMigrParameter );
        if ( id != null ) {
            mdMigrParameterDTO.setConnectionIdFk( id.intValue() );
        }
        if ( mdMigrParameter.getId() != null ) {
            mdMigrParameterDTO.setId( mdMigrParameter.getId().intValue() );
        }
        if ( mdMigrParameter.getObjectId() != null ) {
            mdMigrParameterDTO.setObjectId( mdMigrParameter.getObjectId().intValue() );
        }
        mdMigrParameterDTO.setObjectType( mdMigrParameter.getObjectType() );
        if ( mdMigrParameter.getParamExisting() != null ) {
            mdMigrParameterDTO.setParamExisting( mdMigrParameter.getParamExisting().intValue() );
        }
        if ( mdMigrParameter.getParamOrder() != null ) {
            mdMigrParameterDTO.setParamOrder( mdMigrParameter.getParamOrder().intValue() );
        }
        mdMigrParameterDTO.setParamName( mdMigrParameter.getParamName() );
        mdMigrParameterDTO.setParamType( mdMigrParameter.getParamType() );
        mdMigrParameterDTO.setParamDataType( mdMigrParameter.getParamDataType() );
        if ( mdMigrParameter.getPercision() != null ) {
            mdMigrParameterDTO.setPercision( mdMigrParameter.getPercision().intValue() );
        }
        if ( mdMigrParameter.getScale() != null ) {
            mdMigrParameterDTO.setScale( mdMigrParameter.getScale().intValue() );
        }
        mdMigrParameterDTO.setNullable( mdMigrParameter.getNullable() );
        mdMigrParameterDTO.setDefaultValue( mdMigrParameter.getDefaultValue() );
        if ( mdMigrParameter.getSecurityGroupId() != null ) {
            mdMigrParameterDTO.setSecurityGroupId( mdMigrParameter.getSecurityGroupId().intValue() );
        }
        mdMigrParameterDTO.setCreatedOn( mdMigrParameter.getCreatedOn() );
        mdMigrParameterDTO.setCreatedBy( mdMigrParameter.getCreatedBy() );
        mdMigrParameterDTO.setLastUpdatedOn( mdMigrParameter.getLastUpdatedOn() );
        mdMigrParameterDTO.setLastUpdatedBy( mdMigrParameter.getLastUpdatedBy() );

        return mdMigrParameterDTO;
    }

    protected MdConnections mdMigrParameterDTOToMdConnections(MdMigrParameterDTO mdMigrParameterDTO) {
        if ( mdMigrParameterDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

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

        return mdConnections;
    }

    private BigDecimal mdMigrParameterConnectionIdFkId(MdMigrParameter mdMigrParameter) {
        if ( mdMigrParameter == null ) {
            return null;
        }
        MdConnections connectionIdFk = mdMigrParameter.getConnectionIdFk();
        if ( connectionIdFk == null ) {
            return null;
        }
        BigDecimal id = connectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
