diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java index 74734ae..6b0c45d 100644 --- a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java +++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java @@ -1,16 +1,19 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.controller.mobile.controller.customer; +import com.arrebol.apc.controller.mobile.repository.views.CustomerWithoutRenovationViewRepository; import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository; import com.arrebol.apc.model.ModelParameter; +import com.arrebol.apc.model.core.constance.CustomerWithoutRenovationViewCfg; import com.arrebol.apc.model.core.constance.LoanByUserViewCfg; import com.arrebol.apc.model.enums.PreferenceValue; +import com.arrebol.apc.model.views.CustomerWithoutRenovationView; import com.arrebol.apc.model.views.LoanByUserView; import java.io.Serializable; import java.util.ArrayList; @@ -24,40 +27,65 @@ import org.apache.logging.log4j.Logger; */ public class CustomerController implements Serializable { - /** - * - * @param orderList - * @param userId - * @return - * @throws Exception - */ - public List findAllLoansByUserId(String orderList, String userId) throws Exception { - try { - List parameters = new ArrayList<>(); + /** + * + * @param orderList + * @param userId + * @return + * @throws Exception + */ + public List findAllLoansByUserId(String orderList, String userId) throws Exception { + try { + List parameters = new ArrayList<>(); - boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList); + boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList); - parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId)); + parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId)); - return loanByUserViewRepository - .findAllLoansByUserId( - isByOrderInList - ? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST - : LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME, - parameters - ); - } catch (Exception e) { - logger.error("findAllLoansByUserId", e); - throw e; - } - } + return loanByUserViewRepository + .findAllLoansByUserId( + isByOrderInList + ? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST + : LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME, + parameters + ); + } catch (Exception e) { + logger.error("findAllLoansByUserId", e); + throw e; + } + } - private static final long serialVersionUID = -6689182942800786108L; - final Logger logger = LogManager.getLogger(CustomerController.class); + /** + * + * @param idRoute + * @return + * @throws Exception + */ + public List findAllNonRenewingCustomersByRuteId(String idRoute) throws Exception { + try { + List parameters = new ArrayList<>(); - private final LoanByUserViewRepository loanByUserViewRepository; + parameters.add(new ModelParameter(CustomerWithoutRenovationViewCfg.FIELD_RUTE_ID, idRoute)); - public CustomerController() { - this.loanByUserViewRepository = new LoanByUserViewRepository(); - } + return customerWithoutRenovationViewRepository + .nonRenewingCustomersByRuteId( + CustomerWithoutRenovationViewCfg.QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE, + parameters + ); + } catch (Exception e) { + logger.error("findAllLoansByUserId", e); + throw e; + } + } + + private static final long serialVersionUID = -6689182942800786108L; + final Logger logger = LogManager.getLogger(CustomerController.class); + + private final LoanByUserViewRepository loanByUserViewRepository; + private final CustomerWithoutRenovationViewRepository customerWithoutRenovationViewRepository; + + public CustomerController() { + this.loanByUserViewRepository = new LoanByUserViewRepository(); + this.customerWithoutRenovationViewRepository = new CustomerWithoutRenovationViewRepository(); + } } diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/CustomerWithoutRenovationViewRepository.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/CustomerWithoutRenovationViewRepository.java new file mode 100644 index 0000000..bc6637d --- /dev/null +++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/CustomerWithoutRenovationViewRepository.java @@ -0,0 +1,54 @@ +/* + * Arrebol Consultancy copyright. + * + * This code belongs to Arrebol Consultancy + * its use, redistribution or modification are prohibited + * without written authorization from Arrebol Consultancy. + */ +package com.arrebol.apc.controller.mobile.repository.views; + +import com.arrebol.apc.controller.mobile.repository.GenericRepository; +import com.arrebol.apc.model.ModelParameter; +import com.arrebol.apc.model.views.CustomerWithoutRenovationView; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * + * @author Carlos Janitzio Zavala Lopez + */ +public class CustomerWithoutRenovationViewRepository extends GenericRepository implements Serializable { + + /** + * + * @param xmlQuery + * @param parameters + * @return + * @throws Exception + */ + public List nonRenewingCustomersByRuteId(String xmlQuery, List parameters) throws Exception { + logger.debug("nonRenewingCustomersByRuteId"); + List results = new ArrayList<>(); + + try { + results = createNamedQueryResultList( + CustomerWithoutRenovationView.class, + xmlQuery, + parameters + ); + + } catch (Exception e) { + logger.error("nonRenewingCustomersByRuteId", e); + throw e; + } + + return results; + } + + private static final long serialVersionUID = 5669198954766725476L; + final Logger logger = LogManager.getLogger(CustomerWithoutRenovationViewRepository.class); + +} diff --git a/ace-controller-mobile/src/test/resources/apc.cfg.xml b/ace-controller-mobile/src/test/resources/apc.cfg.xml index 6572c6b..c8fa0d7 100644 --- a/ace-controller-mobile/src/test/resources/apc.cfg.xml +++ b/ace-controller-mobile/src/test/resources/apc.cfg.xml @@ -220,6 +220,7 @@ + diff --git a/ace-controller/src/test/resources/apc.cfg.xml b/ace-controller/src/test/resources/apc.cfg.xml index 7179e6f..90a6219 100644 --- a/ace-controller/src/test/resources/apc.cfg.xml +++ b/ace-controller/src/test/resources/apc.cfg.xml @@ -216,6 +216,7 @@ + diff --git a/ace-model/pom.xml b/ace-model/pom.xml index c5c5c99..9f79347 100644 --- a/ace-model/pom.xml +++ b/ace-model/pom.xml @@ -80,8 +80,8 @@ Localhost jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5 - apoprocomlocalhost - Yj$2Da0z! + root + root 10 40 1800 diff --git a/ace-model/src/main/java/com/arrebol/apc/model/core/constance/CustomerWithoutRenovationViewCfg.java b/ace-model/src/main/java/com/arrebol/apc/model/core/constance/CustomerWithoutRenovationViewCfg.java new file mode 100644 index 0000000..0ca2a55 --- /dev/null +++ b/ace-model/src/main/java/com/arrebol/apc/model/core/constance/CustomerWithoutRenovationViewCfg.java @@ -0,0 +1,19 @@ +/* + * Arrebol Consultancy copyright. + * + * This code belongs to Arrebol Consultancy + * its use, redistribution or modification are prohibited + * without written authorization from Arrebol Consultancy. + */ +package com.arrebol.apc.model.core.constance; + +/** + * + * @author Carlos Janitzio Zavala Lopez + */ +public interface CustomerWithoutRenovationViewCfg extends GenericCfg { + + String QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE = "findAllNonRenewingCustomersByRuteIdList"; + + String FIELD_RUTE_ID = "idRoute"; +} diff --git a/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationSimpleDTO.java b/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationSimpleDTO.java new file mode 100644 index 0000000..0668bda --- /dev/null +++ b/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationSimpleDTO.java @@ -0,0 +1,137 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.arrebol.apc.model.views; + +import java.io.Serializable; +import java.util.Date; + +/** + * + * @author Oscar + */ +public class CustomerWithoutRenovationSimpleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String personName; + private Date lastLoan; + private String amountPaid; + private String amountToPay; + private String saldoInsoluto; + private String actionNumber; + private String numFee; + private String addressHome; + private String addressBusiness; + private String companyName; + private String strPaymentDate; + + // Constructor + public CustomerWithoutRenovationSimpleDTO() { + } + + // Constructor desde entidad + public CustomerWithoutRenovationSimpleDTO(CustomerWithoutRenovationView entity) { + this.personName = entity.getPersonName(); + this.lastLoan = entity.getLastLoan(); + this.amountPaid = entity.getAmountPaid(); + this.amountToPay = entity.getAmountToPay(); + this.saldoInsoluto = entity.getSaldoInsoluto(); + this.actionNumber = entity.getActionNumber(); + this.numFee = entity.getNumFee(); + this.addressHome = entity.getAddressHome(); + this.addressBusiness = entity.getAddressBusiness(); + this.companyName = entity.getCompanyName(); + this.strPaymentDate = entity.getStrPaymentDate(); + } + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public Date getLastLoan() { + return lastLoan; + } + + public void setLastLoan(Date lastLoan) { + this.lastLoan = lastLoan; + } + + public String getAmountPaid() { + return amountPaid; + } + + public void setAmountPaid(String amountPaid) { + this.amountPaid = amountPaid; + } + + public String getAmountToPay() { + return amountToPay; + } + + public void setAmountToPay(String amountToPay) { + this.amountToPay = amountToPay; + } + + public String getSaldoInsoluto() { + return saldoInsoluto; + } + + public void setSaldoInsoluto(String saldoInsoluto) { + this.saldoInsoluto = saldoInsoluto; + } + + public String getActionNumber() { + return actionNumber; + } + + public void setActionNumber(String actionNumber) { + this.actionNumber = actionNumber; + } + + public String getNumFee() { + return numFee; + } + + public void setNumFee(String numFee) { + this.numFee = numFee; + } + + public String getAddressHome() { + return addressHome; + } + + public void setAddressHome(String addressHome) { + this.addressHome = addressHome; + } + + public String getAddressBusiness() { + return addressBusiness; + } + + public void setAddressBusiness(String addressBusiness) { + this.addressBusiness = addressBusiness; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getStrPaymentDate() { + return strPaymentDate; + } + + public void setStrPaymentDate(String strPaymentDate) { + this.strPaymentDate = strPaymentDate; + } + +} diff --git a/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationView.java b/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationView.java index 06ac9aa..4b96072 100644 --- a/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationView.java +++ b/ace-model/src/main/java/com/arrebol/apc/model/views/CustomerWithoutRenovationView.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.views; @@ -30,197 +30,203 @@ import org.hibernate.annotations.Immutable; @Table(name = "APC_CUSTOMERS_WITHOUT_RENOVATION_VIEW") public class CustomerWithoutRenovationView implements Serializable { - private static final long serialVersionUID = 3731003393000465083L; + private static final long serialVersionUID = 3731003393000465083L; - @Id - @Column(name = "id", length = 36) - private String id; + @Id + @Column(name = "id", length = 36) + private String id; - @Column(name = "available_person") - private String personName; + @Column(name = "available_person") + private String personName; - @Column(name = "route_name") - private String routeName; + @Column(name = "route_name") + private String routeName; - @Column(name = "last_loan") - @Temporal(javax.persistence.TemporalType.DATE) - private Date lastLoan; - - @Column(name = "amount_paid") - private String amountPaid; - - @Column(name = "amount_to_pay") - private String amountToPay; - - @Column(name = "saldo_insoluto") - private String saldoInsoluto; + @Column(name = "id_route") + private String idRoute; - @Column(name = "action_number") - private String actionNumber; - - @Column(name = "num_fee") - private String numFee; - - @Column(name = "address_home") - private String addressHome; - - @Column(name = "address_business") - private String addressBusiness; - - @Column(name = "company_name") - private String companyName; - - - + @Column(name = "last_loan") + @Temporal(javax.persistence.TemporalType.DATE) + private Date lastLoan; - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "id_office", - referencedColumnName = "id", - nullable = false - ) - private Office office; + @Column(name = "amount_paid") + private String amountPaid; - @Column(name = "str_payment_date", length = 22) - private String strPaymentDate; + @Column(name = "amount_to_pay") + private String amountToPay; - public String getId() { - return id; - } + @Column(name = "saldo_insoluto") + private String saldoInsoluto; - public void setId(String id) { - this.id = id; - } + @Column(name = "action_number") + private String actionNumber; - public String getPersonName() { - return personName; - } + @Column(name = "num_fee") + private String numFee; - public void setPersonName(String personName) { - this.personName = personName; - } + @Column(name = "address_home") + private String addressHome; - public String getRouteName() { - return routeName; - } + @Column(name = "address_business") + private String addressBusiness; - public void setRouteName(String routeName) { - this.routeName = routeName; - } + @Column(name = "company_name") + private String companyName; - public Date getLastLoan() { - return lastLoan; - } + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "id_office", + referencedColumnName = "id", + nullable = false + ) + private Office office; - public void setLastLoan(Date lastLoan) { - this.lastLoan = lastLoan; - } + @Column(name = "str_payment_date", length = 22) + private String strPaymentDate; - public Office getOffice() { - return office; - } + public String getId() { + return id; + } - public void setOffice(Office office) { - this.office = office; - } + public void setId(String id) { + this.id = id; + } - public String getStrPaymentDate() { - return strPaymentDate; - } + public String getPersonName() { + return personName; + } - public void setStrPaymentDate(String strPaymentDate) { - this.strPaymentDate = strPaymentDate; - } + public void setPersonName(String personName) { + this.personName = personName; + } - public String getAmountPaid() { - return amountPaid; - } + public String getRouteName() { + return routeName; + } - public void setAmountPaid(String amountPaid) { - this.amountPaid = amountPaid; - } + public void setRouteName(String routeName) { + this.routeName = routeName; + } - public String getAmountToPay() { - return amountToPay; - } + public Date getLastLoan() { + return lastLoan; + } - public void setAmountToPay(String amountToPay) { - this.amountToPay = amountToPay; - } + public void setLastLoan(Date lastLoan) { + this.lastLoan = lastLoan; + } - public String getSaldoInsoluto() { - return saldoInsoluto; - } + public Office getOffice() { + return office; + } - public void setSaldoInsoluto(String saldoInsoluto) { - this.saldoInsoluto = saldoInsoluto; - } + public void setOffice(Office office) { + this.office = office; + } - public String getActionNumber() { - return actionNumber; - } + public String getStrPaymentDate() { + return strPaymentDate; + } - public void setActionNumber(String actionNumber) { - this.actionNumber = actionNumber; - } + public void setStrPaymentDate(String strPaymentDate) { + this.strPaymentDate = strPaymentDate; + } - public String getNumFee() { - return numFee; - } + public String getAmountPaid() { + return amountPaid; + } - public void setNumFee(String numFee) { - this.numFee = numFee; - } + public void setAmountPaid(String amountPaid) { + this.amountPaid = amountPaid; + } - public String getAddressHome() { - return addressHome; - } + public String getAmountToPay() { + return amountToPay; + } - public void setAddressHome(String addressHome) { - this.addressHome = addressHome; - } + public void setAmountToPay(String amountToPay) { + this.amountToPay = amountToPay; + } - public String getAddressBusiness() { - return addressBusiness; - } + public String getSaldoInsoluto() { + return saldoInsoluto; + } - public void setAddressBusiness(String addressBusiness) { - this.addressBusiness = addressBusiness; - } + public void setSaldoInsoluto(String saldoInsoluto) { + this.saldoInsoluto = saldoInsoluto; + } - public String getCompanyName() { - return companyName; - } + public String getActionNumber() { + return actionNumber; + } - public void setCompanyName(String companyName) { - this.companyName = companyName; - } - - + public void setActionNumber(String actionNumber) { + this.actionNumber = actionNumber; + } - @Override - public int hashCode() { - int hash = 7; - hash = 61 * hash + Objects.hashCode(this.id); - return hash; - } + public String getNumFee() { + return numFee; + } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj; - if (!Objects.equals(this.id, other.id)) { - return false; - } - return true; - } + public void setNumFee(String numFee) { + this.numFee = numFee; + } + + public String getAddressHome() { + return addressHome; + } + + public void setAddressHome(String addressHome) { + this.addressHome = addressHome; + } + + public String getAddressBusiness() { + return addressBusiness; + } + + public void setAddressBusiness(String addressBusiness) { + this.addressBusiness = addressBusiness; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getIdRoute() { + return idRoute; + } + + public void setIdRoute(String idRoute) { + this.idRoute = idRoute; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + Objects.hashCode(this.id); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj; + if (!Objects.equals(this.id, other.id)) { + return false; + } + return true; + } } diff --git a/ace-model/src/main/resources/apc.cfg.xml b/ace-model/src/main/resources/apc.cfg.xml index aad54c8..485d6d3 100644 --- a/ace-model/src/main/resources/apc.cfg.xml +++ b/ace-model/src/main/resources/apc.cfg.xml @@ -222,6 +222,7 @@ + diff --git a/ace-model/src/main/resources/com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml b/ace-model/src/main/resources/com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml new file mode 100644 index 0000000..87ddb36 --- /dev/null +++ b/ace-model/src/main/resources/com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/ace-web/pom.xml b/ace-web/pom.xml index 56674d8..8d098f7 100644 --- a/ace-web/pom.xml +++ b/ace-web/pom.xml @@ -140,8 +140,8 @@ Localhost jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5 - apoprocomlocalhost - Yj$2Da0z! + root + root diff --git a/ace-ws-rest/pom.xml b/ace-ws-rest/pom.xml index a09c4b5..d8500a3 100644 --- a/ace-ws-rest/pom.xml +++ b/ace-ws-rest/pom.xml @@ -206,11 +206,11 @@ - Localhost-Mobile-APP + Localhost jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5 - apoprocommobilelocalhost - 0Ps$6%q8 + root + root diff --git a/ace-ws-rest/src/main/java/com/arrebol/apc/ws/customer/CustomerWS.java b/ace-ws-rest/src/main/java/com/arrebol/apc/ws/customer/CustomerWS.java index 027926c..911ced0 100644 --- a/ace-ws-rest/src/main/java/com/arrebol/apc/ws/customer/CustomerWS.java +++ b/ace-ws-rest/src/main/java/com/arrebol/apc/ws/customer/CustomerWS.java @@ -1,20 +1,25 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.ws.customer; import com.arrebol.apc.controller.mobile.controller.customer.CustomerController; +import com.arrebol.apc.model.views.CustomerWithoutRenovationSimpleDTO; +import com.arrebol.apc.model.views.CustomerWithoutRenovationView; import com.arrebol.apc.model.views.LoanByUserView; import java.io.Serializable; import java.util.List; +import java.util.stream.Collectors; import javax.ws.rs.FormParam; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -28,32 +33,59 @@ import org.apache.logging.log4j.Logger; @Path("customer") public class CustomerWS implements Serializable { - private static final long serialVersionUID = -5280895557294295716L; + private static final long serialVersionUID = -5280895557294295716L; - @POST - @Path("list") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) { - logger.debug("findAllLoansByUserId"); + @POST + @Path("list") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) { + logger.debug("findAllLoansByUserId"); - Response response; - try { - GenericEntity> list = new GenericEntity>(controller.findAllLoansByUserId(orderList, userId)) { - }; + Response response; + try { + GenericEntity> list = new GenericEntity>(controller.findAllLoansByUserId(orderList, userId)) { + }; - response = Response.ok(list).build(); - } catch (Exception e) { - logger.error("findAllLoansByUserId", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + response = Response.ok(list).build(); + } catch (Exception e) { + logger.error("findAllLoansByUserId", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - final Logger logger = LogManager.getLogger(CustomerWS.class); - private final CustomerController controller; + @GET + @Path("nonRenewingCustomersByRuteId") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllNonRenewingCustomersByRuteId(@QueryParam("idRoute") String idRoute) { + logger.debug("findAllNonRenewingCustomersByRuteId"); - public CustomerWS() { - this.controller = new CustomerController(); - } + Response response; + try { + List originalList = controller.findAllNonRenewingCustomersByRuteId(idRoute); + + // Convertir a DTOs + List simplifiedList = originalList.stream() + .map(CustomerWithoutRenovationSimpleDTO::new) + .collect(Collectors.toList()); + + GenericEntity> list + = new GenericEntity>(simplifiedList) { + }; + + response = Response.ok(list).build(); + } catch (Exception e) { + logger.error("findAllNonRenewingCustomersByRuteId", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + final Logger logger = LogManager.getLogger(CustomerWS.class); + private final CustomerController controller; + + public CustomerWS() { + this.controller = new CustomerController(); + } } diff --git a/ace-ws-rest/src/test/resources/apc.cfg.xml b/ace-ws-rest/src/test/resources/apc.cfg.xml index 1ee5dd4..5d92ef5 100644 --- a/ace-ws-rest/src/test/resources/apc.cfg.xml +++ b/ace-ws-rest/src/test/resources/apc.cfg.xml @@ -216,6 +216,7 @@ +