Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ar.com.bbva.suip.suipbackoffice.mapper;
- import javax.annotation.PostConstruct;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import ar.com.bbva.model.suipportalmodel.model.Comercio;
- import ar.com.bbva.model.suipportalmodel.model.Contribuyente;
- import ar.com.bbva.model.suipportalmodel.model.Rubro;
- import ar.com.bbva.model.suipportalmodel.model.Sucursal;
- import ar.com.bbva.suip.suipbackoffice.dto.ComercioDTO;
- import ar.com.bbva.suip.suipbackoffice.dto.ContribuyenteDTO;
- import ar.com.bbva.suip.suipbackoffice.dto.RubroDTO;
- import ar.com.bbva.suip.suipbackoffice.dto.SucursalDTO;
- import ma.glasnost.orika.CustomMapper;
- import ma.glasnost.orika.MapperFactory;
- import ma.glasnost.orika.MappingContext;
- @Component
- public class BackofficeMapper {
- static Logger logger = LoggerFactory.getLogger(BackofficeMapper.class);
- @Autowired
- Mapper mapper;
- @Autowired
- MapperFactory mapperFactory;
- @PostConstruct
- public void initialize() {
- logger.info("Backoffice mapper initialize");
- mapperFactory.classMap(Comercio.class, ComercioDTO.class).customize(new CustomMapper<Comercio, ComercioDTO>() {
- @Override
- public void mapAtoB(Comercio a, ComercioDTO b, MappingContext context) {
- if(a.getContribuyente() != null ) {
- b.setContribuyente(mapper.map(a.getContribuyente(), ContribuyenteDTO.class));
- }
- if (a.getRubros() != null && !a.getRubros().isEmpty()) {
- b.setRubros(mapper.mapList(a.getRubros(), RubroDTO.class));
- }
- b.setId(a.getId());
- b.setNombre(a.getNombre());
- b.setNoConvocable(a.getNoConvocable());
- b.setId_logo(a.getIdLogo());
- b.setDescripcion(a.getDescripcion());
- b.setPublicado(a.getPublicado());
- b.setDescripcionVista(a.getDescripcionVista());
- b.setAdquirienteNulo(a.getAdquirenteNulo());
- b.setModificoDescripcion(a.getModificoDescripcion());
- b.setActividad(a.getActividad());
- }
- });
- mapperFactory.classMap(Sucursal.class, SucursalDTO.class).customize(new CustomMapper<Sucursal, SucursalDTO>() {
- @Override
- public void mapAtoB(Sucursal a, SucursalDTO b, MappingContext context) {
- b.setId(a.getId());
- b.setFechaCierre(a.getFechaCierre());
- b.setNombre(a.getNombre());
- b.setTelefono1(a.getTelefono1());
- b.setTelefono2(a.getTelefono2());
- b.setVentaTelefonica(a.getVentaTelefonica());
- b.setWebsiteVenta(a.getVentaTelefonica());
- b.setFechaCierre(a.getFechaCierre());
- b.setWebsiteVenta(a.getWebsiteVenta());
- }
- });
- mapperFactory.classMap(Rubro.class, RubroDTO.class).customize(new CustomMapper<Rubro, RubroDTO>() {
- @Override
- public void mapAtoB(Rubro a, RubroDTO b, MappingContext context) {
- b.setId(a.getId());
- b.setNombre(a.getNombre());
- if(a.getSubRubros() != null && !a.getSubRubros().isEmpty()) {
- b.setSubRubros(mapper.mapList(a.getSubRubros(), RubroDTO.class));
- }
- }
- });
- mapperFactory.classMap(Contribuyente.class, ContribuyenteDTO.class).customize(new CustomMapper<Contribuyente, ContribuyenteDTO>() {
- @Override
- public void mapAtoB(Contribuyente a, ContribuyenteDTO b, MappingContext context) {
- b.setId(a.getId());
- b.setCuit(a.getCuit());
- b.setRazonSocial(a.getRazonSocial());
- b.setEmail(a.getEmail());
- b.setDomicilioLegal(a.getDomicilioLegal());
- b.setNombreFirmante(a.getNombreFirmante());
- b.setCargoFirmante(a.getCargoFirmante());
- b.setTieneAfranquiciados(a.getTieneFranquiciados());
- b.setCodigoActivacion(a.getCodigoActivacion());
- b.setFechaConfirmacionDatos(a.getFechaConfirmacionDatos());
- b.setCliente(a.getCliente());
- b.setAdquirente(a.getAdquirente());
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement