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

import com.qsoft.rs.sincoar.dto.MdApplicationsDTO;
import com.qsoft.rs.sincoar.model.MdApplications;
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 MdApplicationsMapperImpl implements MdApplicationsMapper {

    @Override
    public MdApplications getEntidad(MdApplicationsDTO mdApplications) {
        if ( mdApplications == null ) {
            return null;
        }

        MdApplications mdApplications1 = new MdApplications();

        mdApplications1.setConnectionIdFk( mdApplicationsDTOToMdConnections( mdApplications ) );
        if ( mdApplications.getId() != null ) {
            mdApplications1.setId( BigDecimal.valueOf( mdApplications.getId() ) );
        }
        mdApplications1.setName( mdApplications.getName() );
        mdApplications1.setDescription( mdApplications.getDescription() );
        mdApplications1.setBaseDir( mdApplications.getBaseDir() );
        mdApplications1.setOutputDir( mdApplications.getOutputDir() );
        mdApplications1.setBackupDir( mdApplications.getBackupDir() );
        if ( mdApplications.getInplace() != null ) {
            mdApplications1.setInplace( BigInteger.valueOf( mdApplications.getInplace() ) );
        }
        if ( mdApplications.getSecurityGroupId() != null ) {
            mdApplications1.setSecurityGroupId( BigInteger.valueOf( mdApplications.getSecurityGroupId() ) );
        }
        mdApplications1.setCreatedOn( mdApplications.getCreatedOn() );
        mdApplications1.setCreatedBy( mdApplications.getCreatedBy() );
        mdApplications1.setLastUpdatedOn( mdApplications.getLastUpdatedOn() );
        mdApplications1.setLastUpdatedBy( mdApplications.getLastUpdatedBy() );

        validaNulos( mdApplications, mdApplications1 );

        return mdApplications1;
    }

    @Override
    public MdApplicationsDTO getDto(MdApplications mdApplications) {
        if ( mdApplications == null ) {
            return null;
        }

        MdApplicationsDTO mdApplicationsDTO = new MdApplicationsDTO();

        BigDecimal id = mdApplicationsConnectionIdFkId( mdApplications );
        if ( id != null ) {
            mdApplicationsDTO.setConnectionIdFk( id.intValue() );
        }
        if ( mdApplications.getId() != null ) {
            mdApplicationsDTO.setId( mdApplications.getId().intValue() );
        }
        mdApplicationsDTO.setName( mdApplications.getName() );
        mdApplicationsDTO.setDescription( mdApplications.getDescription() );
        mdApplicationsDTO.setBaseDir( mdApplications.getBaseDir() );
        mdApplicationsDTO.setOutputDir( mdApplications.getOutputDir() );
        mdApplicationsDTO.setBackupDir( mdApplications.getBackupDir() );
        if ( mdApplications.getInplace() != null ) {
            mdApplicationsDTO.setInplace( mdApplications.getInplace().intValue() );
        }
        if ( mdApplications.getSecurityGroupId() != null ) {
            mdApplicationsDTO.setSecurityGroupId( mdApplications.getSecurityGroupId().intValue() );
        }
        mdApplicationsDTO.setCreatedOn( mdApplications.getCreatedOn() );
        mdApplicationsDTO.setCreatedBy( mdApplications.getCreatedBy() );
        mdApplicationsDTO.setLastUpdatedOn( mdApplications.getLastUpdatedOn() );
        mdApplicationsDTO.setLastUpdatedBy( mdApplications.getLastUpdatedBy() );

        return mdApplicationsDTO;
    }

    protected MdConnections mdApplicationsDTOToMdConnections(MdApplicationsDTO mdApplicationsDTO) {
        if ( mdApplicationsDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

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

        return mdConnections;
    }

    private BigDecimal mdApplicationsConnectionIdFkId(MdApplications mdApplications) {
        if ( mdApplications == null ) {
            return null;
        }
        MdConnections connectionIdFk = mdApplications.getConnectionIdFk();
        if ( connectionIdFk == null ) {
            return null;
        }
        BigDecimal id = connectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
