Package net.helipilot50.stocktrade.model

Examples of net.helipilot50.stocktrade.model.Customer


     * <p>
     * @param pName Type: TextData
     * @return Customer
     */
    private Customer SQLSelectCustomer(TextData pName) {
        Customer aCustomer = new Customer();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
View Full Code Here


     * @param pPrice Type: float
     */
    public void decrementHolding(TextData pCustomerName, String pStockName, int pQuantity, float pPrice) {
        // TODO [129,Info]: Copy of parameter pCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
        try {
            Customer oneCustomer = null;
            Holding custHolding = null;
            float incomeFromStock = pQuantity*pPrice;
   
            oneCustomer = this.getCustomer(pCustomerName);
            //custHolding = self.GetHolding(pCustomer=oneCustomer,
            //        pGetHoldStockName=pStockName);
            custHolding = this.SQLSelectHolding(pCustomerName, pStockName);
   
            if (custHolding.getQuantity() > pQuantity) {
                custHolding.setQuantity(custHolding.getQuantity()-pQuantity);
                oneCustomer.setCashBalance(oneCustomer.getCashBalance()+incomeFromStock);
                this.SQLUpdateHolding(custHolding);
                this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
   
            }
            else if (custHolding.getQuantity() == pQuantity) {
                this.SQLDeleteHolding(custHolding);
   
                //oneCustomer.HoldingList.DeleteRow(object=custHolding);
                oneCustomer.setCashBalance(oneCustomer.getCashBalance()+incomeFromStock);
                this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
   
            }
            else if (custHolding.getQuantity() < pQuantity) {
                InvalidTradeException badOrder = new InvalidTradeException();
                badOrder.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not own enough stock to place SELL Order", pCustomerName);
View Full Code Here

     * @param pGetCustCustomerName Type: TextData
     * @return Customer
     */
    public Customer getCustomer(TextData pGetCustCustomerName) {
        // TODO [129,Info]: Copy of parameter pGetCustCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
        Customer aCustomer = this.SQLSelectCustomer(pGetCustCustomerName);
        aCustomer.setHoldingList(this.SQLSelectHoldingList(pGetCustCustomerName));

        return aCustomer;
    }
View Full Code Here

     * @param pQuantity Type: int
     * @param pPrice Type: float
     */
    public void incrementHolding(TextData pCustomerName, String pStockName, int pQuantity, float pPrice) {
        // TODO [129,Info]: Copy of parameter pCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
        Customer oneCustomer = null;
        Holding custHolding = null;

        float costOfStock = pQuantity*pPrice;

        oneCustomer = this.getCustomer(pCustomerName);

        if (oneCustomer.getCashBalance() > costOfStock) {
            try {
                oneCustomer.setCashBalance(oneCustomer.getCashBalance()-costOfStock);
                //    custHolding = self.GetHolding(pCustomer=oneCustomer,pGetHoldStockName=pStockName);
                custHolding = this.SQLSelectHolding(pCustomerName, pStockName);
                custHolding.setQuantity(custHolding.getQuantity()+pQuantity);
                this.SQLUpdateHolding(custHolding);
                this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());

            }
            catch (NoSuchHoldingException noHolding) {
                    Holding newHolding = new Holding();
                    newHolding.setCustomerName(pCustomerName);
                    newHolding.setPrice(pPrice);
                    newHolding.setQuantity(pQuantity);
                    newHolding.setStockName(pStockName);
                    this.SQLInsertHolding(newHolding);
                    this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());


                    //        oneCustomer.HoldingList.AppendRow(object=newHolding);
            }
        }
View Full Code Here

     * setUp<p>
     * Code to populate CustomerList array<br>
     * <p>
     */
    private void setUp() {
        this.customerList.set(0, new Customer());
        this.customerList.get(0).getCustomerName().setValue( "Chris" );
        this.customerList.get(0).setAddress("123 4th Ave.\n San Francisco\nCA 94403");
        this.customerList.get(0).setPhoneNumber("5104268845");
        this.customerList.get(0).setCashBalance(45000f);

        Holding holding1 = new Holding();
        holding1.setStockName("Happy Duck");
        holding1.setQuantity(100);
        holding1.setPrice(120f);
        this.customerList.get(0).getHoldingList().add(holding1);

        Holding holding2 = new Holding();
        holding2.setStockName("Coarse Light");
        holding2.setQuantity(240);
        holding2.setPrice(50f);
        this.customerList.get(0).getHoldingList().add(holding2);


        Holding holding3 = new Holding();
        holding3.setStockName("Boston Quicken");
        holding3.setQuantity(50);
        holding3.setPrice(50f);
        this.customerList.get(0).getHoldingList().add(holding3);

        this.customerList.set(1, new Customer());
        this.customerList.get(1).getCustomerName().setValue( "Natasha" );
        this.customerList.get(1).setAddress("222 44th Ave.\nSan Diego\nCA 90210");
        this.customerList.get(1).setPhoneNumber("3335551234");
        this.customerList.get(1).setCashBalance(8000f);

        Holding holding4 = new Holding();
        holding4.setStockName("Boston Quicken");
        holding4.setQuantity(10);
        holding4.setPrice(120f);
        this.customerList.get(1).getHoldingList().add(holding4);

        Holding holding5 = new Holding();
        holding5.setStockName("Giorgio Osmondi");
        holding5.setQuantity(200);
        holding5.setPrice(30f);
        this.customerList.get(1).getHoldingList().add(holding5);

        Holding holding6 = new Holding();
        holding6.setStockName("MacDonna");
        holding6.setQuantity(100);
        holding6.setPrice(50f);
        this.customerList.get(1).getHoldingList().add(holding6);

        this.customerList.set(2, new Customer());
        this.customerList.get(2).getCustomerName().setValue( "Bill" );
        this.customerList.get(2).setAddress("2555 Alma St. #3\nPalo Alto\nCA 90011");
        this.customerList.get(2).setPhoneNumber("4155556666");
        this.customerList.get(2).setCashBalance(10000f);

View Full Code Here

     * <p>
     * @param pName Type: TextData
     * @return Customer
     */
    private Customer SQLSelectCustomer(TextData pName) {
        Customer aCustomer = new Customer();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
View Full Code Here

    ClResult result = DBClient.getInstance().getAll(DBClient.NAME_SPACE, "Customer", pCustomerName, null);
    if (result.resultCode != ClResultCode.OK){
      throw new NoSuchCustomerException("cannot find customer " + pCustomerName);
    }
   
    Customer customer = new Customer();
    customer.setCustomerName((String) result.results.get("CustomerName"));
    customer.setAddress((String) result.results.get("Address"));
    customer.setCashBalance(Float.parseFloat((String) result.results.get("CashBalance")));
    customer.setPhoneNumber((String) result.results.get("PhoneNumber"));

    final List<Holding> holdings = new ArrayList<Holding>();
    DBClient.getInstance().scanAllNodes(DBClient.NAME_SPACE, pCustomerName + "Holding", new ScanCallback() {
     
      @Override
      public void scanCallback(String namespace, String set, byte[] digest,
          Map<String, Object> bins, int generation, int expirationDate,
          Object userData) {
        Holding holding = new Holding();
        holding.set("customerName", bins.get("CustomerName"));
        holding.set("stockName", bins.get("StockName"));
        holding.set("quantity", bins.get("Quantity"));
        holding.set("price", bins.get("Price"));
        holdings.add(holding);
       
      }
    }, null);
    customer.setHoldingList(holdings);
    return customer;
  }
View Full Code Here

    // ------------
    public CustomerWindow() {
        // Explicitly call the superclass constructor to prevent the implicit call
        super();
        this.initialize();
        this.setCustomerGrid(new Customer());
        //self.CustomerName = new;
        //self.HoldingList = new;

        //  Import code for Init Method for CustomerWindow class
        //  Populate HoldingList Array widget
View Full Code Here

        }
        return bindingManager;
    }

    public void setCustomerGrid(Customer customerGrid) {
        Customer oldValue = this.customerGrid;
        this.customerGrid = customerGrid;
        this.firePropertyChange("customerGrid", oldValue, this.customerGrid);
    }
View Full Code Here

    StockTradeBusinessClasses.Customer customer = customerSO.getCustomer(new TextData(name));
    return toCustomerDTO(customer);
  }
 
  public static Customer toCustomerDTO(StockTradeBusinessClasses.Customer customer) {
    Customer customerDTO = new Customer(customer.getCustomerName().toString(),
        customer.getAddress(),
        customer.getPhoneNumber(),
        customer.getCashBalance());
    List<Holding> holdings = new ArrayList<Holding>();
    for (StockTradeBusinessClasses.Holding holding : customer.getHoldingList()){
      holdings.add(toHoldingDTO(holding));
    }
    customerDTO.setHoldingList(holdings);
    return customerDTO;
  }
View Full Code Here

TOP

Related Classes of net.helipilot50.stocktrade.model.Customer

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.