Exemplo n.º 1
0
 def post(self):
     args = postParser.parse_args()
     QUERY_POST_RECIPE = file_processor.read_sql_file(
         "sql/recipe/post_recipe.sql")
     sql_creation = QUERY_POST_RECIPE.format("\'{}\'".format(args['name']))
     sql_creation = sql_processor.handleNone(sql_creation)
     database_processor.insert_data_into_database(sql_creation)
     # START Get nextId
     QUERY_NEXTID_RECIPE = file_processor.read_sql_file(
         "sql/recipe/nextid_recipe.sql")
     sql_creation = QUERY_NEXTID_RECIPE
     nextId = database_processor.fetch_data_in_database(sql_creation)
     # END - Get nextId
     return ({'nextId': nextId[0][0]}, 201)
Exemplo n.º 2
0
    def get(self):
        QUERY_SELECT_CONDITION_LIST = file_processor.read_sql_file(
            "sql/condition/select_condition_list.sql")
        recipeList = database_processor.fetch_data_in_database_pd_dataframe(
            QUERY_SELECT_CONDITION_LIST).to_dict(orient="records")

        # START - Get nextId
        QUERY_NEXTID_CONDITION = file_processor.read_sql_file(
            "sql/condition/nextid_condition.sql")
        sql_creation = QUERY_NEXTID_CONDITION
        nextId = database_processor.fetch_data_in_database(sql_creation)
        # END - Get nextId
        if recipeList:
            return {'payload': recipeList, 'nextId': nextId[0][0]}
        api.abort(404)
Exemplo n.º 3
0
    def get(self):
        QUERY_SELECT_QUANTITY_TYPE_LIST = file_processor.read_sql_file(
            "sql/quantity_type/select_quantity_type_list.sql")
        recipeList = database_processor.fetch_data_in_database_pd_dataframe(
            QUERY_SELECT_QUANTITY_TYPE_LIST).to_dict(orient="records")

        # START - Get nextId
        QUERY_NEXTID_QUANTITY_TYPE = file_processor.read_sql_file(
            "sql/quantity_type/nextid_quantity_type.sql")
        sql_creation = QUERY_NEXTID_QUANTITY_TYPE
        nextId = database_processor.fetch_data_in_database(sql_creation)
        # END - Get nextId
        if recipeList:
            return {'payload': recipeList, 'nextId': nextId[0][0]}
        api.abort(404)
Exemplo n.º 4
0
    def post(self):
        args = postParser.parse_args()
        QUERY_POST_TAG = file_processor.read_sql_file("sql/tag/post_tag.sql")

        sql_creation = QUERY_POST_TAG.format(
            "\'{}\'".format(args['tag_group']), "\'{}\'".format(args['name']))
        sql_creation = sql_processor.handleNone(sql_creation)
        database_processor.insert_data_into_database(sql_creation)
        # START Get nextId
        QUERY_NEXTID_TAG = file_processor.read_sql_file(
            "sql/tag/nextid_tag.sql")
        sql_creation = QUERY_NEXTID_TAG
        nextId = database_processor.fetch_data_in_database(sql_creation)
        # END - Get nextId
        return ({'nextId': nextId[0][0]}, 201)
Exemplo n.º 5
0
 def post(self):
     args = postParser.parse_args()
     QUERY_POST_QUANTITY_TYPE = file_processor.read_sql_file(
         "sql/quantity_type/post_quantity_type.sql")
     sql_creation = QUERY_POST_QUANTITY_TYPE.format(
         "\'{}\'".format(args['quantity_type']),
         "\'{}\'".format(args['abbreviation']))
     sql_creation = sql_processor.handleNone(sql_creation)
     database_processor.insert_data_into_database(sql_creation)
     # START Get nextId
     QUERY_NEXTID_QUANTITY_TYPE = file_processor.read_sql_file(
         "sql/quantity_type/nextid_quantity_type.sql")
     sql_creation = QUERY_NEXTID_QUANTITY_TYPE
     nextId = database_processor.fetch_data_in_database(sql_creation)
     # END - Get nextId
     return ({'nextId': nextId[0][0]}, 201)
