use of BasicCommonClasses.Location in project SmartCity-Market by TechnionYP5777.
the class ManagePackagesTab method smartcodeEntered.
private void smartcodeEntered(SmartCode c) throws SMException {
log.info("===============================smartcodeEntered======================================");
getProductCatalog(barcodeTextField.getText());
int amountInStore = worker.getProductPackageAmount(new ProductPackage(c, 1, new Location(0, 0, PlaceInMarket.STORE))), amountInWarehouse = worker.getProductPackageAmount(new ProductPackage(c, 1, new Location(0, 0, PlaceInMarket.WAREHOUSE)));
this.amountInStore = amountInStore;
this.amountInWarehouse = amountInWarehouse;
showScanCodePane(false);
showSmartCodeOperationsPane(true);
addProductParametersToQuickView(catalogProduct.getName(), barcodeTextField.getText(), c.getExpirationDate() + "", Integer.toString(amountInStore), Integer.toString(amountInWarehouse));
log.info("amount in store: " + amountInStore);
log.info("amount in werehouse: " + amountInWarehouse);
log.info("===============================smartcodeEntered======================================");
}
use of BasicCommonClasses.Location in project SmartCity-Market by TechnionYP5777.
the class ManagePackagesTab method runTheOperationButtonPressed.
@FXML
private void runTheOperationButtonPressed(ActionEvent __) {
SmartCode smartcode = new SmartCode(Long.parseLong(barcodeTextField.getText()), datePicker.getValue());
int amountVal = editPackagesAmountSpinner.getValue();
log.info("===============================runTheOperationButtonPressed======================================");
log.info("amount in spinner: " + amountVal);
try {
if (barcodeOperationsPane.isVisible()) {
log.info("barcode pane is visible");
if (addPakageToWarhouseRadioButton.isSelected()) {
log.info("addPakageToWarhouseRadioButton");
// init
Location loc = new Location(0, 0, PlaceInMarket.WAREHOUSE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
// exec
worker.addProductToWarehouse(pp);
printToSuccessLog("Added (" + amountVal + ") " + "product packages (" + pp + ") to warehouse");
this.expirationDate = datePicker.getValue();
searchCodeButtonPressed(null);
}
} else if (addPackageToStoreRadioButton.isSelected()) {
log.info("addPackageToStoreRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.STORE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.placeProductPackageOnShelves(pp);
printToSuccessLog("Added (" + amountVal + ") " + "product packages (" + pp + ") to store");
searchCodeButtonPressed(null);
} else if (removePackageFromStoreRadioButton.isSelected()) {
log.info("removePackageFromStoreRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.STORE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.removeProductPackageFromStore(pp);
printToSuccessLog("Removed (" + amountVal + ") " + "product packages (" + pp + ") from store");
searchCodeButtonPressed(null);
} else if (!removePackageFromWarhouseRadioButton.isSelected()) {
if (printSmartCodeRadioButton.isSelected())
new SmartcodePrint(smartcode, amountVal).print();
} else {
log.info("removePackageFromWarhouseRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.WAREHOUSE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.removeProductPackageFromStore(pp);
printToSuccessLog("Removed (" + amountVal + ") " + "product packages (" + pp + ") from warehouse");
searchCodeButtonPressed(null);
}
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
log.info("===============================runTheOperationButtonPressed======================================");
}
use of BasicCommonClasses.Location in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testAddRemoveProductRealBarcodeFromCatalog.
@Test
public void testAddRemoveProductRealBarcodeFromCatalog() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
HashSet<Ingredient> ingredients = new HashSet<Ingredient>();
HashSet<Location> locations = new HashSet<Location>();
CatalogProduct newProduct = new CatalogProduct(7290010328246L, "thini", ingredients, new Manufacturer(1, "תנובה"), "", 20, "", locations);
try {
sqlConnection.addProductToCatalog(null, newProduct);
assertEquals(sqlConnection.getProductFromCatalog(null, newProduct.getBarcode()), new Gson().toJson(newProduct));
sqlConnection.removeProductFromCatalog(null, new SmartCode(newProduct.getBarcode(), null));
} catch (SQLDatabaseException e) {
fail();
}
try {
sqlConnection.getProductFromCatalog(null, newProduct.getBarcode());
fail();
} catch (ProductNotExistInCatalog e) {
} catch (CriticalError | ClientNotConnected e) {
fail();
}
}
use of BasicCommonClasses.Location in project SmartCity-Market by TechnionYP5777.
the class RemoveProductPackageFromStoreTest method removeProductPackageFromStoreProductPackageAmountNotMatchTest.
@Test
public void removeProductPackageFromStoreProductPackageAmountNotMatchTest() {
int senderID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_PRODUCT_PACKAGE_FROM_STORE, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
if (productPackage.getLocation().equals(PlaceInMarket.STORE))
Mockito.doThrow(new ProductPackageAmountNotMatch()).when(sqlDatabaseConnection).removeProductPackageFromShelves(senderID, productPackage);
else
Mockito.doThrow(new ProductPackageAmountNotMatch()).when(sqlDatabaseConnection).removeProductPackageFromWarehouse(senderID, productPackage);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageNotExist e) {
fail();
} catch (ProductPackageAmountNotMatch __) {
/* Success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_PRODUCT_PACKAGE_AMOUNT_BIGGER_THEN_AVAILABLE, out.getResultDescriptor());
}
use of BasicCommonClasses.Location in project SmartCity-Market by TechnionYP5777.
the class RemoveProductPackageFromStoreTest method placeProductPackageOnShelvesIllegalCatalogProductTest.
@Test
public void placeProductPackageOnShelvesIllegalCatalogProductTest() {
assertEquals(ResultDescriptor.SM_ERR, (new CommandExecuter(new CommandWrapper(1, CommandDescriptor.REMOVE_PRODUCT_PACKAGE_FROM_STORE, new Gson().toJson("", String.class)).serialize())).execute(sqlDatabaseConnection).getResultDescriptor());
assertEquals(ResultDescriptor.SM_INVALID_PARAMETER, (new CommandExecuter(new CommandWrapper(1, CommandDescriptor.REMOVE_PRODUCT_PACKAGE_FROM_STORE, new Gson().toJson(new ProductPackage(new SmartCode(1, null), -1, new Location(0, 0, PlaceInMarket.WAREHOUSE)), ProductPackage.class)).serialize())).execute(sqlDatabaseConnection).getResultDescriptor());
}
Aggregations