From 0532d002d437c727475a842014cf7ff6ec484734 Mon Sep 17 00:00:00 2001 From: Fabio Faria Date: Thu, 15 Dec 2022 14:30:13 -0300 Subject: [PATCH] bug#AL-1726 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modificações dos metodos de integraçao para melhoria junto ao banco de dados --- pom.xml | 19 ++++++++- .../dao/hibernate/GenericHibernateDAO.java | 14 ++++++- .../dao/hibernate/SapHibernateDAO.java | 39 +++++++++++-------- .../ventaboletos/rest/IntegracaoSapRest.java | 4 +- .../service/impl/SapServiceImpl.java | 3 +- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index cd016e0b0..1c25c74df 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.0.9 + 1.0.10 @@ -133,7 +133,22 @@ org.jboss.resteasy resteasy-jaxrs - 3.15.3.Final + 3.14.0.Final + provided + + + + org.apache.httpcomponents + httpcore + 4.4.14 + provided + + + + org.apache.httpcomponents + httpclient + 4.5.13 + provided diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/GenericHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/GenericHibernateDAO.java index 008d4e991..a2a235a8c 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/GenericHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/GenericHibernateDAO.java @@ -3,9 +3,12 @@ package com.rjconsultores.ventaboletos.dao.hibernate; import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import com.rjconsultores.ventaboletos.dao.GenericDAO; + import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -21,8 +24,6 @@ import org.hibernate.loader.criteria.CriteriaLoader; import org.hibernate.persister.entity.OuterJoinLoadable; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; -import com.rjconsultores.ventaboletos.dao.GenericDAO; - /** * * @author gleimar @@ -158,4 +159,13 @@ public class GenericHibernateDAO extends HibernateDa return info; } + public static List castList(Class clazz, Collection rawCollection) + throws ClassCastException { + List result = new ArrayList(rawCollection.size()); + for (Object o : rawCollection) { + result.add(clazz.cast(o)); + } + return result; + } + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/SapHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/SapHibernateDAO.java index d63acbb5c..973d04e6d 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/SapHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/SapHibernateDAO.java @@ -7,6 +7,15 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import javax.sql.DataSource; + +import org.hibernate.Query; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + import com.rjconsultores.ventaboletos.dao.SapDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.FechamentoCntcorrente; @@ -15,27 +24,26 @@ import com.rjconsultores.ventaboletos.enums.StatusIntegracaoSap; import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.vo.integracao.FechamentoCntCorrenteVO; -import org.hibernate.Query; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Repository; - @Repository("sapDAO") public class SapHibernateDAO extends GenericHibernateDAO implements SapDAO { @Autowired public SapHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); - } + } + + @Autowired + @Qualifier("dataSourceWrite") + DataSource scoDs; @Override + @Transactional public List obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status) { return obtenerTodosParaRemessa(empresa, dataDe, dataAte, status, null); } - @SuppressWarnings("unchecked") @Override + @Transactional public List obtenerTodosParaRemessa(Empresa empresa, Date dataDe, Date dataAte, String status, PuntoVenta puntoVenta) { StringBuilder sb = new StringBuilder(); @@ -142,6 +150,7 @@ public class SapHibernateDAO extends GenericHibernateDAO