Exemplo n.º 6
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_TAG = file_processor.read_sql_file(
         "sql/tag/delete_tag.sql")
     sql_creation = QUERY_DELETE_TAG.format(args['tag_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 7
0
 def get(self):
     args = getParser.parse_args()
     QUERY_SELECT_SPICE = file_processor.read_sql_file(
         "sql/spice/select_spice.sql")
     sql_creation = QUERY_SELECT_SPICE.format(args['spice_id'])
     recipeList = database_processor.fetch_data_in_database_pd_dataframe(
         sql_creation).to_dict(orient="records")
     # START - Get nextId
     QUERY_NEXTID_SPICE = file_processor.read_sql_file(
         "sql/spice/nextid_spice.sql")
     sql_creation = QUERY_NEXTID_SPICE
     nextId = database_processor.fetch_data_in_database(sql_creation)
     # END - Get nextId
     if recipeList:
         return {'payload': recipeList, 'nextId': nextId[0][0]}
     api.abort(404)
Exemplo n.º 8
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_SPICE = file_processor.read_sql_file(
         "sql/spice/delete_spice.sql")
     sql_creation = QUERY_DELETE_SPICE.format(args['spice_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 9
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_CONDITION = file_processor.read_sql_file(
         "sql/condition/delete_condition.sql")
     sql_creation = QUERY_DELETE_CONDITION.format(args['condition_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 10
0
 def get(self):
     args = getParser.parse_args()
     QUERY_SELECT_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/select_ingredient.sql")
     sql_creation = QUERY_SELECT_INGREDIENT.format(args['ingredient_id'])
     recipeList = database_processor.fetch_data_in_database_pd_dataframe(
         sql_creation).to_dict(orient="records")
     # START - Get nextId
     QUERY_NEXTID_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/nextid_ingredient.sql")
     sql_creation = QUERY_NEXTID_INGREDIENT
     nextId = database_processor.fetch_data_in_database(sql_creation)
     # END - Get nextId
     if recipeList:
         return {'payload': recipeList, 'pk_autofill': nextId[0][0]}
     api.abort(404)
Exemplo n.º 11
0
 def put(self):
     # court_id, court_status_list_id, valid_from, valid_to, modified_at, changed_by
     court_id = request.args.get('court_id')
     if not request.args.get("court_id"):
         raise RuntimeError("court_id is missing")
     court_status_list_id = request.args.get('court_status_list_id')
     if not request.args.get("court_status_list_id"):
         raise RuntimeError("court_status_list_id is missing")
     valid_from = request.args.get('valid_from')
     if not request.args.get("valid_from"):
         raise RuntimeError("valid_from is missing")
     valid_to = request.args.get('valid_to')
     if not request.args.get("valid_to"):
         raise RuntimeError("valid_to is missing")
     changed_by = request.args.get('changed_by')
     if not request.args.get("changed_by"):
         raise RuntimeError("changed_by is missing")
     modified_at = request.args.get('modified_at')
     if modified_at == '':
         modified_at = 'NULL'
     QUERY_INSERT = file_processor.read_sql_file(
         "sql/court_status_insert.sql")
     sql_insert_statement = QUERY_INSERT.format(court_id,
                                                court_status_list_id,
                                                "\'{}\'".format(valid_from),
                                                "\'{}\'".format(valid_to),
                                                modified_at,
                                                "\'{}\'".format(changed_by))
     database_processor.insert_data_into_database(sql_insert_statement)
     return 201
Exemplo n.º 12
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/delete_ingredient.sql")
     sql_creation = QUERY_DELETE_INGREDIENT.format(args['ingredient_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 13
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_RECIPE = file_processor.read_sql_file(
         "sql/recipe/delete_recipe.sql")
     sql_creation = QUERY_DELETE_RECIPE.format(args['recipe_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 14
0
 def get(self):
     sql_court_status_list = file_processor.read_sql_file(
         "sql/select_court_status_list.sql")
     all_court_status_list = database_processor.fetch_data_in_database(
         sql_court_status_list)
     column = ['court_status_list_id', 'court_status_name']
     items = [dict(zip(column, row)) for row in all_court_status_list]
     return items
Exemplo n.º 15
0
 def put(self):
     args = updateParser.parse_args()
     QUERY_PUT_TAG = file_processor.read_sql_file("sql/tag/put_tag.sql")
     sql_creation = QUERY_PUT_TAG.format("\'{}\'".format(args['tag_group']),
                                         "\'{}\'".format(args['name']),
                                         args['tag_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 16
0
 def get(self):
     QUERY_SELECT_INGREDIENT_LIST = file_processor.read_sql_file(
         "sql/ingredient/select_ingredient_list.sql")
     recipeList = database_processor.fetch_data_in_database_pd_dataframe(
         QUERY_SELECT_INGREDIENT_LIST).to_dict(orient="records")
     print(recipeList)
     # START - Get nextId
     QUERY_NEXTID_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/nextid_ingredient.sql")
     sql_creation = QUERY_NEXTID_INGREDIENT
     pk_autofill = database_processor.fetch_data_in_database_pd_dataframe(
         sql_creation).to_dict(orient="records")[0]
     print(pk_autofill)
     # END - Get nextId
     if recipeList:
         return {'payload': recipeList, 'pk_autofill': pk_autofill}
     api.abort(404)
Exemplo n.º 17
0
 def post(self):
     args = postParser.parse_args()
     QUERY_POST_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/post_ingredient.sql")
     sql_creation = QUERY_POST_INGREDIENT.format(
         "\'{}\'".format(args['name']),
         "\'{}\'".format(args['description']))
     sql_creation = sql_processor.handleNone(sql_creation)
     database_processor.insert_data_into_database(sql_creation)
     # START Get nextId
     QUERY_NEXTID_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/nextid_ingredient.sql")
     sql_creation = QUERY_NEXTID_INGREDIENT
     pk_autofill = database_processor.fetch_data_in_database_pd_dataframe(
         sql_creation)
     # END - Get nextId
     return ({'pk_autofill': pk_autofill}, 201)
Exemplo n.º 18
0
 def get(self):
     QUERY_SELECT = file_processor.read_sql_file(
         "sql/court_status_list.sql")
     sql_statement = QUERY_SELECT
     row_list = database_processor.fetch_data_in_database(sql_statement)
     column = ['court_status_list_id', 'court_status_name']
     items = [dict(zip(column, row)) for row in row_list]
     return items
Exemplo n.º 19
0
 def delete(self):
     args = deleteParser.parse_args()
     QUERY_DELETE_QUANTITY_TYPE = file_processor.read_sql_file(
         "sql/quantity_type/delete_quantity_type.sql")
     sql_creation = QUERY_DELETE_QUANTITY_TYPE.format(
         args['quantity_type_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 20
0
 def put(self):
     args = updateParser.parse_args()
     QUERY_PUT_RECIPE = file_processor.read_sql_file(
         "sql/recipe/put_recipe.sql")
     sql_creation = QUERY_PUT_RECIPE.format("\'{}\'".format(args['name']),
                                            args['recipe_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 21
0
 def put(self):
     args = updateParser.parse_args()
     QUERY_PUT_CONDITION = file_processor.read_sql_file(
         "sql/condition/put_condition.sql")
     sql_creation = QUERY_PUT_CONDITION.format(
         "\'{}\'".format(args['name']), args['condition_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 22
0
 def put(self):
     args = updateParser.parse_args()
     QUERY_PUT_QUANTITY_TYPE = file_processor.read_sql_file(
         "sql/quantity_type/put_quantity_type.sql")
     sql_creation = QUERY_PUT_QUANTITY_TYPE.format(
         "\'{}\'".format(args['quantity_type']),
         "\'{}\'".format(args['abbreviation']), args['quantity_type_id'])
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 23
0
 def post(self):
     args = postParser.parse_args()
     QUERY_POST_RECIPE_TAG = file_processor.read_sql_file(
         "sql/recipe_tag/post_recipe_tag.sql")
     sql_creation = QUERY_POST_RECIPE_TAG.format(args['recipe_id'],
                                                 args['tag_id'])
     sql_creation = sql_processor.handleNone(sql_creation)
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 24
0
 def put(self):
     args = updateParser.parse_args()
     QUERY_PUT_INGREDIENT = file_processor.read_sql_file(
         "sql/ingredient/put_ingredient.sql")
     sql_creation = QUERY_PUT_INGREDIENT.format(
         "\'{}\'".format(args['name']),
         "\'{}\'".format(args['description']), args['ingredient_id'])
     sql_creation = sql_processor.handleNone(sql_creation)
     database_processor.insert_data_into_database(sql_creation)
     return 201
Exemplo n.º 25
0
 def get(self):
     QUERY_SELECT_ALL_TASKS = file_processor.read_sql_file(
         "sql/select_all_tasks.sql")
     sql_all_tasks = QUERY_SELECT_ALL_TASKS
     all_tasks = self.database_processor.fetch_data_in_database(
         sql_all_tasks)
     column = [
         'task_no', 'title', 'description', 'created_at', 'modified_at',
         'due_date', 'resolution_date', 'priority', 'task_status'
     ]
     items = [dict(zip(column, row)) for row in all_tasks]
     return items
Exemplo n.º 26
0
 def put(self):
     person_no = request.args.get('person_no')
     is_member = request.args.get('is_member')
     member_no = request.args.get('member_no')
     first_name = request.args.get('first_name')
     last_name = request.args.get('last_name')
     QUERY_INSERT_PERSON = file_processor.read_sql_file(
         "sql/insert_person.sql")
     sql_insert_person = QUERY_INSERT_PERSON.format(
         person_no, is_member, member_no, "\'{}\'".format(first_name),
         "\'{}\'".format(last_name))
     database_processor.insert_data_into_database(sql_insert_person)
     return 201
Exemplo n.º 27
0
 def get(self):
     parser = reqparse.RequestParser()
     parser.add_argument('person_no',
                         required=True,
                         help="person_no cannot be blank!")
     args = parser.parse_args()
     QUERY_SELECT = file_processor.read_sql_file(
         "sql/select_person_info.sql")
     sql_statement = QUERY_SELECT.format("\'{}\'".format(args['person_no']))
     row_list = database_processor.fetch_data_in_database(sql_statement)
     column = ['person_no', 'first_name', 'last_name', 'member_no', 'role']
     items = [dict(zip(column, row)) for row in row_list]
     return items
Exemplo n.º 28
0
 def get(self):
     parser = reqparse.RequestParser()
     parser.add_argument('task_no',
                         required=True,
                         help="task_no cannot be blank!")
     args = parser.parse_args()
     QUERY_SELECT_TASK_DETAIL = file_processor.read_sql_file(
         "sql/select_task_details.sql")
     sql_task_detail = QUERY_SELECT_TASK_DETAIL.format(args['task_no'])
     task_detail = database_processor.fetch_data_in_database(
         sql_task_detail)
     column = ['relationship_type', 'person_no', 'first_name', 'last_name']
     items = [dict(zip(column, row)) for row in task_detail]
     return items
Exemplo n.º 29
0
    def get(self):
        QUERY_SELECT_RECIPE_LIST = file_processor.read_sql_file(
            "sql/recipe/select_recipe_list.sql")
        recipeList = database_processor.fetch_data_in_database_pd_dataframe(
            QUERY_SELECT_RECIPE_LIST)
        recipes = recipeList.groupby(['recipe_id', 'recipe_name'],
                                     as_index=False).max('duration')[[
                                         'recipe_id', 'recipe_name', 'duration'
                                     ]].rename(columns={
                                         'recipe_name': 'name'
                                     }).to_dict(orient="records")
        tagList = recipeList.groupby(
            ['recipe_id', 'tag_name', 'tag_group'], as_index=False
        ).last()[['recipe_id', 'tag_name', 'tag_group']].to_dict(
            orient="records"
        )  # .groupby(['recipe_id']).tag_name_group.apply(list).reset_index().to_dict(orient="records")

        items = []
        for recipe_r in recipes:
            recipe_r['tags'] = []
            for recipe_tl in tagList:
                if recipe_r['recipe_id'] == recipe_tl['recipe_id']:
                    tag = {
                        key: recipe_tl[key]
                        for key in ['tag_name', 'tag_group']
                    }
                    recipe_r['tags'].append(tag)
                    items.append(recipe_r)

        QUERY_NEXTID_RECIPE = file_processor.read_sql_file(
            "sql/recipe/nextid_recipe.sql")
        sql_creation = QUERY_NEXTID_RECIPE
        nextId = database_processor.fetch_data_in_database(sql_creation)
        # END - Get nextId
        if items:
            return {'payload': items, 'nextId': nextId[0][0]}
        api.abort(404)
Exemplo n.º 30
0
 def get(self):
     parser = reqparse.RequestParser()
     parser.add_argument('date',
                         required=True,
                         help="date cannot be blank!")
     args = parser.parse_args()
     QUERY_SELECT = file_processor.read_sql_file(
         "sql/court_status_date.sql")
     sql_statement = QUERY_SELECT.format(args['date'])
     row_list = database_processor.fetch_data_in_database(sql_statement)
     column = [
         'court_id', 'court_no', 'court_status_name', 'court_surface',
         'court_type'
     ]
     items = [dict(zip(column, row)) for row in row_list]
     return items