use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLJsonGenerator method ProductToJson.
/**
* convert product from ResultSet to Json representation of product
*
* @param product
* - ResultSet of the product\s joined with manufactures table
* (assuming the ResultSet ordered by product barcode) the
* ResultSet need to point to the product to convert). this
* object will point the next product after returning.
* @param productIngredients
* - ResultSet of the product\s ingredients (assuming the
* ResultSet ordered by product barcode) the ResultSet should
* pointing the product to convert, if it has ingredients. if so,
* this object will point the next product after returning.
* @param productLocations
* - ResultSet of the product\s locations (assuming the ResultSet
* ordered by product barcode) the ResultSet should pointing the
* product to convert, if it has ingredients. if so, this object
* will point the next product after returning.
* @return
* @throws CriticalError
*/
static String ProductToJson(ResultSet product, ResultSet productIngredients, ResultSet productLocations) throws CriticalError {
HashSet<Location> locations;
HashSet<Ingredient> ingredients;
try {
long productBarcode = product.getLong(ProductsCatalogTable.barcodeCol.getColumnNameSQL());
// adding all ingredients
ingredients = createIngredientsListByBarcode(productBarcode, productIngredients);
// adding all locations
locations = createLocationsList(productBarcode, productLocations);
// get product other details
String productManufacturerName = getStringFromResultset(product, ManufacturerTable.manufacturerNameCol);
int productManufacturerID = product.getInt(ManufacturerTable.manufacturerIDCol.getColumnNameSQL());
String productDescription = getStringFromResultset(product, ProductsCatalogTable.productDescriptionCol), productName = getStringFromResultset(product, ProductsCatalogTable.productNameCol), productPicture = getStringFromResultset(product, ProductsCatalogTable.productPictureCol);
double productPrice = product.getDouble(ProductsCatalogTable.productPriceCol.getColumnNameSQL());
product.next();
return Serialization.serialize(new CatalogProduct(productBarcode, productName, ingredients, new Manufacturer(productManufacturerID, productManufacturerName), productDescription, productPrice, productPicture, locations));
} catch (SQLException e) {
throw new SQLDatabaseException.CriticalError();
}
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class Serialization method deserializeManufacturersHashSet.
public static HashSet<Manufacturer> deserializeManufacturersHashSet(String hashsetToDeserialize) {
Gson gson = new Gson();
Type hashsetType = new TypeToken<HashSet<Manufacturer>>() {
}.getType();
HashSet<Manufacturer> result = gson.fromJson(hashsetToDeserialize, hashsetType);
return result;
}
Aggregations