Package org.apache.stonehenge.stocktrader

Examples of org.apache.stonehenge.stocktrader.CustomHoldingBean


          + order.getOrderStatus() + "\nOrder Open Date :"
          + order.getOpenDate() + "\nCompletionDate :"
          + order.getCompletionDate());
    }

    CustomHoldingBean holding = orderDAO.getHoldingForUpdate(order.getOrderID());

    if (holding == null) {
      // TODO : DAOException ..
      throw new RuntimeException("Unable to locate a holding entry for orderID :" + order.getOrderID());
    }
    order.setAccountId(holding.getAccountID());

    // There are three distinct business cases here, each needs different
    // treatment:
    // a) Quantity requested is less than total shares in the holding --
    // update holding.
    // b) Quantity requested is equal to total shares in the holding --
    // delete holding.
    // c) Quantity requested is greater than total shares in the holding --
    // delete holding, update order table.

    if (order.getQuantity() < holding.getQuantity()) {
      orderDAO.updateHolding(holding.getHoldingID(), order.getQuantity());

    } else if (holding.getQuantity() == order.getQuantity()) {
      orderDAO.deleteHolding(holding.getHoldingID());

    } else if (order.getQuantity() > holding.getQuantity()) {
      // We now need to back-update the order record quantity to reflect
      // fact not all shares originally requested were sold since the
      // holding had less shares in it, perhaps due to other orders placed
      // against that holding that completed before this one. So we will
      // sell the remaining shares, but need to update the final order to
      // reflect this.
      orderDAO.deleteHolding(holding.getHoldingID());
      order.setQuantity(holding.getQuantity());
      order.setAccountId(holding.getAccountID());
      orderDAO.updateOrder(order);
    }
    return holding.getHoldingID();
  }
