how to write a very tough program code for below tough problem:
1. Utility to read JSON file from file server
2. Utility should run at scheduled time let’s say 6AM
3. Error message if JSON file is not properly formatted
4. Error message if Category is missing and ITEM need that Category to be saved.
5. Entity mapping as per the given relationship in data model
5. Documentation for the API, preferably using any tool
6. Junit Test cases using Mockito
7. Use either MySQL or Oracle for API development
8. add one point as JSON validation for not null and value range
Validation Points:
Step 1: You have to read the file, If any Error, please correct.
Step 2: IF any category/item Missing, Null Message came or Any notification.
Step 3: Add the category and save the message,
Step 4: if Order not received it 6 AM, then Not file Uploaded Message must show OR repeat the previous order.
Step 5: Must add clock in Programmer.
Introduction
Someone wants to manage their website. One of
the most important pages on their website is the “Menu” page.The menu gets updated every
night at the restaurant and Joe’s grill wants the updated menu published to their website every
morning. customer will upload their menu in a JSON formatted file (Let’s call it menu.json) to our
ftp server every night.
Requirement is to develop a program to take this menu.json file and store the data
in a relational database. The data model for the database tables is defined as follows.
Data model
items: id(pkey), name
categories: id(pkey), name
category_items: id(pkey), category_id (fkey categories), item_id(fkey items)
menu.json
{
"category”:[{
“name”: “Appetizer”,
},
{
“name”: “Entree”
}
]
],
"item”:[
{
"name":"French Fries",
"category":"Appetizer"
},
{
"name":"Onion Rings",
"category":"Appetizer"
},
{
"name":"Sandwich",
"category":"Entree"
},
{
"name":"Tacos",
"category":"Entree"
},
{
"name":"Ice Cream Sundae",
"category":"Dessert"
}
],
"restaurant":"Joe's Grill"
}
}
Existing classes:
class category:
def __init__(self, name):
self.name = name
class item:
def __init__(self, name, category_name):
self.name = name
self.category_name = category_name
Helper Functions that Already exist
// json.get_categories(file_name) -> returns array of active category objects (category.name)
// json.get_items(file_name) --> returns array of item object (item.name, item.category_name)
// db.write(table_name, <a data dict or an array of data dicts>) //db.write('categories', {'name':
'c1'})
Note:The keys of the dictionary are the table column names, the values are the row values in
the database table