Examples of HoldingDataBeanImpl


Examples of org.apache.aries.samples.ariestrader.beans.HoldingDataBeanImpl

    private HoldingDataBean getHoldingDataFromResultSet(ResultSet rs) throws Exception {
        HoldingDataBean holdingData = null;

        holdingData =
            new HoldingDataBeanImpl(new Integer(rs.getInt("holdingID")), rs.getDouble("quantity"), rs
                .getBigDecimal("purchasePrice"), rs.getTimestamp("purchaseDate"), rs.getString("quote_symbol"));
        return holdingData;
    }
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
            AccountDataBean account = profile.getAccount();

            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);

            HoldingDataBeanImpl holding = null; // The holding will be created by this buy order

            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding, "buy", quantity);

            // order = createOrder(account, quote, holding, "buy", quantity);
            // UPDATE - account should be credited during completeOrder
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

                Log.trace("TradeJpaCm:sell", userID, holdingID, orderProcessingMode);

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);

            AccountDataBean account = profile.getAccount();
            HoldingDataBeanImpl holding = entityManager.find(HoldingDataBeanImpl.class, holdingID);

            if (holding == null) {
                Log.error("TradeJpaCm:sell User " + userID
                          + " attempted to sell holding " + holdingID
                          + " which has already been sold");

                OrderDataBean orderData = new OrderDataBeanImpl();
                orderData.setOrderStatus("cancelled");

                entityManager.persist(orderData);

                return orderData;
            }

            QuoteDataBean quote = holding.getQuote();
            double quantity = holding.getQuantity();

            order = createOrder(account, quote, holding, "sell", quantity);
            // UPDATE the holding purchase data to signify this holding is
            // "inflight" to be sold
            // -- could add a new holdingStatus attribute to holdingEJB
            holding.setPurchaseDate(new java.sql.Timestamp(0));

            // UPDATE - account should be credited during completeOrder
            BigDecimal price = quote.getPrice();
            BigDecimal orderFee = order.getOrderFee();
            BigDecimal balance = account.getBalance();
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

    private HoldingDataBean createHolding(AccountDataBean account,
                                          QuoteDataBean quote,
                                          double quantity,
                                          BigDecimal purchasePrice) throws Exception {
        HoldingDataBeanImpl newHolding = new HoldingDataBeanImpl(quantity,
                                                         purchasePrice, new Timestamp(System.currentTimeMillis()),
                                                         account, quote);
        entityManager.persist(newHolding);
        return newHolding;
    }
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
            AccountDataBean account = profile.getAccount();

            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);

            HoldingDataBeanImpl holding = null; // The holding will be created by this buy order

            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding, "buy", quantity, entityManager);

            // order = createOrder(account, quote, holding, "buy", quantity);
            // UPDATE - account should be credited during completeOrder
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

                Log.trace("TradeJpaAm:sell", userID, holdingID, orderProcessingMode);

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);

            AccountDataBean account = profile.getAccount();
            HoldingDataBeanImpl holding = entityManager.find(HoldingDataBeanImpl.class, holdingID);

            if (holding == null) {
                Log.error("TradeJpaAm:sell User " + userID
                          + " attempted to sell holding " + holdingID
                          + " which has already been sold");

                OrderDataBean orderData = new OrderDataBeanImpl();
                orderData.setOrderStatus("cancelled");

                entityManager.persist(orderData);

                entityManager.getTransaction().commit();

                if (entityManager != null) {
                    entityManager.close();
                    entityManager = null;

                }

                return orderData;
            }

            QuoteDataBean quote = holding.getQuote();
            double quantity = holding.getQuantity();

            order = createOrder(account, quote, holding, "sell", quantity,
                                entityManager);
            // UPDATE the holding purchase data to signify this holding is
            // "inflight" to be sold
            // -- could add a new holdingStatus attribute to holdingEJB
            holding.setPurchaseDate(new java.sql.Timestamp(0));

            // UPDATE - account should be credited during completeOrder
            BigDecimal price = quote.getPrice();
            BigDecimal orderFee = order.getOrderFee();
            BigDecimal balance = account.getBalance();
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl

    }

    private HoldingDataBean createHolding(AccountDataBean account,
                                          QuoteDataBean quote, double quantity, BigDecimal purchasePrice,
                                          EntityManager entityManager) throws Exception {
        HoldingDataBeanImpl newHolding = new HoldingDataBeanImpl(quantity,
                                                         purchasePrice, new Timestamp(System.currentTimeMillis()),
                                                         account, quote);
        try {
            /*
             * manage transactions
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.