com.fenalco.servlets.shopkeeper
Class QuotePurchaser

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.fenalco.servlets.shopkeeper.QuotePurchaser
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class QuotePurchaser
extends javax.servlet.http.HttpServlet

Este servlet es el encargado de construir la orden de compra sobre la cotización seleccionada por el minorista.

Author:
Mario Linares Vásquez
See Also:
Serialized Form

Constructor Summary
QuotePurchaser()
           
 
Method Summary
 void destroy()
          Destructor de servlet.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Procesa el método HTTP GET.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Procesa el método HTTP POST.
 java.lang.String getServletInfo()
          Retorna una breve descripción de el servlet.
 void init(javax.servlet.ServletConfig config)
          Inicializa el servlet.
protected  void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Procesa las solictudes de los métodos HTTP GET y POST.
 boolean submitOrder(int quoteId, int storeId, int communityId, User user)
          Este método construye la orden de compra a partir de la cotización seleccionada.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuotePurchaser

public QuotePurchaser()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Inicializa el servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config -
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Destructor de servlet.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

processRequest

protected void processRequest(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              java.io.IOException
Procesa las solictudes de los métodos HTTP GET y POST. Este método invoca la función miembro submitOrder con los parámetros id del request y store de la sesiòn del request y redirecciona el flujo a el servlet miscotizaciones

Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Procesa el método HTTP GET.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Procesa el método HTTP POST.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

getServletInfo

public java.lang.String getServletInfo()
Retorna una breve descripción de el servlet.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:

submitOrder

public boolean submitOrder(int quoteId,
                           int storeId,
                           int communityId,
                           User user)
Este método construye la orden de compra a partir de la cotización seleccionada. Para tal efecto crea una instancia de la clase Quote con el parámetro quoteId; luego crea una instancia de Order con el constructor vacío , fija los atributos de esta con los métodos modificadores e invoca el método saveData con el respectivo Transaction y por último el método submit. Luego de creada la orden se debe eliminar la cotización con el método delete.

Parameters:
quoteId - id de la cotización
storeId - id del establecimiento destino
user - usuario que solicita la compra de la cotización
Returns:
boolean que representa el exito del proceso