Search in sources :

Example 16 with WorkerAlreadyExists

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

the class Manager method editIngredient.

@Override
public void editIngredient(Ingredient w) throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure, ParamIDDoesNotExist {
    log.info("Creating editIngredient command wrapper with Ingredient: " + w);
    String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.EDIT_INGREDIENT, Serialization.serialize(w))).serialize());
    CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
    try {
        resultDescriptorHandler(commandDescriptor.getResultDescriptor());
    } catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("editIngredient command succeed.");
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) CriticalError(SMExceptions.CommonExceptions.CriticalError) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) AmountBiggerThanAvailable(EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable) InvalidCommandDescriptor(EmployeeDefs.AEmployeeException.InvalidCommandDescriptor) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) ManfacturerStillInUse(EmployeeDefs.AEmployeeException.ManfacturerStillInUse) ProductPackageDoesNotExist(EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)

Example 17 with WorkerAlreadyExists

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

the class Manager method removeManufacturer.

@Override
public void removeManufacturer(Manufacturer m) throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure, ParamIDDoesNotExist, ManfacturerStillInUse {
    log.info("Creating removeManufacturer command wrapper with Manufacturer: " + m);
    String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.REMOVE_MANUFACTURER, Serialization.serialize(m))).serialize());
    CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
    try {
        resultDescriptorHandler(commandDescriptor.getResultDescriptor());
    } catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | WorkerDoesNotExist | IngredientStillInUse ¢) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("removeManufacturer command succeed.");
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) CriticalError(SMExceptions.CommonExceptions.CriticalError) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) AmountBiggerThanAvailable(EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable) InvalidCommandDescriptor(EmployeeDefs.AEmployeeException.InvalidCommandDescriptor) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) ProductPackageDoesNotExist(EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)

Example 18 with WorkerAlreadyExists

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

the class Manager method getAllIngredients.

@Override
public List<Ingredient> getAllIngredients() throws InvalidParameter, CriticalError, ConnectionFailure {
    log.info("Creating getAllIngredients command wrapper");
    String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.GET_ALL_INGREDIENTS, 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 | EmployeeNotConnected ¢) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("getAllIngredients command succeed.");
    return new Gson().fromJson(commandDescriptor.getData(), new TypeToken<List<Ingredient>>() {
    }.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) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) AmountBiggerThanAvailable(EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable) Ingredient(BasicCommonClasses.Ingredient) 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 19 with WorkerAlreadyExists

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

the class Worker method logout.

@Override
public void logout() throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure {
    log.info("Creating logout command wrapper with username: " + username);
    String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.LOGOUT, Serialization.serialize(username))).serialize());
    try {
        resultDescriptorHandler(getCommandWrapper(serverResponse).getResultDescriptor());
    } catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductNotExistInCatalog | ProductAlreadyExistInCatalog | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    setClientId(WorkerDefs.loginCommandSenderId);
    log.info("logout from server succeed.");
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) ProductNotExistInCatalog(EmployeeDefs.AEmployeeException.ProductNotExistInCatalog) CriticalError(SMExceptions.CommonExceptions.CriticalError) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) 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 20 with WorkerAlreadyExists

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

the class Worker method removeProductPackageFromStore.

@Override
public void removeProductPackageFromStore(ProductPackage p) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductNotExistInCatalog, AmountBiggerThanAvailable, ProductPackageDoesNotExist, ConnectionFailure {
    log.info("Creating removeProductPackageFromStore command wrapper with product package: " + p);
    String serverResponse = sendRequestWithRespondToServer(new CommandWrapper(getClientId(), CommandDescriptor.REMOVE_PRODUCT_PACKAGE_FROM_STORE, Serialization.serialize(p)).serialize());
    CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
    try {
        resultDescriptorHandler(commandDescriptor.getResultDescriptor());
    } catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductAlreadyExistInCatalog | ProductStillForSale | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
        log.fatal("Critical bug: this command result isn't supposed to return here");
        throw new CriticalError();
    }
    log.info("removeProductPackageFromStore command succeed.");
}
Also used : AuthenticationError(EmployeeDefs.AEmployeeException.AuthenticationError) CriticalError(SMExceptions.CommonExceptions.CriticalError) CommandWrapper(ClientServerApi.CommandWrapper) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) EmployeeAlreadyConnected(EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) ProductAlreadyExistInCatalog(EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog) ProductStillForSale(EmployeeDefs.AEmployeeException.ProductStillForSale) InvalidCommandDescriptor(EmployeeDefs.AEmployeeException.InvalidCommandDescriptor) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) ParamIDDoesNotExist(EmployeeDefs.AEmployeeException.ParamIDDoesNotExist) ManfacturerStillInUse(EmployeeDefs.AEmployeeException.ManfacturerStillInUse)

Aggregations

WorkerAlreadyExists (EmployeeDefs.AEmployeeException.WorkerAlreadyExists)22 CriticalError (SMExceptions.CommonExceptions.CriticalError)22 CommandWrapper (ClientServerApi.CommandWrapper)21 InvalidCommandDescriptor (EmployeeDefs.AEmployeeException.InvalidCommandDescriptor)21 AuthenticationError (EmployeeDefs.AEmployeeException.AuthenticationError)20 EmployeeAlreadyConnected (EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected)20 IngredientStillInUse (EmployeeDefs.AEmployeeException.IngredientStillInUse)20 ManfacturerStillInUse (EmployeeDefs.AEmployeeException.ManfacturerStillInUse)20 ProductAlreadyExistInCatalog (EmployeeDefs.AEmployeeException.ProductAlreadyExistInCatalog)20 ProductStillForSale (EmployeeDefs.AEmployeeException.ProductStillForSale)20 WorkerDoesNotExist (EmployeeDefs.AEmployeeException.WorkerDoesNotExist)20 AmountBiggerThanAvailable (EmployeeDefs.AEmployeeException.AmountBiggerThanAvailable)19 ParamIDAlreadyExists (EmployeeDefs.AEmployeeException.ParamIDAlreadyExists)19 ProductPackageDoesNotExist (EmployeeDefs.AEmployeeException.ProductPackageDoesNotExist)18 ParamIDDoesNotExist (EmployeeDefs.AEmployeeException.ParamIDDoesNotExist)17 ProductNotExistInCatalog (EmployeeDefs.AEmployeeException.ProductNotExistInCatalog)15 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)4 InvalidParameter (EmployeeDefs.AEmployeeException.InvalidParameter)3 Gson (com.google.gson.Gson)3 TypeToken (com.google.gson.reflect.TypeToken)3