View Full Code Here


      logger
          .debug("MSSQLCustomerDAO.getHoldingForUpdate(int)\nOrder ID :"
              + orderId);
    }

    CustomHoldingBean holding = null;
    PreparedStatement selectHoldingLockStat = null;
    try {
      selectHoldingLockStat = sqlConnection
          .prepareStatement(SQL_SELECT_HOLDING_LOCK);
      selectHoldingLockStat.setInt(1, orderId);
      ResultSet rs = selectHoldingLockStat.executeQuery();
      if (rs.next()) {
        try {
          holding = new CustomHoldingBean(
              rs.getInt(1),
              rs.getInt(2),
              rs.getDouble(3),
              rs.getBigDecimal(4),
              StockTraderUtility.convertToCalendar(rs.getDate(5)),
View Full Code Here

      throws DAOException {
    if (logger.isDebugEnabled()) {
      logger.debug("MSSQLCustomerDAO.getHolding(String,int)\nUserID :"
          + userId + "\nOrder ID :" + holdingID);
    }
    CustomHoldingBean holding = null;
    PreparedStatement selectHoldingNoLockStat = null;
    try {
      selectHoldingNoLockStat = sqlConnection
          .prepareStatement(SQL_SELECT_HOLDING_NOLOCK);
            // FIXED: index starts from 1 rather than 0
      selectHoldingNoLockStat.setInt(1, holdingID);
      selectHoldingNoLockStat.setString(2, userId);

      ResultSet rs = selectHoldingNoLockStat.executeQuery();
      if (rs.next()) {
        try {
          holding = new CustomHoldingBean(
              rs.getInt(1),
              rs.getInt(2),
              rs.getDouble(3),
              rs.getBigDecimal(4),
              StockTraderUtility.convertToCalendar(rs.getDate(5)),
View Full Code Here

      selectHoldings.setString(1, userID);
      ResultSet rs = selectHoldings.executeQuery();
      List<CustomHoldingBean> holdings = new ArrayList<CustomHoldingBean>();
      try {
        while (rs.next()) {
          CustomHoldingBean holding = new CustomHoldingBean(
              rs.getInt(1),
              rs.getDouble(2),
              rs.getBigDecimal(3),
              StockTraderUtility.convertToCalendar(rs.getDate(4)),
              rs.getString(5), rs.getInt(6));
View Full Code Here

    CustomerDAO customerDAO = fac.getCustomerDAO();
    return customerDAO.getHoldingForUpdate(orderId);
  }

  public CustomHoldingBean getHolding(int holdingId) throws DAOException {
    CustomHoldingBean holding = null;
    PreparedStatement selectHoldingStat = null;
    try {
      selectHoldingStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING);
      selectHoldingStat.setInt(1, holdingId);
      ResultSet rs = selectHoldingStat.executeQuery();
      if (rs.next()) {
        try {
          holding = new CustomHoldingBean(
              rs.getInt(1),
              rs.getDouble(2),
              rs.getBigDecimal(3),
              StockTraderUtility.convertToCalendar(rs.getDate(4)),
              rs.getString(5),
View Full Code Here

    CustomerDAO customerDAO = fac.getCustomerDAO();
    return customerDAO.getHoldingForUpdate(orderId);
  }

  public CustomHoldingBean getHolding(int holdingId) throws DAOException {
    CustomHoldingBean holding = null;
    PreparedStatement selectHoldingStat = null;
    try {
      selectHoldingStat = sqlConnection
          .prepareStatement(SQL_SELECT_HOLDING);
      selectHoldingStat.setInt(1, holdingId);
      ResultSet rs = selectHoldingStat.executeQuery();
      if (rs.next()) {
        try {
          holding = new CustomHoldingBean(
              rs.getInt(1),
              rs.getDouble(2),
              rs.getBigDecimal(3),
              StockTraderUtility.convertToCalendar(rs.getDate(4)),
              rs.getString(5),
View Full Code Here

          + order.getOrderStatus() + "\nOrder Open Date :"
          + order.getOpenDate() + "\nCompletionDate :"
          + order.getCompletionDate());
    }

    CustomHoldingBean holding = orderDAO.getHoldingForUpdate(order.getOrderID());

    if (holding == null) {
      // TODO : DAOException ..
      throw new RuntimeException(
          "Unable to locate a holding entry for orderID :"
              + order.getOrderID());
    }
    order.setAccountId(holding.getAccountID());

    // There are three distinct business cases here, each needs different
    // treatment:
    // a) Quantity requested is less than total shares in the holding --
    // update holding.
    // b) Quantity requested is equal to total shares in the holding --
    // delete holding.
    // c) Quantity requested is greater than total shares in the holding --
    // delete holding, update order table.

    if (order.getQuantity() < holding.getQuantity()) {
      orderDAO.updateHolding(holding.getHoldingID(), order.getQuantity());

    } else if (holding.getQuantity() == order.getQuantity()) {
      orderDAO.deleteHolding(holding.getHoldingID());

    } else if (order.getQuantity() > holding.getQuantity()) {
      // We now need to back-update the order record quantity to reflect
      // fact not all shares originally requested were sold since the
      // holding had less shares in it, perhaps due to other orders placed
      // against that holding that completed before this one. So we will
      // sell the remaining shares, but need to update the final order to
      // reflect this.
      orderDAO.deleteHolding(holding.getHoldingID());
      order.setQuantity(holding.getQuantity());
      order.setAccountId(holding.getAccountID());
      orderDAO.updateOrder(order);
    }
    return holding.getHoldingID();
  }
View Full Code Here

     
    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);
View Full Code Here

    public CustomHoldingBean getHoldingForUpdate(int orderId) throws DAOException {
        if (logger.isDebugEnabled()) {
            logger.debug("MySQLCustomerDAO.getHoldingForUpdate(int)\nOrder ID :" + orderId);
        }

        CustomHoldingBean holding = null;
        PreparedStatement selectHoldingLockStat = null;
        try {
            selectHoldingLockStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING_LOCK);
            selectHoldingLockStat.setInt(1, orderId);
            ResultSet rs = selectHoldingLockStat.executeQuery();
            if (rs.next()) {
                try {
                    holding = new CustomHoldingBean(
                            rs.getInt(1),
                            rs.getInt(2),
                            rs.getDouble(3),
                            rs.getBigDecimal(4),
                            StockTraderUtility.convertToCalendar(rs.getDate(5)),
View Full Code Here

    public CustomHoldingBean getHolding(String userId, int holdingID) throws DAOException {
        if (logger.isDebugEnabled()) {
            logger.debug("MSSQLCustomerDAO.getHolding(String,int)\nUserID :" + userId + "\nOrder ID :" + holdingID);
        }
        CustomHoldingBean holding = null;
        PreparedStatement selectHoldingNoLockStat = null;
        try {
            selectHoldingNoLockStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING_NOLOCK);
            selectHoldingNoLockStat.setInt(1, holdingID);
            selectHoldingNoLockStat.setString(2, userId);

            ResultSet rs = selectHoldingNoLockStat.executeQuery();
            if (rs.next()) {
                try {
                    holding = new CustomHoldingBean(
                            rs.getInt(1),
                            holdingID,
                            rs.getDouble(2),
                            rs.getBigDecimal(3),
                            StockTraderUtility.convertToCalendar(rs.getDate(4)),
View Full Code Here

TOP

Related Classes of org.apache.stonehenge.stocktrader.CustomHoldingBean

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.