/** * Open the ConglomerateController for this index if it isn't open yet. * * @return The ConglomerateController for this index. * @exception StandardException Thrown on duplicate key error */ private ConglomerateController openIndexCC() throws StandardException { if (indexCC == null) { /* DataDictionary doesn't have compiled info */ if (indexSCOCI == null) { indexCC = tc.openConglomerate( indexCID, false, (TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_BASEROW_INSERT_LOCKED), lockMode, isolationLevel); } else { indexCC = tc.openCompiledConglomerate( false, (TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_BASEROW_INSERT_LOCKED), lockMode, isolationLevel, indexSCOCI, indexDCOCI); } } return indexCC; }
/** * This constructor creates an instance of the object. * * @param cctrl the TransactionController. */ public CoinInputBox(TransactionController cctrl) { this.txCtrl = cctrl; MainController mainCtrl = cctrl.getMainController(); StoreController storeCtrl = mainCtrl.getStoreController(); int cashStoreSize = storeCtrl.getStoreSize(Store.CASH); StoreItem[] cashStoreItems = storeCtrl.getStore(Store.CASH).getItems(); btnCoinButton = new CoinButton[cashStoreSize + 1]; CoinInputListener coinInputListener = new CoinInputListener(txCtrl.getCoinReceiver()); setLayout(new GridBagLayout()); for (int i = 0; i < cashStoreItems.length; i++) { StoreItem storeItem = cashStoreItems[i]; CashStoreItem cashStoreItem = (CashStoreItem) storeItem; StoreObject storeObject = cashStoreItem.getContent(); Coin coin = (Coin) storeObject; String coinName = coin.getName(); int coinValue = coin.getValue(); double coinWeight = coin.getWeight(); btnCoinButton[i] = new CoinButton(coinName, coinValue, coinWeight); btnCoinButton[i].addActionListener(coinInputListener); add( btnCoinButton[i], new GridBagConstraints( i, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 10, 8)); } btnCoinButton[cashStoreSize] = new CoinButton("Invalid", -1, CashStore.INVALID_COIN_WEIGHT); btnCoinButton[cashStoreSize].addActionListener(coinInputListener); add( btnCoinButton[cashStoreSize], new GridBagConstraints( cashStoreSize, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 10, 8)); }
public void allowSelection(boolean allow) { if (allow) { Store drinkStore = transactionController.getMainCtrl().getStoreController().getStore(Store.DRINK); StoreItem[] storeItems = drinkStore.getItems(); for (int i = 0; i < storeItems.length; i++) { StoreItem storeItem = storeItems[i]; if (storeItem.getQuantity() == 0) { // transactionController.getCustomerPanel().setDrinkSelectionBoxState(i, false); // transactionController.getCustomerPanel().setDrinkSelectionBoxItemState(i, false); } else { // transactionController.getCustomerPanel().setDrinkSelectionBoxState(i, true); // transactionController.getCustomerPanel().setDrinkSelectionBoxState(i, true); } } } else { transactionController.getCustomerPanel().getDrinkSelectionBox().setActive(allow); } }
public boolean dispenseDrink(int selectedBrand) throws Exception { // transactionController.getMainCtrl().getMachineryController().dispenseDrink(selectedBrand); // StoreItem storeItem = // transactionController.getMainCtrl().getStoreController().getStoreItem(Store.DRINK, // selectedBrand); // transactionController.getCustomerPanel().setCollectCanValue(storeItem.getContent().getName()); // if (drinkDispensed) // updateDrinkSelection(selectedBrand); transactionController.getMainCtrl().getMachineryController().dispenseDrink(selectedBrand); return true; }
public void updateDrinkSelection(int selection) { DrinksStore drinksStore = (DrinksStore) transactionController.getMainCtrl().getStoreController().getStore(Store.DRINK); DrinksStoreItem drinksStoreItem = null; try { drinksStoreItem = (DrinksStoreItem) drinksStore.getStoreItem(selection); } catch (Exception e) { e.printStackTrace(); } DrinksBrand drinksBrand = (DrinksBrand) drinksStoreItem.getContent(); int qty = drinksStoreItem.getQuantity(); int price = drinksBrand.getPrice(); String name = drinksBrand.getName(); // transactionController.getCustomerPanel().updateDrinkInput(selection, qty, price, name) ; }
public void faultIsDetected() { transactionController.setTerminateStrategy(new DispenseFaultTerminator()); transactionController.terminate(); }
/** * Position our index scan to 'ourIndexRow'. * * <p>This creates the scan the first time it is called. * * @exception StandardException Thrown on error */ private void setScan() throws StandardException { /* * -sf- Derby makes an assumption about system tables that isn't true * for Splice land, which results in WriteConflicts occurring * when you try to drop tables * * With indices, Derby only ever creates start and stop keys for the scan. * However, if the entire index is to be scanned, one or more column in the start/stop * key may be null. With db this was apparently treated acceptably, but in Splice * this results in garbage start and stop row keys, which in turn results in deleting * every row in the index instead of deleting just the rows of interest. * * Thus, the following hack. When the row is not entirely filled, we convert * the start/stop key into a single ANDed equals qualifier[], and use that instead */ DataValueDescriptor[] ourRowDvds = ourIndexRow.getRowArray(); int numNonNull = ourRowDvds.length; for (int i = 0; i < ourRowDvds.length; i++) { if (ourRowDvds[i].isNull()) { numNonNull--; } } Qualifier[][] qualifiers = null; if (numNonNull < ourRowDvds.length) { qualifiers = new Qualifier[1][]; qualifiers[0] = new Qualifier[numNonNull]; for (int dvdPos = 0, qualPos = 0; dvdPos < ourRowDvds.length; dvdPos++) { if (ourRowDvds[dvdPos].isNull()) continue; ScanQualifier qualifier = new GenericScanQualifier(); qualifier.setQualifier( dvdPos, ourRowDvds[dvdPos], DataValueDescriptor.ORDER_OP_EQUALS, false, false, false); qualifiers[0][qualPos] = qualifier; } } /* Get the SC from the activation if re-using */ if (!ownIndexSC) { indexSC = activation.getIndexScanController(); } else if (indexSC == null) { RowLocation templateBaseRowLocation = baseCC.newRowLocationTemplate(); /* DataDictionary doesn't have compiled info */ if (indexSCOCI == null) { indexSC = tc.openScan( indexCID, false, /* hold */ TransactionController.OPENMODE_FORUPDATE, /* forUpdate */ lockMode, isolationLevel, (FormatableBitSet) null, /* all fields */ ourIndexRow.getRowArray(), /* startKeyValue */ ScanController.GE, /* startSearchOp */ qualifiers, /* qualifier */ ourIndexRow.getRowArray(), /* stopKeyValue */ ScanController.GT /* stopSearchOp */); } else { indexSC = tc.openCompiledScan( false, /* hold */ TransactionController.OPENMODE_FORUPDATE, /* forUpdate */ lockMode, isolationLevel, (FormatableBitSet) null, /* all fields */ ourIndexRow.getRowArray(), /* startKeyValue */ ScanController.GE, /* startSearchOp */ qualifiers, /* qualifier */ ourIndexRow.getRowArray(), /* stopKeyValue */ ScanController.GT, /* stopSearchOp */ indexSCOCI, indexDCOCI); } } else { indexSC.reopenScan( ourIndexRow.getRowArray(), /* startKeyValue */ ScanController.GE, /* startSearchOperator */ qualifiers, /* qualifier */ ourIndexRow.getRowArray(), /* stopKeyValue */ ScanController.GT /* stopSearchOperator */); } }