Product ID may not be getting set properly on new NestUPCs
-
SelectItemFragment.java is loading the categories and subcategories in a manual hard-coded into string-arrays approach, rather than getting the categories, subcategories, names, and subtitles straight from the "products" table of the database or FoodKeeper-API using JSON. This approach may still work but, it may have to be manually updated from time to time which is not optimal, and subcategories still needs to be split into two separate fields: “name” and “subtitle”. May want to update it to load "categories", "names", and "subtitles" from the "categories" and "products" tables from Nest.db database. (See assets/NestDB.Create.sql) This may require adding new methods to NestDBDataSource.java that return the "categories", "names", and "subtitles".
-
SelectItemFragment.java should be updated to have 3-4 Spinners/PopupMenus that get the "category", (optional "subcategory"), "name", and "subtitle" from the user, in that respective order. (See assets/NestDB.Create.sql lines 56-60). If you want to see how "categories" and "products" are stored in the JSON files these are two links taken from NestDBOpenHelper.java.
[Categories] - https://foodkeeper-api.herokuapp.com/categories
[Products] - https://foodkeeper-api.herokuapp.com/products
-
-
getProdIdfromProdInfo(int cId, String iName) method in NestDBDataSource.java needs to be updated to include a third parameter of type String that also checks for the "subtitle" of the product. [Ex. getProdIdfromProdInfo(int cId, String name, String subtitle)] This is because there are many products with the same "name" and "category id" so this method will currently only return the first id it finds in the list of products that have the same "name" and "category id". Including a "subtitle" parameter will help further specify which product id out of that list to return.
-
SelectItemFragment.java, should be updated to use the new getProdIdfromProdInfo(int cId, String name, String subtitle) method (using the new values obtained from the "category", "name" and "subtitle" Spinners/PopupMenus) to determine the correct product id if no UPCs exists in the database.
Here is a screenshot of some of the products stored in the "products" table in Nest.db database with the getProdIdFromProdInfo method to help understand why a additional "subtitle" field is needed. Notice how there are 5 types of cheeses and they each have a different "id" but same "name" and "categoryId", getProdIdFromProdInfo would only return the first one out of those 5.