Package org.apache.stonehenge.stocktrader.dal

Examples of org.apache.stonehenge.stocktrader.dal.OrderDAO


        holdingID, null, quantity);
  }

  public CustomOrderBean placeOrder(String orderType, String userID,
      int holdingID, String symbol, double quantity) throws DAOException {
    OrderDAO orderDAO = factory.getOrderDAO();
    CustomOrderBean order = null;
    CustomHoldingBean holding = new CustomHoldingBean();
    try {

      orderDAO.beginTransaction();
      order = createOrder(orderType, userID, holdingID, symbol, quantity,
          holding);

      TradeOrderServiceClient asynClient = TradeOrderServiceClient.getInstance();
      asynClient.SubmitOrderTrasactedQueue(order);
      orderDAO.commitTransaction();
      return order;
    } catch (Exception e) {
      try {
        orderDAO.rollbackTransaction();
      } catch (DAOException e2) {
        throw e2;
      }
      throw new RuntimeException(e);
    }
View Full Code Here


  private CustomOrderBean createOrder(String orderType, String userID,
      int holdingID, String symbol, double quantity,
      CustomHoldingBean holding) throws DAOException {
    CustomOrderBean order = null;
    OrderDAO orderDAO = factory.getOrderDAO();

    if (StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
      // CHECKME holding is the argument
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      order = orderDAO.createOrder(userID, holding.getQuoteID(),
          StockTraderUtility.ORDER_TYPE_SELL, holding.getQuantity(),
          holdingID);

    } else if (StockTraderUtility.ORDER_TYPE_SELL_ENHANCED
        .equals(orderType)) {
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      if (quantity > holding.getQuantity()) {
        order = orderDAO.createOrder(userID, holding.getQuoteID(),
            StockTraderUtility.ORDER_TYPE_SELL, holding
                .getQuantity(), holdingID);
      } else {
        order = orderDAO
            .createOrder(userID, holding.getQuoteID(),
                StockTraderUtility.ORDER_TYPE_SELL, quantity,
                holdingID);
      }
    } else if (StockTraderUtility.ORDER_TYPE_BUY.equals(orderType)) {
      order = orderDAO.createOrder(userID, symbol,
          StockTraderUtility.ORDER_TYPE_BUY, quantity, -1);
    } else {
      throw new IllegalArgumentException("Invalid orderType<" + orderType
          + ">");
    }
View Full Code Here

  }

  public OrderDAO getOrderDAO() throws DAOException {
    logger.debug("MSSQLDAOFactory.getOrderDAO");
    try {
      OrderDAO orderDAO = new MSSQLOrderDAO(getConnection());
      return orderDAO;
    } catch (SQLException e) {
      logger.debug("", e);
      throw new DAOException("Exception was thrown when instantiating MSSQLOrderDAO object", e);
    }
View Full Code Here

  }

  public OrderDAO getOrderDAO() throws DAOException {
    logger.debug("MySQLDAOFactory.getOrderDAO");
    try {
      OrderDAO orderDAO = new MySQLOrderDAO(getConnection());
      return orderDAO;
    } catch (SQLException e) {
      logger.debug("", e);
      throw new DAOException("Exception was thrown when instantiating MySQLOrderDAO object",e);
    }
View Full Code Here

  }

  public OrderDAO getOrderDAO() throws DAOException {
    logger.debug("MySQLDAOFactory.getOrderDAO");
    try {
      OrderDAO orderDAO = new MySQLOrderDAO(getConnection());
      return orderDAO;
    } catch (SQLException e) {
      logger.debug("", e);
      throw new DAOException("Exception was thrown when instantiating MySQLOrderDAO object",e);
    }
View Full Code Here

      int holdingID, String symbol, double quantity) throws DAOException {
   
     
    System.setProperty("java.net.debug", "ssl,handshake")
     
    OrderDAO orderDAO = factory.getOrderDAO();
    CustomOrderBean order = null;
    CustomHoldingBean holding = new CustomHoldingBean();
    try {

      orderDAO.beginTransaction();
      order = createOrder(orderType, userID, holdingID, symbol, quantity,
          holding);

            TradeOrderServiceClient asynClient = TradeOrderServiceClient.getInstance();
      asynClient.SubmitOrder(order);
      orderDAO.commitTransaction();
      return order;
    } catch (Exception e) {
      try {
        orderDAO.rollbackTransaction();
      } catch (DAOException e2) {
        throw e2;
      }
            logger.error(e);
      throw new RuntimeException(e);
View Full Code Here

  private CustomOrderBean createOrder(String orderType, String userID,
      int holdingID, String symbol, double quantity,
      CustomHoldingBean holding) throws DAOException {
    CustomOrderBean order = null;
    OrderDAO orderDAO = factory.getOrderDAO();

    if (StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
      // CHECKME holding is the argument
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      order = orderDAO.createOrder(userID, holding.getQuoteID(),
          StockTraderUtility.ORDER_TYPE_SELL, holding.getQuantity(),
          holdingID);

    } else if (StockTraderUtility.ORDER_TYPE_SELL_ENHANCED
        .equals(orderType)) {
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      if (quantity > holding.getQuantity()) {
        order = orderDAO.createOrder(userID, holding.getQuoteID(),
            StockTraderUtility.ORDER_TYPE_SELL, holding
                .getQuantity(), holdingID);
      } else {
        order = orderDAO
            .createOrder(userID, holding.getQuoteID(),
                StockTraderUtility.ORDER_TYPE_SELL, quantity,
                holdingID);
      }
    } else if (StockTraderUtility.ORDER_TYPE_BUY.equals(orderType)) {
      order = orderDAO.createOrder(userID, symbol,
          StockTraderUtility.ORDER_TYPE_BUY, quantity, -1);
    } else {
      throw new IllegalArgumentException("Invalid orderType<" + orderType
          + ">");
    }
View Full Code Here

        holdingID, null, quantity);
  }

  public CustomOrderBean placeOrder(String orderType, String userID,
      int holdingID, String symbol, double quantity) throws DAOException {
    OrderDAO orderDAO = factory.getOrderDAO();
    CustomOrderBean order = null;
    CustomHoldingBean holding = new CustomHoldingBean();
    try {

      orderDAO.beginTransaction();
      order = createOrder(orderType, userID, holdingID, symbol, quantity,
          holding);

      TradeOrderServiceClient asynClient = TradeOrderServiceClient.getInstance();
      asynClient.SubmitOrderTrasactedQueue(order);
      orderDAO.commitTransaction();
      return order;
    } catch (Exception e) {
      try {
        orderDAO.rollbackTransaction();
      } catch (DAOException e2) {
        throw e2;
      }
      throw new RuntimeException(e);
    }
View Full Code Here

  private CustomOrderBean createOrder(String orderType, String userID,
      int holdingID, String symbol, double quantity,
      CustomHoldingBean holding) throws DAOException {
    CustomOrderBean order = null;
    OrderDAO orderDAO = factory.getOrderDAO();

    if (StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
      // CHECKME holding is the argument
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      order = orderDAO.createOrder(userID, holding.getQuoteID(),
          StockTraderUtility.ORDER_TYPE_SELL, holding.getQuantity(),
          holdingID);

    } else if (StockTraderUtility.ORDER_TYPE_SELL_ENHANCED
        .equals(orderType)) {
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      if (quantity > holding.getQuantity()) {
        order = orderDAO.createOrder(userID, holding.getQuoteID(),
            StockTraderUtility.ORDER_TYPE_SELL, holding
                .getQuantity(), holdingID);
      } else {
        order = orderDAO
            .createOrder(userID, holding.getQuoteID(),
                StockTraderUtility.ORDER_TYPE_SELL, quantity,
                holdingID);
      }
    } else if (StockTraderUtility.ORDER_TYPE_BUY.equals(orderType)) {
      order = orderDAO.createOrder(userID, symbol,
          StockTraderUtility.ORDER_TYPE_BUY, quantity, -1);
    } else {
      throw new IllegalArgumentException("Invalid orderType<" + orderType
          + ">");
    }
View Full Code Here

TOP

Related Classes of org.apache.stonehenge.stocktrader.dal.OrderDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.