Package net.helipilot50.stocktrade.model

Examples of net.helipilot50.stocktrade.model.Holding


        case Constants.RA_TOP:
        case Constants.RA_BOTTOM:
            this.rowAlignment = pAlignment;
            break;
        default:
            UsageException errorVar = new UsageException("Row alignment passed invalid value of " + pAlignment);
            ErrorMgr.addError(errorVar);
            throw errorVar;
        }
    }
View Full Code Here


                if (gbc.row == -1 || gbc.column == -1) {
                    gbc.row = 0;
                    gbc.column = 0;
                }
                else if (gbc.row < 0 || gbc.column < 0) {
                    UsageException errorVar = new UsageException("gridx and gridy should be >= 0, not row = " + gbc.row + ", column = " + gbc.column);
                    ErrorMgr.addError(errorVar);
                    throw errorVar;
                }
                else if (gbc.row >= rows || gbc.column >= columns) {
                  // TF:28/04/2008:if ignoreCollapse is true, we're doing the initial insert. In this case we don't
                  // have the rows and columns necessarily set, so we need to add the components in by expanding the grid
                  if (ignoreCollapse) {
                    // TF:09/05/2008:JIRA JCT-545:Since this is the initial insert, we must obey the
                    // constraints as posted. This means that we'll get the correct row and column
                    // even if a row or column appears empty when this element is inserted (because
                    // another element might be inserted later to make the empty row/column populated)
//                    if (isCollapsed()) {
//                      if (gbc.row >= rows) {
//                        gbc.row = rows;
//                      }
//                      if (gbc.column >= columns) {
//                        gbc.column = columns;
//                      }
//                    }
                    for (int i = rows; i <= gbc.row; i++) {
                      rowWeights.add(i, new Integer(0));
                    }
                    for (int i = columns; i <= gbc.column; i++) {
                      columnWeights.add(i, new Integer(0));
                    }
                    rows = Math.max(rows, gbc.row + 1);
                    columns = Math.max(columns, gbc.column + 1);
                  }
                  else {
                      // Using the replace policy, we never insert a column outside the grid
                    // TF:10/08/2008:JCT-582:If the grid field is empty, we allow the replace
                    if (parent.getComponentCount() == 0) {
                      fallThroughToExpand = true;
                    }
                    else {
                      return false;
                    }
                  }
                }
                if (!fallThroughToExpand) {
                  JComponent comp = parent.getChildInCell(gbc.row + 1, gbc.column + 1);
                  if (comp != null) {
                      parent.remove(comp);
                  }
                  break;
                }
               
        case Constants.IP_EXPAND:
            // If the row or column is -1, we shuffle everything up and across
            if (gbc.row == -1 || gbc.column == -1) {
                gbc.row = 0;
                gbc.column = 0;
                for (Component thisChild : parent.getComponents()) {
                    if (thisChild != newOne) {
                        GridCell effective = findConstraints(thisChild);
                        effective.row++;
                        effective.column++;
                    }
                }
                rows++;
                columns++;
                rowWeights.add(0, new Integer(0));
                columnWeights.add(0, new Integer(0));
            }
            else if (gbc.column < 0 || gbc.row < 0) {
                UsageException errorVar = new UsageException("gridx and gridy should be >= 0, not gridx = " + gbc.column + ", gridy = " + gbc.row);
                ErrorMgr.addError(errorVar);
                throw errorVar;
            }
            else if (gbc.column >= columns || gbc.row >= rows) {
                // If we need to collapse the columns, update the value passed so that it's the
View Full Code Here

              // There's one other possibility -- it just hasn't been injected yet. (eg if
              // the client accesses the database directly)
              result = (DBConnectionManager)ServiceObjectRegistry.getService(dataSourceName, DBConnectionManager.class);
              result.setDataSourceName(dataSourceName);
              if (result == null) {
                  throw new UsageException("Data source " + dataSourceName + " has not been injected into the DBConnectionMgr");
              }
          }
        }
        return result;
    }
View Full Code Here

     * @param pSelHoldCustName Type: TextData
     * @param pSelHoldStockName Type: String
     * @return Holding
     */
    private Holding SQLSelectHolding(TextData pSelHoldCustName, String pSelHoldStockName) {
        Holding aHolding = new Holding();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

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

     * @param pSelHoldCustName Type: TextData
     * @param pSelHoldStockName Type: String
     * @return Holding
     */
    private Holding SQLSelectHolding(TextData pSelHoldCustName, String pSelHoldStockName) {
        Holding aHolding = new Holding();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

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

     */
    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);
                ErrorMgr.addError(badOrder);
                throw badOrder;
            }
View Full Code Here

     * @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

        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);

        Holding holding7 = new Holding();
        holding7.setStockName("Paco Bella");
        holding7.setQuantity(100);
        holding7.setPrice(120f);
        this.customerList.get(2).getHoldingList().add(holding7);

        Holding holding8 = new Holding();
        holding8.setStockName("Coarse Light");
        holding8.setQuantity(100);
        holding8.setPrice(30f);
        this.customerList.get(2).getHoldingList().add(holding8);

        Holding holding9 = new Holding();
        holding9.setStockName("MacDonna");
        holding9.setQuantity(100);
        holding9.setPrice(50f);
        this.customerList.get(2).getHoldingList().add(holding9);
    }
View Full Code Here

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

    return customer;

  }
 
  public static Holding toHoldingDTO(StockTradeBusinessClasses.Holding holding){
    Holding holdingDTO = new Holding(holding.getCustomerName().toString(),
        holding.getStockName(),
        holding.getQuantity(),
        holding.getPrice());
    return holdingDTO;
  }
View Full Code Here

TOP

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

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.