Search in sources :

Example 1 with ConnectionFailure

use of EmployeeDefs.AEmployeeException.ConnectionFailure in project SmartCity-Market by TechnionYP5777.

the class ManageCatalogProductDetailsTab method renameManuPressed.

void renameManuPressed() {
    long id = manufacturars.get(selectedManu.iterator().next()).getId();
    try {
        manager.editManufacturer(new Manufacturer(id, renameManuLbl.getText()));
    } catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | ParamIDDoesNotExist e) {
        log.fatal(e);
        log.debug(StackTraceUtil.getStackTrace(e));
        e.showInfoToUser();
    }
    selectedManu.clear();
    createManufacturerList();
    enableButtons();
    enableAddButtons();
}
Also used : InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) CriticalError(SMExceptions.CommonExceptions.CriticalError) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) Manufacturer(BasicCommonClasses.Manufacturer) ParamIDDoesNotExist(EmployeeDefs.AEmployeeException.ParamIDDoesNotExist) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected)

Example 2 with ConnectionFailure

use of EmployeeDefs.AEmployeeException.ConnectionFailure in project SmartCity-Market by TechnionYP5777.

the class ManageCatalogProductDetailsTab method addIngPressed.

void addIngPressed() {
    try {
        manager.addIngredient(new Ingredient(0, newIngr.getText()));
    } catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | ParamIDAlreadyExists e) {
        log.fatal(e);
        log.debug(StackTraceUtil.getStackTrace(e));
        e.showInfoToUser();
    }
    selectedIngr.clear();
    createIngredientList();
    enableButtons();
    enableAddButtons();
}
Also used : InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) CriticalError(SMExceptions.CommonExceptions.CriticalError) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) Ingredient(BasicCommonClasses.Ingredient) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected)

Example 3 with ConnectionFailure

use of EmployeeDefs.AEmployeeException.ConnectionFailure in project SmartCity-Market by TechnionYP5777.

the class AEmployee method sendRequestWithRespondToServer.

protected String sendRequestWithRespondToServer(String request) throws ConnectionFailure {
    establishCommunication(WorkerDefs.port, WorkerDefs.host, WorkerDefs.timeout);
    log.info("Sending command to server");
    try {
        String $ = this.clientRequestHandler.sendRequestWithRespond(request);
        terminateCommunication();
        return $;
    } catch (IOException e) {
        log.fatal("Sending logout command to server encounter sever fault : " + e.getMessage());
        terminateCommunication();
        throw new ConnectionFailure();
    }
}
Also used : ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) IOException(java.io.IOException)

Example 4 with ConnectionFailure

use of EmployeeDefs.AEmployeeException.ConnectionFailure in project SmartCity-Market by TechnionYP5777.

the class ViewProductFromCatalogTest method ViewProductFromCatalogSuccessfulTest.

@Test
public void ViewProductFromCatalogSuccessfulTest() {
    CatalogProduct testCatalogProduct = null, catalogProduct = new CatalogProduct(1234567890, "name", null, new Manufacturer(1, "Manufacturer"), "description", 22.0, null, null);
    CommandWrapper commandWrapper = new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(catalogProduct));
    try {
        Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(WorkerDefs.loginCommandSenderId, CommandDescriptor.VIEW_PRODUCT_FROM_CATALOG, Serialization.serialize(new SmartCode(1234567890, null))).serialize())).thenReturn(commandWrapper.serialize());
    } catch (IOException ¢) {
        fail();
    }
    try {
        testCatalogProduct = worker.viewProductFromCatalog(1234567890);
    } catch (InvalidParameter | CriticalError | EmployeeNotConnected | ProductNotExistInCatalog | ConnectionFailure ¢) {
        fail();
    }
    assertEquals(testCatalogProduct.getBarcode(), 1234567890);
    assertEquals(testCatalogProduct.getManufacturer().getId(), 1);
    assertEquals(testCatalogProduct.getManufacturer().getName(), "Manufacturer");
    assertEquals(testCatalogProduct.getName(), "name");
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) CriticalError(SMExceptions.CommonExceptions.CriticalError) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) Manufacturer(BasicCommonClasses.Manufacturer) CatalogProduct(BasicCommonClasses.CatalogProduct) CommandWrapper(ClientServerApi.CommandWrapper) IOException(java.io.IOException) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) Test(org.junit.Test)

Example 5 with ConnectionFailure

use of EmployeeDefs.AEmployeeException.ConnectionFailure in project SmartCity-Market by TechnionYP5777.

the class ManageEmployeesTab method finishBtnPressed.

@FXML
void finishBtnPressed(ActionEvent __) {
    try {
        manager.registerNewWorker(new Login(userTxt.getText(), passTxt.getText(), new ForgotPasswordData(securityCombo.getSelectionModel().getSelectedItem(), securityAnswerTxt.getText())));
    } catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | WorkerAlreadyExists e) {
        log.fatal(e);
        log.debug(StackTraceUtil.getStackTrace(e));
        e.showInfoToUser();
    }
    createEmployeesList();
    enableRemoveButton();
}
Also used : InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) CriticalError(SMExceptions.CommonExceptions.CriticalError) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) Login(BasicCommonClasses.Login) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) FXML(javafx.fxml.FXML)

Aggregations

ConnectionFailure (EmployeeDefs.AEmployeeException.ConnectionFailure)7 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)6 InvalidParameter (EmployeeDefs.AEmployeeException.InvalidParameter)6 CriticalError (SMExceptions.CommonExceptions.CriticalError)6 Manufacturer (BasicCommonClasses.Manufacturer)3 Ingredient (BasicCommonClasses.Ingredient)2 ParamIDAlreadyExists (EmployeeDefs.AEmployeeException.ParamIDAlreadyExists)2 ParamIDDoesNotExist (EmployeeDefs.AEmployeeException.ParamIDDoesNotExist)2 IOException (java.io.IOException)2 CatalogProduct (BasicCommonClasses.CatalogProduct)1 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 Login (BasicCommonClasses.Login)1 SmartCode (BasicCommonClasses.SmartCode)1 CommandWrapper (ClientServerApi.CommandWrapper)1 ProductNotExistInCatalog (EmployeeDefs.AEmployeeException.ProductNotExistInCatalog)1 WorkerAlreadyExists (EmployeeDefs.AEmployeeException.WorkerAlreadyExists)1 FXML (javafx.fxml.FXML)1 Test (org.junit.Test)1