Search in sources :

Example 1 with InvalidParameter

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

the class Manager method getAllWorkers.

@Override
public HashMap<String, Boolean> getAllWorkers() throws CriticalError, EmployeeNotConnected, ConnectionFailure {
    log.info("Creating getAllWorkers command wrapper");
    String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.GET_ALL_WORKERS, Serialization.serialize(""))).serialize());
    CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
    try {
        resultDescriptorHandler(commandDescriptor.getResultDescriptor());
    } catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse | InvalidParameter ยข) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("getAllWorkers command succeed.");
    return new Gson().fromJson(commandDescriptor.getData(), new TypeToken<HashMap<String, Boolean>>() {
    }.getType());
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) CriticalError(SMExceptions.CommonExceptions.CriticalError) Gson(com.google.gson.Gson) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) AmountBiggerThanAvailable(EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable) InvalidCommandDescriptor(EmployeeDefs.AEmployeeException.InvalidCommandDescriptor) TypeToken(com.google.gson.reflect.TypeToken) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) ParamIDDoesNotExist(EmployeeDefs.AEmployeeException.ParamIDDoesNotExist) ManfacturerStillInUse(EmployeeDefs.AEmployeeException.ManfacturerStillInUse) ProductPackageDoesNotExist(EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)

Example 2 with InvalidParameter

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

the class Worker method isLoggedIn.

@Override
public boolean isLoggedIn() throws CriticalError, ConnectionFailure {
    String serverResponse;
    log.info("Creating is logged in command wrapper with senderID: " + getClientId());
    serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.IS_LOGGED_IN)).serialize());
    CommandWrapper commandWrapper = getCommandWrapper(serverResponse);
    try {
        resultDescriptorHandler(commandWrapper.getResultDescriptor());
    } catch (InvalidCommandDescriptor | InvalidParameter | EmployeeNotConnected | EmployeeAlreadyConnected | AuthenticationError | ProductNotExistInCatalog | ProductAlreadyExistInCatalog | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse e) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("is logged out from server succeed");
    return Serialization.deserialize(commandWrapper.getData(), Boolean.class);
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) CriticalError(SMExceptions.CommonExceptions.CriticalError) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) AmountBiggerThanAvailable(EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable) InvalidCommandDescriptor(EmployeeDefs.AEmployeeException.InvalidCommandDescriptor) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) ParamIDDoesNotExist(EmployeeDefs.AEmployeeException.ParamIDDoesNotExist) ManfacturerStillInUse(EmployeeDefs.AEmployeeException.ManfacturerStillInUse) ProductPackageDoesNotExist(EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)

Example 3 with InvalidParameter

use of EmployeeDefs.AEmployeeException.InvalidParameter 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 4 with InvalidParameter

use of EmployeeDefs.AEmployeeException.InvalidParameter 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 5 with InvalidParameter

use of EmployeeDefs.AEmployeeException.InvalidParameter 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

InvalidParameter (EmployeeDefs.AEmployeeException.InvalidParameter)8 CriticalError (SMExceptions.CommonExceptions.CriticalError)8 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)7 ConnectionFailure (EmployeeDefs.AEmployeeException.ConnectionFailure)6 ParamIDAlreadyExists (EmployeeDefs.AEmployeeException.ParamIDAlreadyExists)4 ParamIDDoesNotExist (EmployeeDefs.AEmployeeException.ParamIDDoesNotExist)4 Manufacturer (BasicCommonClasses.Manufacturer)3 CommandWrapper (ClientServerApi.CommandWrapper)3 ProductNotExistInCatalog (EmployeeDefs.AEmployeeException.ProductNotExistInCatalog)3 WorkerAlreadyExists (EmployeeDefs.AEmployeeException.WorkerAlreadyExists)3 Ingredient (BasicCommonClasses.Ingredient)2 AmountBiggerThanAvailable (EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable)2 AuthenticationError (EmployeeDefs.AEmployeeException.AuthenticationError)2 EmployeeAlreadyConnected (EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected)2 IngredientStillInUse (EmployeeDefs.AEmployeeException.IngredientStillInUse)2 InvalidCommandDescriptor (EmployeeDefs.AEmployeeException.InvalidCommandDescriptor)2 ManfacturerStillInUse (EmployeeDefs.AEmployeeException.ManfacturerStillInUse)2 ProductAlreadyExistInCatalog (EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog)2 ProductPackageDoesNotExist (EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)2 ProductStillForSale (EmployeeDefs.AEmployeeException.ProductStillForSale)2