use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnection method addManufacturer.
@Override
public String addManufacturer(Integer sessionID, String manufacturerName) throws CriticalError, ClientNotConnected {
log.debug("SQL Public addManufacturer: manufacturer name: " + manufacturerName + " (SESSION: " + sessionID + " )");
validateSessionEstablished(sessionID);
int $;
// START transaction
connectionStartTransaction();
try {
// WRITE part of transaction
// get "fresh" id for the new manufacturer
$ = allocateIDToTable(ManufacturerTable.table, ManufacturerTable.manufacturerIDCol);
String insertQuery = new InsertQuery(ManufacturerTable.table).addColumn(ManufacturerTable.manufacturerIDCol, PARAM_MARK).addColumn(ManufacturerTable.manufacturerNameCol, PARAM_MARK).validate() + "";
insertQuery.hashCode();
getParameterizedQuery(insertQuery, $, manufacturerName).executeUpdate();
// END transaction
connectionCommitTransaction();
} catch (CriticalError | SQLException e) {
connectionRollbackTransaction();
throw new CriticalError();
} finally {
connectionEndTransaction();
}
return Serialization.serialize(new Manufacturer($, manufacturerName));
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class ManageCatalogProductTab method getManufacturer.
private Manufacturer getManufacturer() {
Manufacturer $ = null;
String man = productManufacturerCombo.getValue();
switch(man) {
case "אסם":
$ = new Manufacturer(4, man);
break;
case "בייגל-בייגל":
$ = new Manufacturer(5, man);
break;
case "מאפיות ברמן":
$ = new Manufacturer(2, man);
break;
case "עלית":
$ = new Manufacturer(3, man);
break;
case "תנובה":
$ = new Manufacturer(1, man);
break;
}
return $;
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class ManageCatalogProductDetailsTab method addManuPressed.
void addManuPressed() {
try {
manager.addManufacturer(new Manufacturer(0, newManu.getText()));
} catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | ParamIDAlreadyExists e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
selectedManu.clear();
createManufacturerList();
enableButtons();
enableAddButtons();
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class Manager method getAllManufacturers.
@Override
public List<Manufacturer> getAllManufacturers() throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure {
log.info("Creating getAllManufacturers command wrapper");
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.GET_ALL_MANUFACTURERS, 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 ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("getAllManufacturers command succeed.");
return new Gson().fromJson(commandDescriptor.getData(), new TypeToken<List<Manufacturer>>() {
}.getType());
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testGetManufacturersList.
@Test
public void testGetManufacturersList() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
String result = null;
try {
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
}
Aggregations