Commit 3cad21a7 authored by OnellaNatalie's avatar OnellaNatalie

Merge branch 'master' of http://gitlab.sliit.lk/2022-158/2022-158 into IT19041926

# Conflicts:
#	backend/database.db
#	backend/models/attribute_model.py
#	backend/models/class_component_model.py
#	backend/routes/submission_routes.py
#	backend/services/class_model_detection_service.py
parents 96a8c049 82e05909
No preview for this file type
......@@ -4,9 +4,11 @@ from config.database import db
class Assignment(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(200), nullable=False)
module_id = db.Column(db.Integer, db.ForeignKey('module.id'))
content = db.Column(db.String(800), nullable=False)
plagiarism_percentage = db.Column(db.Integer, nullable=False)
assignment_type = db.Column(db.Integer, nullable=False)
start_at = db.Column(db.DateTime, default=datetime.now())
end_at = db.Column(db.DateTime)
created_at = db.Column(db.DateTime, default=datetime.now())
......
from config.database import db
class Attribute(db.Model):
id = db.Column(db.Integer, primary_key=True)
data_type = db.Column(db.String(50), nullable=False)
name = db.Column(db.String(50), nullable=False)
access_spec = db.Column(db.String(50), nullable=False)
class_id = db.Column(db.Integer)
def __repr__(self) -> str:
return 'Attribute>>> {self.content}'
from sqlalchemy.orm import relationship
from config.database import db
class Component(db.Model):
id = db.Column(db.Integer, primary_key=True)
class_answer = db.Column(db.Integer, nullable=False)
name = db.Column(db.String(50), nullable=False)
type = db.Column(db.String(50), nullable=False)
x_min = db.Column(db.String(50), nullable=False)
y_min = db.Column(db.String(50), nullable=False)
x_max = db.Column(db.String(50), nullable=False)
y_max = db.Column(db.String(50), nullable=False)
def __repr__(self) -> str:
return 'Class>>> {self.content}'
from config.database import db
class Relationship(db.Model):
id = db.Column(db.Integer, primary_key=True)
class_answer = db.Column(db.Integer, nullable=False)
name = db.Column(db.String(50))
type = db.Column(db.String(50), nullable=False)
x_min = db.Column(db.String(50), nullable=False)
y_min = db.Column(db.String(50), nullable=False)
x_max = db.Column(db.String(50), nullable=False)
y_max = db.Column(db.String(50), nullable=False)
comp_1 = db.Column(db.Integer, nullable=False)
comp_2 = db.Column(db.Integer, nullable=False)
def __repr__(self) -> str:
return 'class_relationship>>> {self.content}'
from config.database import db
class Multiplicity(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(50))
relationship_id = db.Column(db.String(50))
x_min = db.Column(db.String(50), nullable=False)
y_min = db.Column(db.String(50), nullable=False)
x_max = db.Column(db.String(50), nullable=False)
y_max = db.Column(db.String(50), nullable=False)
def __repr__(self) -> str:
return 'Class_Multiplicity>>> {self.content}'
......@@ -5,8 +5,8 @@ from config.database import db
class Diagram(db.Model):
id = db.Column(db.Integer, primary_key=True)
assignment_id = db.Column(db.Integer, db.ForeignKey('assignment.id'))
class_diagram_path = db.Column(db.String(80), nullable=False)
usecase_diagram_path = db.Column(db.String(80), nullable=False)
class_diagram_path = db.Column(db.String(80))
usecase_diagram_path = db.Column(db.String(80))
created_at = db.Column(db.DateTime, default=datetime.now())
updated_at = db.Column(db.DateTime, onupdate=datetime.now(), default=datetime.now())
......
class WarehouseOperator:
def create_orders_by_uploading_a_csv_file(self):
pass
def make_adjustments_to_the_order(self):
pass
def allocate_a_vehicle_for_a_job(self):
pass
def change_the_system_suggested_optimized_route_if_required(self):
pass
def confirm_a_job(self):
pass
def change_the_vehicle_allocated_for_a_job(self):
pass
def export_information_of_a_job_to_pdf_and_xls_format(self):
pass
def indicate_that_the_loading_is_completed(self):
pass
def generate_an_invoice_for_each_vehicle(self):
pass
def generate_vehicle_capacity_utilization_report(self):
pass
def generate_outlet_wise_transport_cost_report_for_a_given_date_range(self):
pass
def generate_vehicle_turnaround_time_report_for_a_warehouse(self):
pass
def generate_cost_per_1_kg_report(self):
pass
def generate_an_idle_time_limit_violation_report(self):
pass
class WarehouseIncharge:
def confirm_the_delivered_items_to_a_outlet(self):
pass
def approve_a_job(self):
pass
def request_a_modification_to_the_planned_mileage_of_a_job(self):
pass
class Admin:
def approve_the_planned_mileage_modification_request_submitted_by_the_WarehouseIncharge(self):
pass
def modify_the_minimum_fix_mileage_configuration_for_a_job(self):
pass
def modify_the_unloading_charge(self):
pass
def update_the_radius_limit_from_a_warehouse_for___drop_off___charges(self):
pass
def set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited(self):
pass
def modify_the___drop_off___rate_table(self):
pass
def edit_the_eligibility_criteria_for_driver_incentive(self):
pass
def edit_the_per_km_rate_for_an_existing_vehicle_capacity_type(self):
pass
class WarehouseOperator:
def create_orders_by_uploading_a_csv_file(self):
pass
def make_adjustments_to_the_order(self):
pass
def allocate_a_vehicle_for_a_job(self):
pass
def change_the_system_suggested_optimized_route_if_required(self):
pass
def confirm_a_job(self):
pass
class Admin:
def modify_the_minimum_fix_mileage_configuration_for_a_job(self):
pass
def modify_the_unloading_charge(self):
pass
class Admin:
def login_to_the_system(self):
pass
def view_and_manage_cart_items(self):
pass
def check_the_payments_and_sold_items(self):
pass
def reply_to_Customer_feedbacks(self):
pass
class WarehouseOperator:
def Create_Orders_By_Uploading_A_Csv_File(self):
pass
def Make_Adjustments_To_The_Order(self):
pass
def Allocate_A_Vehicle_For_A_Job(self):
pass
def Change_The_System_Suggested_Optimized_Route_If_Required(self):
pass
def Confirm_A_Job(self):
pass
def Change_The_Vehicle_Allocated_For_A_Job(self):
pass
def Export_Information_Of_A_Job_To_Pdf_And_Xls_Format(self):
pass
def Indicate_That_The_Loading_Is_Completed(self):
pass
def Generate_An_Invoice_For_Each_Vehicle(self):
pass
def Generate_Vehicle_Capacity_Utilization_Report(self):
pass
def Generate_Outlet_Wise_Transport_Cost_Report_For_A_Given_Date_Range(self):
pass
def Generate_Vehicle_Turnaround_Time_Report_For_A_Warehouse(self):
pass
def Generate_Cost_Per_1_Kg_Report(self):
pass
def Generate_An_Idle_Time_Limit_Violation_Report(self):
pass
class WarehouseIncharge:
def Confirm_The_Delivered_Items_To_A_Outlet(self):
pass
def Approve_A_Job(self):
pass
def Request_A_Modification_To_The_Planned_Mileage_Of_A_Job(self):
pass
class Admin:
def Approve_The_Planned_Mileage_Modification_Request_Submitted_By_The_Warehouseincharge(self):
pass
def Modify_The_Minimum_Fix_Mileage_Configuration_For_A_Job(self):
pass
def Modify_The_Unloading_Charge(self):
pass
def Update_The_Radius_Limit_From_A_Warehouse_For___Drop_Off___Charges(self):
pass
def Set_Up_The___Drop_Off___Rate_Table_Based_On_Number_Of_Outlets_Visited(self):
pass
def Modify_The___Drop_Off___Rate_Table(self):
pass
def Edit_The_Eligibility_Criteria_For_Driver_Incentive(self):
pass
def Edit_The_Per_Km_Rate_For_An_Existing_Vehicle_Capacity_Type(self):
pass
class WarehouseOperator:
def Create_Orders_By_Uploading_A_Csv_File(self):
pass
def Make_Adjustments_To_The_Order(self):
pass
def Allocate_A_Vehicle_For_A_Job(self):
pass
def Change_The_System_Suggested_Optimized_Route_If_Required(self):
pass
def Confirm_A_Job(self):
pass
def Change_The_Vehicle_Allocated_For_A_Job(self):
pass
def Export_Information_Of_A_Job_To_Pdf_And_Xls_Format(self):
pass
def Indicate_That_The_Loading_Is_Completed(self):
pass
def Generate_An_Invoice_For_Each_Vehicle(self):
pass
def Generate_Vehicle_Capacity_Utilization_Report(self):
pass
def Generate_Outlet_Wise_Transport_Cost_Report_For_A_Given_Date_Range(self):
pass
def Generate_Vehicle_Turnaround_Time_Report_For_A_Warehouse(self):
pass
def Generate_Cost_Per_1_Kg_Report(self):
pass
def Generate_An_Idle_Time_Limit_Violation_Report(self):
pass
class WarehouseIncharge:
def Confirm_The_Delivered_Items_To_A_Outlet(self):
pass
def Approve_A_Job(self):
pass
def Request_A_Modification_To_The_Planned_Mileage_Of_A_Job(self):
pass
class Admin:
def Approve_The_Planned_Mileage_Modification_Request_Submitted_By_The_Warehouseincharge(self):
pass
def Modify_The_Minimum_Fix_Mileage_Configuration_For_A_Job(self):
pass
def Modify_The_Unloading_Charge(self):
pass
def Update_The_Radius_Limit_From_A_Warehouse_For___Drop_Off___Charges(self):
pass
def Set_Up_The___Drop_Off___Rate_Table_Based_On_Number_Of_Outlets_Visited(self):
pass
def Modify_The___Drop_Off___Rate_Table(self):
pass
def Edit_The_Eligibility_Criteria_For_Driver_Incentive(self):
pass
def Edit_The_Per_Km_Rate_For_An_Existing_Vehicle_Capacity_Type(self):
pass
class WarehouseOperator:
def create_orders_by_uploading_a_csv_file(self):
pass
def make_adjustments_to_the_order(self):
pass
def allocate_a_vehicle_for_a_job(self):
pass
def change_the_system_suggested_optimized_route_if_required(self):
pass
def confirm_a_job(self):
pass
def change_the_vehicle_allocated_for_a_job(self):
pass
def export_information_of_a_job_to_pdf_and_xls_format(self):
pass
def indicate_that_the_loading_is_completed(self):
pass
def generate_an_invoice_for_each_vehicle(self):
pass
def generate_vehicle_capacity_utilization_report(self):
pass
def generate_outlet_wise_transport_cost_report_for_a_given_date_range(self):
pass
def generate_vehicle_turnaround_time_report_for_a_warehouse(self):
pass
def generate_cost_per_1_kg_report(self):
pass
def generate_an_idle_time_limit_violation_report(self):
pass
class WarehouseIncharge:
def confirm_the_delivered_items_to_a_outlet(self):
pass
def approve_a_job(self):
pass
def request_a_modification_to_the_planned_mileage_of_a_job(self):
pass
class Admin:
def approve_the_planned_mileage_modification_request_submitted_by_the_WarehouseIncharge(self):
pass
def modify_the_minimum_fix_mileage_configuration_for_a_job(self):
pass
def modify_the_unloading_charge(self):
pass
def update_the_radius_limit_from_a_warehouse_for___drop_off___charges(self):
pass
def set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited(self):
pass
def modify_the___drop_off___rate_table(self):
pass
def edit_the_eligibility_criteria_for_driver_incentive(self):
pass
def edit_the_per_km_rate_for_an_existing_vehicle_capacity_type(self):
pass
digraph "classes_hhiiofvlqz" {
rankdir=BT
charset="utf-8"
"hhiiofvlqz.Admin" [color="black", fontcolor="black", label="{Admin|\l|approve_the_planned_mileage_modification_request_submitted_by_the_WarehouseIncharge()\ledit_the_eligibility_criteria_for_driver_incentive()\ledit_the_per_km_rate_for_an_existing_vehicle_capacity_type()\lmodify_the___drop_off___rate_table()\lmodify_the_minimum_fix_mileage_configuration_for_a_job()\lmodify_the_unloading_charge()\lset_up_the___drop_off___rate_table_based_on_number_of_outlets_visited()\lupdate_the_radius_limit_from_a_warehouse_for___drop_off___charges()\l}", shape="record", style="solid"];
"hhiiofvlqz.WarehouseIncharge" [color="black", fontcolor="black", label="{WarehouseIncharge|\l|approve_a_job()\lconfirm_the_delivered_items_to_a_outlet()\lrequest_a_modification_to_the_planned_mileage_of_a_job()\l}", shape="record", style="solid"];
"hhiiofvlqz.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|allocate_a_vehicle_for_a_job()\lchange_the_system_suggested_optimized_route_if_required()\lchange_the_vehicle_allocated_for_a_job()\lconfirm_a_job()\lcreate_orders_by_uploading_a_csv_file()\lexport_information_of_a_job_to_pdf_and_xls_format()\lgenerate_an_idle_time_limit_violation_report()\lgenerate_an_invoice_for_each_vehicle()\lgenerate_cost_per_1_kg_report()\lgenerate_outlet_wise_transport_cost_report_for_a_given_date_range()\lgenerate_vehicle_capacity_utilization_report()\lgenerate_vehicle_turnaround_time_report_for_a_warehouse()\lindicate_that_the_loading_is_completed()\lmake_adjustments_to_the_order()\l}", shape="record", style="solid"];
}
digraph "classes_lxceiajuky" {
rankdir=BT
charset="utf-8"
"lxceiajuky.Admin" [color="black", fontcolor="black", label="{Admin|\l|modify_the_minimum_fix_mileage_configuration_for_a_job()\lmodify_the_unloading_charge()\l}", shape="record", style="solid"];
"lxceiajuky.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|allocate_a_vehicle_for_a_job()\lchange_the_system_suggested_optimized_route_if_required()\lconfirm_a_job()\lcreate_orders_by_uploading_a_csv_file()\lmake_adjustments_to_the_order()\l}", shape="record", style="solid"];
}
digraph "classes_qxjyzaydlr" {
rankdir=BT
charset="utf-8"
"qxjyzaydlr.Admin" [color="black", fontcolor="black", label="{Admin|\l|check_the_payments_and_sold_items()\llogin_to_the_system()\lreply_to_Customer_feedbacks()\lview_and_manage_cart_items()\l}", shape="record", style="solid"];
}
digraph "classes_tefqjbwtro" {
rankdir=BT
charset="utf-8"
"tefqjbwtro.Admin" [color="black", fontcolor="black", label="{Admin|\l|Approve_The_Planned_Mileage_Modification_Request_Submitted_By_The_Warehouseincharge()\lEdit_The_Eligibility_Criteria_For_Driver_Incentive()\lEdit_The_Per_Km_Rate_For_An_Existing_Vehicle_Capacity_Type()\lModify_The_Minimum_Fix_Mileage_Configuration_For_A_Job()\lModify_The_Unloading_Charge()\lModify_The___Drop_Off___Rate_Table()\lSet_Up_The___Drop_Off___Rate_Table_Based_On_Number_Of_Outlets_Visited()\lUpdate_The_Radius_Limit_From_A_Warehouse_For___Drop_Off___Charges()\l}", shape="record", style="solid"];
"tefqjbwtro.WarehouseIncharge" [color="black", fontcolor="black", label="{WarehouseIncharge|\l|Approve_A_Job()\lConfirm_The_Delivered_Items_To_A_Outlet()\lRequest_A_Modification_To_The_Planned_Mileage_Of_A_Job()\l}", shape="record", style="solid"];
"tefqjbwtro.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|Allocate_A_Vehicle_For_A_Job()\lChange_The_System_Suggested_Optimized_Route_If_Required()\lChange_The_Vehicle_Allocated_For_A_Job()\lConfirm_A_Job()\lCreate_Orders_By_Uploading_A_Csv_File()\lExport_Information_Of_A_Job_To_Pdf_And_Xls_Format()\lGenerate_An_Idle_Time_Limit_Violation_Report()\lGenerate_An_Invoice_For_Each_Vehicle()\lGenerate_Cost_Per_1_Kg_Report()\lGenerate_Outlet_Wise_Transport_Cost_Report_For_A_Given_Date_Range()\lGenerate_Vehicle_Capacity_Utilization_Report()\lGenerate_Vehicle_Turnaround_Time_Report_For_A_Warehouse()\lIndicate_That_The_Loading_Is_Completed()\lMake_Adjustments_To_The_Order()\l}", shape="record", style="solid"];
}
digraph "classes_wwebavcyfa" {
rankdir=BT
charset="utf-8"
"wwebavcyfa.Admin" [color="black", fontcolor="black", label="{Admin|\l|Approve_The_Planned_Mileage_Modification_Request_Submitted_By_The_Warehouseincharge()\lEdit_The_Eligibility_Criteria_For_Driver_Incentive()\lEdit_The_Per_Km_Rate_For_An_Existing_Vehicle_Capacity_Type()\lModify_The_Minimum_Fix_Mileage_Configuration_For_A_Job()\lModify_The_Unloading_Charge()\lModify_The___Drop_Off___Rate_Table()\lSet_Up_The___Drop_Off___Rate_Table_Based_On_Number_Of_Outlets_Visited()\lUpdate_The_Radius_Limit_From_A_Warehouse_For___Drop_Off___Charges()\l}", shape="record", style="solid"];
"wwebavcyfa.WarehouseIncharge" [color="black", fontcolor="black", label="{WarehouseIncharge|\l|Approve_A_Job()\lConfirm_The_Delivered_Items_To_A_Outlet()\lRequest_A_Modification_To_The_Planned_Mileage_Of_A_Job()\l}", shape="record", style="solid"];
"wwebavcyfa.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|Allocate_A_Vehicle_For_A_Job()\lChange_The_System_Suggested_Optimized_Route_If_Required()\lChange_The_Vehicle_Allocated_For_A_Job()\lConfirm_A_Job()\lCreate_Orders_By_Uploading_A_Csv_File()\lExport_Information_Of_A_Job_To_Pdf_And_Xls_Format()\lGenerate_An_Idle_Time_Limit_Violation_Report()\lGenerate_An_Invoice_For_Each_Vehicle()\lGenerate_Cost_Per_1_Kg_Report()\lGenerate_Outlet_Wise_Transport_Cost_Report_For_A_Given_Date_Range()\lGenerate_Vehicle_Capacity_Utilization_Report()\lGenerate_Vehicle_Turnaround_Time_Report_For_A_Warehouse()\lIndicate_That_The_Loading_Is_Completed()\lMake_Adjustments_To_The_Order()\l}", shape="record", style="solid"];
}
digraph "classes_xgxiplwygn" {
rankdir=BT
charset="utf-8"
"xgxiplwygn.Admin" [color="black", fontcolor="black", label="{Admin|\l|approve_the_planned_mileage_modification_request_submitted_by_the_WarehouseIncharge()\ledit_the_eligibility_criteria_for_driver_incentive()\ledit_the_per_km_rate_for_an_existing_vehicle_capacity_type()\lmodify_the___drop_off___rate_table()\lmodify_the_minimum_fix_mileage_configuration_for_a_job()\lmodify_the_unloading_charge()\lset_up_the___drop_off___rate_table_based_on_number_of_outlets_visited()\lupdate_the_radius_limit_from_a_warehouse_for___drop_off___charges()\l}", shape="record", style="solid"];
"xgxiplwygn.WarehouseIncharge" [color="black", fontcolor="black", label="{WarehouseIncharge|\l|approve_a_job()\lconfirm_the_delivered_items_to_a_outlet()\lrequest_a_modification_to_the_planned_mileage_of_a_job()\l}", shape="record", style="solid"];
"xgxiplwygn.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|allocate_a_vehicle_for_a_job()\lchange_the_system_suggested_optimized_route_if_required()\lchange_the_vehicle_allocated_for_a_job()\lconfirm_a_job()\lcreate_orders_by_uploading_a_csv_file()\lexport_information_of_a_job_to_pdf_and_xls_format()\lgenerate_an_idle_time_limit_violation_report()\lgenerate_an_invoice_for_each_vehicle()\lgenerate_cost_per_1_kg_report()\lgenerate_outlet_wise_transport_cost_report_for_a_given_date_range()\lgenerate_vehicle_capacity_utilization_report()\lgenerate_vehicle_turnaround_time_report_for_a_warehouse()\lindicate_that_the_loading_is_completed()\lmake_adjustments_to_the_order()\l}", shape="record", style="solid"];
}
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph WarehouseOperator {label="WarehouseOperator"; warehouseoperator};
warehouseoperator [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph WarehouseIncharge {label="WarehouseIncharge"; warehouseincharge};
warehouseincharge [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph Admin {label="Admin"; admin};
admin [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
sign_up_to_the_system [label="Sign Up To The System"];
sign_in_to_the_system [label="Sign In To The System"];
create_orders_by_uploading_a_csv_file [label="Create Orders By Uploading A Csv File"];
make_adjustments_to_the_order [label="Make Adjustments To The Order"];
allocate_a_vehicle_for_a_job [label="Allocate A Vehicle For A Job"];
change_the_system_suggested_optimized_route_if_required [label="Change The System Suggested Optimized Route If Required"];
confirm_a_job [label="Confirm A Job"];
change_the_vehicle_allocated_for_a_job [label="Change The Vehicle Allocated For A Job"];
export_information_of_a_job_to_pdf_and_xls_format [label="Export Information Of A Job To Pdf And Xls Format"];
indicate_that_the_loading_is_completed [label="Indicate That The Loading Is Completed"];
confirm_the_delivered_items_to_a_outlet [label="Confirm The Delivered Items To A Outlet"];
approve_a_job [label="Approve A Job"];
request_a_modification_to_the_planned_mileage_of_a_job [label="Request A Modification To The Planned Mileage Of A Job"];
approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge [label="Approve The Planned Mileage Modification Request Submitted By The Warehouseincharge"];
generate_an_invoice_for_each_vehicle [label="Generate An Invoice For Each Vehicle"];
modify_the_minimum_fix_mileage_configuration_for_a_job [label="Modify The Minimum Fix Mileage Configuration For A Job"];
modify_the_unloading_charge [label="Modify The Unloading Charge"];
update_the_radius_limit_from_a_warehouse_for___drop_off___charges [label="Update The Radius Limit From A Warehouse For Drop Off Charges"];
set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited [label="Set Up The Drop Off Rate Table Based On Number Of Outlets Visited"];
modify_the___drop_off___rate_table [label="Modify The Drop Off Rate Table"];
edit_the_eligibility_criteria_for_driver_incentive [label="Edit The Eligibility Criteria For Driver Incentive"];
edit_the_per_km_rate_for_an_existing_vehicle_capacity_type [label="Edit The Per Km Rate For An Existing Vehicle Capacity Type"];
generate_vehicle_capacity_utilization_report [label="Generate Vehicle Capacity Utilization Report"];
generate_outlet_wise_transport_cost_report_for_a_given_date_range [label="Generate Outlet Wise Transport Cost Report For A Given Date Range"];
generate_vehicle_turnaround_time_report_for_a_warehouse [label="Generate Vehicle Turnaround Time Report For A Warehouse"];
generate_cost_per_1_kg_report [label="Generate Cost Per 1 Kg Report"];
generate_an_idle_time_limit_violation_report [label="Generate An Idle Time Limit Violation Report"];
edge [arrowhead="none"];
theuser->sign_up_to_the_system;
theuser->sign_in_to_the_system;
warehouseoperator->create_orders_by_uploading_a_csv_file;
warehouseoperator->make_adjustments_to_the_order;
warehouseoperator->allocate_a_vehicle_for_a_job;
warehouseoperator->change_the_system_suggested_optimized_route_if_required;
warehouseoperator->confirm_a_job;
warehouseoperator->change_the_vehicle_allocated_for_a_job;
warehouseoperator->export_information_of_a_job_to_pdf_and_xls_format;
warehouseoperator->indicate_that_the_loading_is_completed;
warehouseincharge->confirm_the_delivered_items_to_a_outlet;
warehouseincharge->approve_a_job;
warehouseincharge->request_a_modification_to_the_planned_mileage_of_a_job;
admin->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
warehouseoperator->generate_an_invoice_for_each_vehicle;
admin->modify_the_minimum_fix_mileage_configuration_for_a_job;
admin->modify_the_unloading_charge;
admin->update_the_radius_limit_from_a_warehouse_for___drop_off___charges;
admin->set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited;
admin->modify_the___drop_off___rate_table;
admin->edit_the_eligibility_criteria_for_driver_incentive;
admin->edit_the_per_km_rate_for_an_existing_vehicle_capacity_type;
warehouseoperator->generate_vehicle_capacity_utilization_report;
warehouseoperator->generate_outlet_wise_transport_cost_report_for_a_given_date_range;
warehouseoperator->generate_vehicle_turnaround_time_report_for_a_warehouse;
warehouseoperator->generate_cost_per_1_kg_report;
warehouseoperator->generate_an_idle_time_limit_violation_report;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
create_orders_by_uploading_a_csv_file->make_adjustments_to_the_order;
confirm_a_job->change_the_vehicle_allocated_for_a_job_change_the_system_suggested_optimized_route_if_required;
edge [arrowtail="vee", label="<<include>>", style=dashed];
confirm_a_job->allocate_a_vehicle_for_a_job;
approve_a_job->confirm_the_delivered_items_to_a_outlet;
request_a_modification_to_the_planned_mileage_of_a_job->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
}
\ No newline at end of file
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph Admin {label="Admin"; admin};
admin [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
login_to_the_system [label="Login To The System"];
check_the_home_page [label="Check The Home Page"];
play_the_site_demo_video [label="Play The Site Demo Video"];
add_items_to_the_cart [label="Add Items To The Cart"];
pay_the_items [label="Pay The Items"];
give_a_feedback_for_the_system [label="Give A Feedback For The System"];
view_the_seller_details [label="View The Seller Details"];
contact_the_seller_to_request_more_items [label="Contact The Seller To Request More Items"];
login_to_the_system [label="Login To The System"];
view_and_manage_cart_items [label="View And Manage Cart Items"];
check_the_payments_and_sold_items [label="Check The Payments And Sold Items"];
reply_to_customer_feedbacks [label="Reply To Customer Feedbacks"];
edge [arrowhead="none"];
customer->login_to_the_system;
customer->check_the_home_page;
customer->play_the_site_demo_video;
customer->add_items_to_the_cart;
customer->pay_the_items;
customer->give_a_feedback_for_the_system;
customer->view_the_seller_details;
customer->contact_the_seller_to_request_more_items;
admin->login_to_the_system;
admin->view_and_manage_cart_items;
admin->check_the_payments_and_sold_items;
admin->reply_to_customer_feedbacks;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
give_a_feedback_for_the_system->rate_the_service;
edge [arrowtail="vee", label="<<include>>", style=dashed];
pay_the_items->recieve_the_confirmation_email;
}
\ No newline at end of file
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph WarehouseOperator {label="WarehouseOperator"; warehouseoperator};
warehouseoperator [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph WarehouseIncharge {label="WarehouseIncharge"; warehouseincharge};
warehouseincharge [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph Admin {label="Admin"; admin};
admin [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
sign_up_to_the_system [label="Sign Up To The System"];
sign_in_to_the_system [label="Sign In To The System"];
create_orders_by_uploading_a_csv_file [label="Create Orders By Uploading A Csv File"];
make_adjustments_to_the_order [label="Make Adjustments To The Order"];
allocate_a_vehicle_for_a_job [label="Allocate A Vehicle For A Job"];
change_the_system_suggested_optimized_route_if_required [label="Change The System Suggested Optimized Route If Required"];
confirm_a_job [label="Confirm A Job"];
change_the_vehicle_allocated_for_a_job [label="Change The Vehicle Allocated For A Job"];
export_information_of_a_job_to_pdf_and_xls_format [label="Export Information Of A Job To Pdf And Xls Format"];
indicate_that_the_loading_is_completed [label="Indicate That The Loading Is Completed"];
confirm_the_delivered_items_to_a_outlet [label="Confirm The Delivered Items To A Outlet"];
approve_a_job [label="Approve A Job"];
request_a_modification_to_the_planned_mileage_of_a_job [label="Request A Modification To The Planned Mileage Of A Job"];
approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge [label="Approve The Planned Mileage Modification Request Submitted By The Warehouseincharge"];
generate_an_invoice_for_each_vehicle [label="Generate An Invoice For Each Vehicle"];
modify_the_minimum_fix_mileage_configuration_for_a_job [label="Modify The Minimum Fix Mileage Configuration For A Job"];
modify_the_unloading_charge [label="Modify The Unloading Charge"];
update_the_radius_limit_from_a_warehouse_for___drop_off___charges [label="Update The Radius Limit From A Warehouse For Drop Off Charges"];
set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited [label="Set Up The Drop Off Rate Table Based On Number Of Outlets Visited"];
modify_the___drop_off___rate_table [label="Modify The Drop Off Rate Table"];
edit_the_eligibility_criteria_for_driver_incentive [label="Edit The Eligibility Criteria For Driver Incentive"];
edit_the_per_km_rate_for_an_existing_vehicle_capacity_type [label="Edit The Per Km Rate For An Existing Vehicle Capacity Type"];
generate_vehicle_capacity_utilization_report [label="Generate Vehicle Capacity Utilization Report"];
generate_outlet_wise_transport_cost_report_for_a_given_date_range [label="Generate Outlet Wise Transport Cost Report For A Given Date Range"];
generate_vehicle_turnaround_time_report_for_a_warehouse [label="Generate Vehicle Turnaround Time Report For A Warehouse"];
generate_cost_per_1_kg_report [label="Generate Cost Per 1 Kg Report"];
generate_an_idle_time_limit_violation_report [label="Generate An Idle Time Limit Violation Report"];
edge [arrowhead="none"];
theuser->sign_up_to_the_system;
theuser->sign_in_to_the_system;
warehouseoperator->create_orders_by_uploading_a_csv_file;
warehouseoperator->make_adjustments_to_the_order;
warehouseoperator->allocate_a_vehicle_for_a_job;
warehouseoperator->change_the_system_suggested_optimized_route_if_required;
warehouseoperator->confirm_a_job;
warehouseoperator->change_the_vehicle_allocated_for_a_job;
warehouseoperator->export_information_of_a_job_to_pdf_and_xls_format;
warehouseoperator->indicate_that_the_loading_is_completed;
warehouseincharge->confirm_the_delivered_items_to_a_outlet;
warehouseincharge->approve_a_job;
warehouseincharge->request_a_modification_to_the_planned_mileage_of_a_job;
admin->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
warehouseoperator->generate_an_invoice_for_each_vehicle;
admin->modify_the_minimum_fix_mileage_configuration_for_a_job;
admin->modify_the_unloading_charge;
admin->update_the_radius_limit_from_a_warehouse_for___drop_off___charges;
admin->set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited;
admin->modify_the___drop_off___rate_table;
admin->edit_the_eligibility_criteria_for_driver_incentive;
admin->edit_the_per_km_rate_for_an_existing_vehicle_capacity_type;
warehouseoperator->generate_vehicle_capacity_utilization_report;
warehouseoperator->generate_outlet_wise_transport_cost_report_for_a_given_date_range;
warehouseoperator->generate_vehicle_turnaround_time_report_for_a_warehouse;
warehouseoperator->generate_cost_per_1_kg_report;
warehouseoperator->generate_an_idle_time_limit_violation_report;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
create_orders_by_uploading_a_csv_file->make_adjustments_to_the_order;
confirm_a_job->change_the_vehicle_allocated_for_a_job_change_the_system_suggested_optimized_route_if_required;
edge [arrowtail="vee", label="<<include>>", style=dashed];
confirm_a_job->allocate_a_vehicle_for_a_job;
approve_a_job->confirm_the_delivered_items_to_a_outlet;
request_a_modification_to_the_planned_mileage_of_a_job->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
}
\ No newline at end of file
......@@ -8,30 +8,71 @@ digraph G {
subgraph WarehouseOperator {label="WarehouseOperator"; warehouseoperator};
warehouseoperator [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph WarehouseIncharge {label="WarehouseIncharge"; warehouseincharge};
warehouseincharge [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
subgraph Admin {label="Admin"; admin};
admin [image="D:\SLIIT\Year 4\Research Project\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
sign_up_to_the_system [label="Sign Up To The System"];
sign_in_to_the_system [label="Sign In To The System"];
create_orders_by_uploading_a_csv_file [label="Create Orders By Uploading A Csv File"];
make_adjustments_to_the_order [label="Make Adjustments To The Order"];
allocate_a_vehicle_for_a_job [label="Allocate A Vehicle For A Job"];
change_the_system_suggested_optimized_route_if_required [label="Change The System Suggested Optimized Route If Required"];
confirm_a_job [label="Confirm A Job"];
change_the_vehicle_allocated_for_a_job [label="Change The Vehicle Allocated For A Job"];
export_information_of_a_job_to_pdf_and_xls_format [label="Export Information Of A Job To Pdf And Xls Format"];
indicate_that_the_loading_is_completed [label="Indicate That The Loading Is Completed"];
confirm_the_delivered_items_to_a_outlet [label="Confirm The Delivered Items To A Outlet"];
approve_a_job [label="Approve A Job"];
request_a_modification_to_the_planned_mileage_of_a_job [label="Request A Modification To The Planned Mileage Of A Job"];
approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge [label="Approve The Planned Mileage Modification Request Submitted By The Warehouseincharge"];
generate_an_invoice_for_each_vehicle [label="Generate An Invoice For Each Vehicle"];
modify_the_minimum_fix_mileage_configuration_for_a_job [label="Modify The Minimum Fix Mileage Configuration For A Job"];
modify_the_unloading_charge [label="Modify The Unloading Charge"];
update_the_radius_limit_from_a_warehouse_for___drop_off___charges [label="Update The Radius Limit From A Warehouse For Drop Off Charges"];
set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited [label="Set Up The Drop Off Rate Table Based On Number Of Outlets Visited"];
modify_the___drop_off___rate_table [label="Modify The Drop Off Rate Table"];
edit_the_eligibility_criteria_for_driver_incentive [label="Edit The Eligibility Criteria For Driver Incentive"];
edit_the_per_km_rate_for_an_existing_vehicle_capacity_type [label="Edit The Per Km Rate For An Existing Vehicle Capacity Type"];
generate_vehicle_capacity_utilization_report [label="Generate Vehicle Capacity Utilization Report"];
generate_outlet_wise_transport_cost_report_for_a_given_date_range [label="Generate Outlet Wise Transport Cost Report For A Given Date Range"];
generate_vehicle_turnaround_time_report_for_a_warehouse [label="Generate Vehicle Turnaround Time Report For A Warehouse"];
generate_cost_per_1_kg_report [label="Generate Cost Per 1 Kg Report"];
generate_an_idle_time_limit_violation_report [label="Generate An Idle Time Limit Violation Report"];
edge [arrowhead="none"];
user->sign_up_to_the_system;
user->sign_in_to_the_system;
warehouseoperator->create_orders_by_uploading_a_csv_file;
warehouseoperator->make_adjustments_to_the_order;
warehouseoperator->allocate_a_vehicle_for_a_job;
warehouseoperator->change_the_system_suggested_optimized_route_if_required;
warehouseoperator->confirm_a_job;
warehouseoperator->change_the_vehicle_allocated_for_a_job;
warehouseoperator->export_information_of_a_job_to_pdf_and_xls_format;
warehouseoperator->indicate_that_the_loading_is_completed;
warehouseincharge->confirm_the_delivered_items_to_a_outlet;
warehouseincharge->approve_a_job;
warehouseincharge->request_a_modification_to_the_planned_mileage_of_a_job;
admin->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
warehouseoperator->generate_an_invoice_for_each_vehicle;
admin->modify_the_minimum_fix_mileage_configuration_for_a_job;
admin->modify_the_unloading_charge;
admin->update_the_radius_limit_from_a_warehouse_for___drop_off___charges;
admin->set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited;
admin->modify_the___drop_off___rate_table;
admin->edit_the_eligibility_criteria_for_driver_incentive;
admin->edit_the_per_km_rate_for_an_existing_vehicle_capacity_type;
warehouseoperator->generate_vehicle_capacity_utilization_report;
warehouseoperator->generate_outlet_wise_transport_cost_report_for_a_given_date_range;
warehouseoperator->generate_vehicle_turnaround_time_report_for_a_warehouse;
warehouseoperator->generate_cost_per_1_kg_report;
warehouseoperator->generate_an_idle_time_limit_violation_report;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
......@@ -41,5 +82,7 @@ digraph G {
edge [arrowtail="vee", label="<<include>>", style=dashed];
confirm_a_job->allocate_a_vehicle_for_a_job;
approve_a_job->confirm_the_delivered_items_to_a_outlet;
request_a_modification_to_the_planned_mileage_of_a_job->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
}
\ No newline at end of file
import requests
from flask import Blueprint, jsonify, request
from constants.http_status_codes_constant import HTTP_200_OK, HTTP_400_BAD_REQUEST, HTTP_201_CREATED, HTTP_500_INTERNAL_SERVER_ERROR
from constants.http_status_codes_constant import HTTP_200_OK, HTTP_400_BAD_REQUEST, HTTP_201_CREATED, \
HTTP_500_INTERNAL_SERVER_ERROR
from config.database import db
from datetime import datetime
from models.assignment_model import Assignment
from models.module_model import Module
assignment = Blueprint('assignments', __name__, url_prefix='/api/v1/assignments')
@assignment.post('/create')
def create_assignment():
title = request.json.get('title', '')
content = request.json.get('content', '')
module_id = request.json.get('module_id', '')
assignment_type = request.json.get('assignment_type', '')
plagiarism_percentage = request.json.get('plagiarism_percentage', '')
start_at = datetime.strptime(request.json.get('start_at', ''), '%Y-%m-%d %H:%M:%S')
end_at = datetime.strptime(request.json.get('end_at', ''), '%Y-%m-%d %H:%M:%S')
......@@ -19,20 +23,25 @@ def create_assignment():
if not content or not module_id or not plagiarism_percentage or not start_at or not end_at:
return jsonify({'err': 'Missing assignment details'}), HTTP_400_BAD_REQUEST
assignment_obj = Assignment(content=content,
assignment_obj = Assignment(title=title, content=content,
module_id=module_id,
plagiarism_percentage=plagiarism_percentage,
assignment_type=assignment_type,
start_at=start_at,
end_at=end_at)
db.session.add(assignment_obj)
db.session.commit()
response = requests.post(url="http://127.0.0.1:5000/api/v1/diagrams/generate", json={"scenario": content, "assignment_id": assignment_obj.id})
response = requests.post(url="http://127.0.0.1:5000/api/v1/diagrams/generate",
json={"scenario": content, "assignment_id": assignment_obj.id, "assignment_type": assignment_obj.assignment_type})
print(response.content)
if response.ok:
return jsonify({'msg': 'Assignment created', 'assignment': {
'id': assignment_obj.id,
'title': assignment_obj.title,
'content': assignment_obj.content,
'assignment_type': assignment_obj.assignment_type,
'module_id': assignment_obj.module_id,
'plagiarism_percentage': assignment_obj.plagiarism_percentage,
'start_at': assignment_obj.start_at,
......@@ -46,6 +55,22 @@ def create_assignment():
return jsonify({'err': 'Something went wrong while generating model answers'}), HTTP_500_INTERNAL_SERVER_ERROR
@assignment.get('/')
def get_assignments():
assignment_obj = db.session.query(Assignment, Module).join(Module).all()
assignments = []
for assignment, module in assignment_obj:
assignments.append(
{"id": assignment.id, "title": assignment.title, "module_id": assignment.module_id, "code": module.code, "name": module.name, "start_at": assignment.start_at, "end_at": assignment.end_at, 'assignment_type': assignment.assignment_type,
"created_at": assignment.created_at, "updated_at": assignment.updated_at})
if assignment_obj is None:
return jsonify({'err': "Assignments does not exist"}), HTTP_400_BAD_REQUEST
return jsonify({'msg': 'Assignments found', 'assignments': assignments}), HTTP_200_OK
@assignment.get('/<assignment_id>')
def get_assignment(assignment_id):
if not assignment_id:
......@@ -58,7 +83,9 @@ def get_assignment(assignment_id):
return jsonify({'msg': 'Assignment found', 'assignment': {
'id': assignment_obj.id,
"title": assignment_obj.title,
'content': assignment_obj.content,
'assignment_type': assignment_obj.assignment_type,
'module_id': assignment_obj.module_id,
'plagiarism_percentage': assignment_obj.plagiarism_percentage,
'start_at': assignment_obj.start_at,
......@@ -81,7 +108,9 @@ def delete_assignment(assignment_id):
return jsonify({'msg': 'Assignment deleted', 'assignment': {
'id': assignment_obj.id,
"title": assignment_obj.title,
'content': assignment_obj.content,
'assignment_type': assignment_obj.assignment_type,
'module_id': assignment_obj.module_id,
'plagiarism_percentage': assignment_obj.plagiarism_percentage,
'start_at': assignment_obj.start_at,
......@@ -92,7 +121,9 @@ def delete_assignment(assignment_id):
@assignment.patch('/<assignment_id>')
def update_assignment(assignment_id):
content = request.json.get('content', '')
title = request.json.get('title', '')
module_id = request.json.get('module_id', '')
assignment_type = request.json.get('assignment_type', '')
plagiarism_percentage = request.json.get('plagiarism_percentage', '')
start_at = datetime.strptime(request.json.get('start_at', ''), '%Y-%m-%d %H:%M:%S')
end_at = datetime.strptime(request.json.get('end_at', ''), '%Y-%m-%d %H:%M:%S')
......@@ -106,11 +137,14 @@ def update_assignment(assignment_id):
assignment_obj.plagiarism_percentage = plagiarism_percentage
assignment_obj.start_at = start_at
assignment_obj.end_at = end_at
assignment_obj.assignment_type = assignment_type
db.session.commit()
return jsonify({'msg': 'Assignment updated', 'assignment': {
'id': assignment_obj.id,
"title": assignment_obj.title,
'content': assignment_obj.content,
'assignment_type': assignment_obj.assignment_type,
'module_id': assignment_obj.module_id,
'plagiarism_percentage': assignment_obj.plagiarism_percentage,
'start_at': assignment_obj.start_at,
......
......@@ -12,30 +12,57 @@ diagram = Blueprint('diagrams', __name__, url_prefix='/api/v1/diagrams')
@diagram.post('/generate')
def generate_diagrams():
try:
generated_usecase_diagram_path = None
generated_class_diagram_path = None
data = request.get_json(silent=True)
if data is None:
return jsonify('Please attach a scenario file'), HTTP_400_BAD_REQUEST
generated_class_diagram_path, generated_usecase_diagram_path = services.question_preprocess_service.main(
data['scenario'])
return jsonify('Please attach assignment details'), HTTP_400_BAD_REQUEST
if generated_usecase_diagram_path or generated_usecase_diagram_path:
if data['assignment_type'] == 1:
generated_usecase_diagram_path = services.question_preprocess_service.main(
data['scenario'], data['assignment_type'])
diagram_obj = Diagram(assignment_id=data['assignment_id'],
usecase_diagram_path=generated_usecase_diagram_path,
class_diagram_path=None)
elif data['assignment_type'] == 2:
generated_class_diagram_path = services.question_preprocess_service.main(
data['scenario'], data['assignment_type'])
diagram_obj = Diagram(assignment_id=data['assignment_id'],
usecase_diagram_path=None,
class_diagram_path=generated_class_diagram_path)
db.session.add(diagram_obj)
db.session.commit()
elif data['assignment_type'] == 3:
print(data['assignment_type'])
generated_class_diagram_path, generated_usecase_diagram_path = services.question_preprocess_service.main(
data['scenario'], data['assignment_type'])
diagram_obj = Diagram(assignment_id=data['assignment_id'],
usecase_diagram_path=generated_usecase_diagram_path,
class_diagram_path=generated_class_diagram_path)
else:
return jsonify('Something went wrong'), HTTP_500_INTERNAL_SERVER_ERROR
return jsonify(generated_class_diagram_path=generated_class_diagram_path,
generated_usecase_diagram_path=generated_usecase_diagram_path), HTTP_200_OK
db.session.add(diagram_obj)
db.session.commit()
if data['assignment_type'] == 1:
return jsonify(
generated_usecase_diagram_path=generated_usecase_diagram_path), HTTP_200_OK
elif data['assignment_type'] == 2:
return jsonify(generated_class_diagram_path=generated_class_diagram_path,
), HTTP_200_OK
elif data['assignment_type'] == 3:
return jsonify(generated_class_diagram_path=generated_class_diagram_path,
generated_usecase_diagram_path=generated_usecase_diagram_path), HTTP_200_OK
else:
return jsonify('Something went wrong'), HTTP_500_INTERNAL_SERVER_ERROR
except Exception or BadRequestKeyError:
if BadRequestKeyError:
return jsonify('Please attach a scenario file'), HTTP_400_BAD_REQUEST
return jsonify('Please attach assignment details'), HTTP_400_BAD_REQUEST
return jsonify('Something went wrong'), HTTP_500_INTERNAL_SERVER_ERROR
......@@ -46,4 +73,5 @@ def get_diagrams(assignment_id):
if diagram_obj is None:
return jsonify({"err": "No diagram found"}, HTTP_404_NOT_FOUND)
return jsonify({'msg': 'Diagrams found', 'diagrams': {'class_diagram': diagram_obj.class_diagram_path, 'usecase_diagram': diagram_obj.usecase_diagram_path}}), HTTP_200_OK
return jsonify({'msg': 'Diagrams found', 'diagrams': {'class_diagram': diagram_obj.class_diagram_path,
'usecase_diagram': diagram_obj.usecase_diagram_path}}), HTTP_200_OK
......@@ -25,6 +25,20 @@ def create_module():
}}), HTTP_201_CREATED
@module.get('/')
def get_modules():
module_obj = Module.query.all()
modules = []
for module in module_obj:
modules.append({"id": module.id, "name": module.name, "code": module.code, "created_at": module.created_at, "updated_at": module.updated_at})
if module_obj is None:
return jsonify({'err': "Module does not exist"}), HTTP_400_BAD_REQUEST
return jsonify({'msg': 'Module found', 'modules': modules}), HTTP_200_OK
@module.get('/<module_id>')
def get_module(module_id):
if not module_id:
......@@ -33,9 +47,9 @@ def get_module(module_id):
module_obj = Module.query.filter_by(id=module_id).first()
if module_obj is None:
return jsonify({'err': "Module does not exist"}), HTTP_400_BAD_REQUEST
return jsonify({'err': "Modules does not exist"}), HTTP_400_BAD_REQUEST
return jsonify({'msg': 'Module found', 'module': {
return jsonify({'msg': 'Modules found', 'module': {
'name': module_obj.name,
'code': module_obj.code,
'created_at': module_obj.created_at,
......
......@@ -4,6 +4,9 @@ from flask import request, jsonify, Blueprint
from flask_jwt_extended import jwt_required, get_jwt_identity
from constants.http_status_codes_constant import HTTP_400_BAD_REQUEST, HTTP_200_OK
from services.class_model_detection_service import component_separation
from models.actor_and_use_case import ActorANDUseCase
from services.submission_service import save_submission
from services.use_case_model_detection_service import model_object_detection
......@@ -27,9 +30,10 @@ def upload_submission():
use_case_obj = save_submission(assignment_id, image, submission_type, comment, user_id)
model_object_detection(image.filename, use_case_obj.id)
return jsonify({'message': 'upload successful '}), HTTP_200_OK
elif submission_type == 'class':
class_obj = save_submission(assignment_id, image, submission_type, comment, user_id)
# model_object_detection(image.filename, class_obj.id)
component_separation(image.filename, class_obj.id)
return jsonify({'id': str(class_obj.id)}), HTTP_200_OK
else:
return jsonify({'err': 'invalid request '}), HTTP_400_BAD_REQUEST
import operator
import cv2
import numpy as np
import pytesseract as ts
from PIL import Image
from models.attribute_model import Attribute
from object_detection.utils import label_map_util
import matplotlib.pyplot as plt
import app
import tensorflow as tf
import spacy
from config.database import db
from models.class_component_model import Component
from models.class_relationship_model import Relationship
from models.class_relationship_muplicity import Multiplicity
from models.method_model import Method
from services.class_relationship_relativity_service import detect_class_relationship
ts.pytesseract.tesseract_cmd = r'C:\Users\DELL\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'
def component_separation(filename, class_comp_id):
mdl1_path = app.CLASS_SAVED_MODEL_PATH
lbl1_path = app.CLASS_SAVED_LABEL_PATH
img1_path = app.SUBMISSION_PATH_CLASS + '/' + filename
image_nparray = np.array(Image.open(img1_path))
# print(img1_path)
boxes, accurate_indexes, category_index, class_id = class_object_detection(mdl1_path,
lbl1_path,
image_nparray)
for index in range(0, len(accurate_indexes)):
# Convert the class id in their name
if len(accurate_indexes) > 1:
category = category_index[class_id[index]]['name']
elif len(accurate_indexes) == 1:
category = category_index[class_id]['name']
# print(category)
# select the component type and provide method to detect further details
if category == 'class':
# print(filename, 'class')
class_details_detection(image_nparray, boxes, index, class_comp_id, category)
elif category == 'interface':
# print(filename, 'interface')
class_details_detection(image_nparray, boxes, index, class_comp_id, category)
else:
# print(filename, 'relationship')
detect_class_relationship(image_nparray, boxes, index, class_comp_id, category)
# relationship_details_detection(image_nparray, boxes, index, class_comp_id, category)
def class_object_detection(model_path, label_path, image_nparray):
detect_fn = tf.saved_model.load(model_path)
category_index = label_map_util.create_category_index_from_labelmap(label_path, use_display_name=True)
image_np = image_nparray
input_tensor = tf.convert_to_tensor(image_np)
input_tensor = input_tensor[tf.newaxis, ...]
detections = detect_fn(input_tensor)
num_detections = int(detections.pop('num_detections'))
detections = {key: value[0, :num_detections].numpy()
for key, value in detections.items()}
detections['num_detections'] = num_detections
detections['detection_classes'] = detections['detection_classes'].astype(np.int64)
accurate_indexes = [k for k, v in enumerate(detections['detection_scores']) if (v > 0.8)]
class_id = operator.itemgetter(*accurate_indexes)(detections['detection_classes'])
boxes = detections['detection_boxes']
return boxes, accurate_indexes, category_index, class_id
def class_details_detection(image_nparray, boxes, index, class_comp_id, class_type):
methods_attributes = []
_image, cl_ymin, cl_xmin, cl_ymax, cl_xmax = crop_image_(image_nparray, boxes, index)
# cv2.imwrite('image_1.jpg', _image)
mdl2_path = app.CLASS_COMP_SAVED_MODEL_PATH
lbl2_path = app.CLASS_COMP_SAVED_LABEL_PATH
boxes_class, accurate_indexes, category_index, class_id = class_object_detection(
mdl2_path, lbl2_path, _image)
for j in range(0, len(accurate_indexes)):
if len(accurate_indexes) > 1:
category = category_index[class_id[j]]['name']
else:
category = category_index[class_id]['name']
# print(category)
if category == 'class_attributes':
# print(category, 'line 96 - inside attributes')
class_attributes, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j)
class_attributes = cv2.resize(class_attributes, None, fx=2, fy=2)
# cv2.imwrite('image.jpg', class_attributes)
text = text_extraction(class_attributes)
attr = save_attributes_methods(text, 'attribute')
methods_attributes.append(attr)
elif category == 'class_methods':
# print(category, 'line 103 - inside methods')
class_methods, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j)
class_methods = cv2.resize(class_methods, None, fx=2, fy=2)
text = text_extraction(class_methods)
methods = save_attributes_methods(text, 'method')
methods_attributes.append(methods)
# print(text, '111 line')
comp_name = class_name_detection(_image, boxes_class, category_index, accurate_indexes, class_id)
# print(comp_name, 'comp_name line 118')
comp = save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id)
# print(comp, 'component_id line 120')
alter_attributes_methods(methods_attributes, comp.id)
# crop image using boxes & index
def crop_image_(image, boxes, index):
height, width, c = image.shape
# crop box format: xmin, ymin, xmax, ymax
ymin = boxes[index][0] * height
xmin = boxes[index][1] * width
ymax = boxes[index][2] * height
xmax = boxes[index][3] * width
cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)]
# image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
# image = cv2.resize(image, (800, 500))
# returns cropped image , ymin,xmin,ymax & xmax
return cropped_image, ymin, xmin, ymax, xmax
# extract text from provided image
def text_extraction(image):
config = '-l eng --oem 1 --psm 4'
text = ts.image_to_string(image, config=config)
text = text.splitlines()
text = [x.strip(' ') for x in text]
text = list(filter(None, text))
return text
# save attributes and methods in database
def save_attributes_methods(text, typ):
saved_data = []
nlp = spacy.load('en_core_web_sm')
for element in text:
# print(element, 'line 145')
# removable = str.maketrans('', '', '()')
nlp_ner = spacy.load('ner_models/model-best')
nlp_output = nlp_ner(element)
attr = Attribute()
method = Method()
for token in nlp_output.ents:
if typ == 'attribute':
if token.label_ == 'ATTRIBUTE_NAME':
attr.name = token.text
elif token.label_ == 'ACCESS_SP':
attr.access_spec = covert_to_access_specifier(token.text)
elif token.label_ == 'DATA_TYPE':
attr.data_type = token.text
elif typ == 'method':
if token.label_ == 'METHOD_NAME':
method.name = token.text
elif token.label_ == 'ACCESS_SP':
method.access_spec = covert_to_access_specifier(token.text)
elif token.label_ == 'DATA_TYPE':
method.return_type = token.text
if typ == 'attribute':
# print(attr, 'line 175 - attr')
db.session.add(attr)
db.session.commit()
saved_data.append(attr)
else:
# print(method, 'line 181 method')
db.session.add(method)
db.session.commit()
saved_data.append(method)
return saved_data
# update attributes and methods with relevant class id
def alter_attributes_methods(element_list, component_id):
for j in element_list:
for element in j:
# print(component_id)
# print(element_list)
element.class_id = component_id
db.session.commit()
# convert symbol access specifier to string
def covert_to_access_specifier(access):
if access == "-":
return "Private"
elif access == "#":
return "Protected"
if access == "+":
return "Public"
elif access == "~":
return "Package"
else:
return ''
def class_name_detection(image, boxes, category_index, accurate_indexes, class_id):
# print(category_index, 'category_index')
# print(class_id, 'class_id')
height, width, c = image.shape
for i in range(0, len(accurate_indexes)):
if len(accurate_indexes) > 1:
category = category_index[class_id[i]]['name']
# print(category, '225 line')
else:
category = category_index[class_id]['name']
# print(category, '225 line')
if category != 'interface_name' or category != 'class_name':
ymin = boxes[i][0] * height
xmin = boxes[i][1] * width
ymax = boxes[i][2] * height
xmax = boxes[i][3] * width
cv2.rectangle(image, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (255, 255, 255), -1)
# cv2.imwrite('image_2.jpg', image)
class_name = text_extraction(image)
# print(class_name, 'line 249 class name')
if ''.join(class_name) is not None:
# print(class_name, 'line 251 class name')
if "interface" in ''.join(class_name):
name = ''.join(class_name).replace("<<interface>>", "")
else:
name = ''.join(class_name)
return name
def save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id):
comp = Component(class_answer=class_comp_id, name=comp_name, type=class_type, x_min=cl_xmin, y_min=cl_ymin,
x_max=cl_xmax,
y_max=cl_ymax)
db.session.add(comp)
db.session.commit()
# print(comp, 'line 261 comp')
return comp
......@@ -4,7 +4,7 @@ import re
import cv2
import numpy as np
import pytesseract as pytesseract
import pytesseract as ts
from PIL import Image
from models.attribute_model import Attribute
......@@ -18,7 +18,7 @@ from config.database import db
from models.component_model import Component
from models.method_model import Method
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
ts.pytesseract.tesseract_cmd = r'C:\Users\DELL\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'
def component_separation(filename, class_comp_id):
......
import math
from decimal import Decimal
import cv2
import keras_ocr
import numpy as np
import spacy
from paddleocr import PaddleOCR, draw_ocr # main OCR dependencies
from config.database import db
import app
from models.class_component_model import Component
from models.class_relationship_model import Relationship
from models.class_relationship_muplicity import Multiplicity
def detect_class_relationship(image_nparray, boxes, index, class_comp_id, category):
# image = cv2.imread(app.SUBMISSION_PATH + '/' + filename)
height, width, c = image_nparray.shape
class_objects = Component.query.filter_by(class_answer=class_comp_id).all()
# for i in range(0, len(accurate_indexes))
# if category_index[class_id[i]]['name'] != 'class' and category_index[class_id[i]]['name'] != 'interface':
# category_name = category_index[class_id[i]]['name']
ymin = boxes[index][0] * height
xmin = boxes[index][1] * width
ymax = boxes[index][2] * height
xmax = boxes[index][3] * width
crop_img = image_nparray[int(ymin):int(ymax), int(xmin):int(xmax)]
img = remove_text(crop_img)
if category == 'realization':
img = line_recovery(img)
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
_, thresh_image = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY_INV)
arrow_image = get_filter_arrow_image(thresh_image)
if arrow_image is not None:
arrow_info_image, point1, point2 = get_arrow_info(arrow_image)
point1_x = int(xmin) + point1[0]
point1_y = int(ymin) + point1[1]
point2_x = int(xmin) + point2[0]
point2_y = int(ymin) + point2[1]
line_point1 = (point1_x, point1_y)
line_point2 = (point2_x, point2_y)
class_object1 = find_closest_components_length(line_point1, class_objects)
class_object2 = find_closest_components_length(line_point2, class_objects)
relationship_details_detection(image_nparray, boxes, index, class_comp_id, category, class_object1,
class_object2)
def midpoint(x1, y1, x2, y2):
x_mid = int((x1 + x2) / 2)
y_mid = int((y1 + y2) / 2)
return (x_mid, y_mid)
def remove_text(img_path):
# read image
pipeline = keras_ocr.pipeline.Pipeline()
img = keras_ocr.tools.read(img_path)
# generate (word, box) tuples
prediction_groups = pipeline.recognize([img])
mask = np.zeros(img.shape[:2], dtype="uint8")
for box in prediction_groups[0]:
x0, y0 = box[1][0]
x1, y1 = box[1][1]
x2, y2 = box[1][2]
x3, y3 = box[1][3]
x_mid0, y_mid0 = midpoint(x1, y1, x2, y2)
x_mid1, y_mi1 = midpoint(x0, y0, x3, y3)
thickness = int(math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))
cv2.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255,
thickness)
img = cv2.inpaint(img, mask, 7, cv2.INPAINT_NS)
return img
def line_recovery(img):
kernel1 = np.ones((3, 5), np.uint8)
kernel2 = np.ones((9, 9), np.uint8)
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
imgBW = cv2.threshold(imgGray, 230, 255, cv2.THRESH_BINARY_INV)[1]
img1 = cv2.erode(imgBW, kernel1, iterations=1)
img2 = cv2.dilate(img1, kernel2, iterations=3)
img3 = cv2.bitwise_and(imgBW, img2)
img3 = cv2.bitwise_not(img3)
img4 = cv2.bitwise_and(imgBW, imgBW, mask=img3)
imgLines = cv2.HoughLinesP(img4, 1, np.pi / 180, 20, minLineLength=0, maxLineGap=10)
for i in range(len(imgLines)):
for x1, y1, x2, y2 in imgLines[i]:
cv2.line(img, (x1, y1), (x2, y2), (0, 0, 0), 2)
return img
def get_filter_arrow_image(threslold_image):
blank_image = np.zeros_like(threslold_image)
kernel_dilate = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 2))
threslold_image = cv2.dilate(threslold_image, kernel_dilate, iterations=1)
contours, hierarchy = cv2.findContours(threslold_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
if hierarchy is not None:
threshold_distnace = 100
for cnt in contours:
hull = cv2.convexHull(cnt, returnPoints=False)
defects = cv2.convexityDefects(cnt, hull)
if defects is not None:
for i in range(defects.shape[0]):
start_index, end_index, farthest_index, distance = defects[i, 0]
if distance > threshold_distnace:
cv2.drawContours(blank_image, [cnt], -1, 225, -1)
return blank_image
else:
return None
def get_length(p1, p2):
line_length = ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
return line_length
def find_max_length(contours):
max_lenth = 0
for cnt in contours:
p1, p2 = get_max_distace_point(cnt)
line_length = ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
if line_length > max_lenth:
max_lenth = line_length
return max_lenth
def get_max_distace_point(cnt):
max_distance = 0
max_points = None
for [[x1, y1]] in cnt:
for [[x2, y2]] in cnt:
distance = get_length((x1, y1), (x2, y2))
if distance > max_distance:
max_distance = distance
max_points = [(x1, y1), (x2, y2)]
return max_points
def angle_between_points(a, b):
arrow_slope = (a[0] - b[0]) / (a[1] - b[1])
arrow_angle = math.degrees(math.atan(arrow_slope))
return arrow_angle
def get_arrow_info(arrow_image):
arrow_info_image = cv2.cvtColor(arrow_image.copy(), cv2.COLOR_GRAY2BGR)
contours, hierarchy = cv2.findContours(arrow_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
if hierarchy is not None:
max_lenth = find_max_length(contours)
for cnt in contours:
blank_image = np.zeros_like(arrow_image)
cv2.drawContours(blank_image, [cnt], -1, 255, -1)
point1, point2 = get_max_distace_point(cnt)
lenght = get_length(point1, point2)
if lenght == max_lenth:
cv2.circle(arrow_info_image, point1, 2, (255, 0, 0), 3)
cv2.circle(arrow_info_image, point2, 2, (255, 0, 0), 3)
cv2.putText(arrow_info_image, "point 1 : %s" % (str(point1)), point2, cv2.FONT_HERSHEY_PLAIN, 0.8,
(0, 0, 255), 1)
cv2.putText(arrow_info_image, "point 2 : %s" % (str(point2)), (point2[0], point2[1] + 20),
cv2.FONT_HERSHEY_PLAIN, 0.8, (0, 0, 255), 1)
return arrow_info_image, point1, point2
else:
return None, None
def find_closest_components_length(point, class_objects):
u_object = 0
min_length = 1000000000000
for obj in class_objects:
ymin = Decimal(obj.y_min)
xmin = Decimal(obj.x_min)
ymax = Decimal(obj.y_max)
xmax = Decimal(obj.x_max)
usecase_x = xmin + (xmax - xmin) / 2
usecase_y = ymin + (ymax - ymin) / 2
usecase_point = (int(usecase_x), int(usecase_y))
l_length = ((point[0] - usecase_point[0]) ** 2 + (point[1] - usecase_point[1]) ** 2) ** 0.5
if min_length > l_length:
min_length = l_length
u_object = obj
return u_object
def relationship_details_detection(image_nparray, boxes, index, class_comp_id, category, class_object1, class_object2):
_image, y_min, x_min, y_max, x_max = crop_image_(image_nparray, boxes, index)
_image = cv2.resize(_image, None, fx=4, fy=5)
ocr_model = PaddleOCR(lang='en', use_gpu=False)
result = ocr_model.ocr(_image)
relationship = Relationship(class_answer=class_comp_id, type=category, x_min=x_min, y_min=y_min,
x_max=x_max,
y_max=y_max, comp_1=class_object1.id, comp_2=class_object2.id)
db.session.add(relationship)
db.session.commit()
if result is not None:
relationship_text(_image, result, relationship)
# print(relationship, 'relationship')
def relationship_text(_image, result, relationship):
# boxes = [res[0] for res in result]
# texts = [res[1][0] for res in result]
# scores = [res[1][1] for res in result]
for element in result:
text = element[1][0]
box = element[0]
nlp_ner = spacy.load('ner_models/model-best')
nlp_output = nlp_ner(text)
# print(text, 'line 290')
# box = np.array(box,dtype=float)
box = np.array(box).astype(np.int32)
xmin = min(box[:, 0])
ymin = min(box[:, 1])
xmax = max(box[:, 0])
ymax = max(box[:, 1])
for token in nlp_output.ents:
# print(token.text, 'line 301')
# print(token.label_, 'line 302')
if token.label_ == 'MULTIPLICITY' or contains_number(text):
multiplicity = Multiplicity(value=token.text, relationship_id=relationship.id, x_min=xmin,
y_min=ymin, x_max=xmax, y_max=ymax)
db.session.add(multiplicity)
db.session.commit()
if not contains_number(text):
relationship.name = text
db.session.commit()
# check if string contains any numbers
def contains_number(string):
return any([char.isdigit() for char in string])
# crop image using boxes & index
def crop_image_(image, boxes, index):
height, width, c = image.shape
# crop box format: xmin, ymin, xmax, ymax
ymin = boxes[index][0] * height
xmin = boxes[index][1] * width
ymax = boxes[index][2] * height
xmax = boxes[index][3] * width
cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)]
# image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
# image = cv2.resize(image, (800, 500))
# returns cropped image , ymin,xmin,ymax & xmax
return cropped_image, ymin, xmin, ymax, xmax
......@@ -23,17 +23,20 @@ def remove_punctuation(sentence):
return cleaned_sentence
# load the text
def main(scenario):
requirement_text = scenario.replace("\n\n", " ").replace("\n", " ")
# load the text content and generating diagrams
def main(scenario, assignment_type):
# replacing spaces and new line characters
text_content = scenario.replace("\n\n", " ").replace("\n", " ")
nlp = spacy.load("en_core_web_lg")
doc = nlp(requirement_text)
nlp_loaded_text_content = nlp(text_content)
# sentence splitting
sentences = list(doc.sents)
# sentences splitting
sentences = list(nlp_loaded_text_content.sents)
# removing fist and last sentences
sentences.pop(0)
del sentences[-1]
# creating required lists
nc = []
cleaned_extracted_actions = []
cleaned_sentences = []
......@@ -41,7 +44,7 @@ def main(scenario):
# looping through each sentence
for sentence in sentences:
res = get_nouns_pnouns(sentence)
res = get_nouns_pronouns(sentence)
nc.append(str(res))
cleaned_sentence = remove_punctuation(sentence)
cleaned_sentences.append(cleaned_sentence)
......@@ -57,10 +60,21 @@ def main(scenario):
# remove duplicates of the actors
nc = list(dict.fromkeys(nc))
data = remove_unwanted_values(nc)
generated_class_diagram_path = generate_class(data, cleaned_extracted_actions)
extracted_relationships = get_include_extend_relationships(splitted_actions_array)
actors_and_use_cases_array = identify_use_cases(cleaned_extracted_actions)
generated_usecase_diagram_path = generate_use_case_diagram(data, extracted_relationships,
actors_and_use_cases_array)
return generated_class_diagram_path, generated_usecase_diagram_path
if assignment_type == 1:
generated_usecase_diagram_path = generate_use_case_diagram(data, extracted_relationships,
actors_and_use_cases_array)
return generated_usecase_diagram_path
elif assignment_type == 2:
generated_class_diagram_path = generate_class(data, cleaned_extracted_actions)
return generated_class_diagram_path
elif assignment_type == 3:
generated_class_diagram_path = generate_class(data, cleaned_extracted_actions)
generated_usecase_diagram_path = generate_use_case_diagram(data, extracted_relationships,
actors_and_use_cases_array)
return generated_class_diagram_path, generated_usecase_diagram_path
......@@ -17,9 +17,10 @@ def get_noun_chunks(sentence):
return list(sentence.noun_chunks)
def get_nouns_pnouns(sentence):
# getting nouns and pronouns (pos tagging)
def get_nouns_pronouns(sentence):
for token in sentence:
if token.pos_ == "PROPN" and token.pos_ != None:
if token.pos_ == "PROPN" and token.pos_ is not None:
return token
......@@ -37,7 +38,6 @@ def split_actions(sentence):
def get_actions(splitted_action):
# print('splitted_action',splitted_action)
temp_array = []
if splitted_action is not None and '|' in splitted_action[1]:
res = splitted_action[1].split(' | ')
......
......@@ -44,34 +44,39 @@ def get_include_extend_relationships(splitted_actions_array):
relationship_array.append(dictionary)
return relationship_array
def clean_use_case_strings(use_case):
if 'Extend' in use_case:
return use_case.replace('Extend','').lstrip(' ')
return use_case.replace('Extend', '').lstrip(' ')
elif 'Include' in use_case:
return use_case.replace('Include', '').lstrip(' ')
else:
return use_case.lstrip(' ')
def generate_dot_file_actors_string(actors):
actors_string_content = []
for actor in actors:
single_actor_string = 'subgraph ' + actor + ' {label="' + actor + '"; ' + actor.lower() + '};\n\t' + actor.lower() + ' [image="'+APP_ROOT+'/stick.png";peripheries=0;];\n'
single_actor_string = 'subgraph ' + actor + ' {label="' + actor + '"; ' + actor.lower() + '};\n\t' + actor.lower() + ' [image="' + APP_ROOT + '/stick.png";peripheries=0;];\n'
actors_string_content.append(single_actor_string)
return actors_string_content
def generate_use_case_nodes(actors_and_use_cases_array):
use_case_nodes_array = []
for element in actors_and_use_cases_array:
cleaned_use_case_string = clean_use_case_strings(element[1])
use_case_string = cleaned_use_case_string.lower().replace(' ','_') + ' [label="' + cleaned_use_case_string + '"];\n'
use_case_string = cleaned_use_case_string.lower().replace(' ',
'_') + ' [label="' + cleaned_use_case_string + '"];\n'
use_case_nodes_array.append(use_case_string)
return use_case_nodes_array
def generate_edges(actors_and_use_cases_array):
edges_array = []
for element in actors_and_use_cases_array:
cleaned_string = clean_use_case_strings(element[1])
edge_string = element[0].replace(' ','').lower() + '->' + cleaned_string.lower().replace(' ','_') + ';\n'
edge_string = element[0].replace(' ', '').lower() + '->' + cleaned_string.lower().replace(' ', '_') + ';\n'
edges_array.append(edge_string)
return edges_array
......@@ -81,25 +86,32 @@ def generate_extend_relationships_string(extracted_relationships):
for element in extracted_relationships:
if element['extend']:
for ele in element['extend']:
extend_string = element['use_case'].lstrip(' ').rstrip(' ').replace(' ','_').lower() + '->' + ele.lstrip(' ').rstrip(' ').replace(' ','_').lower() + ';\n'
extend_string = element['use_case'].lstrip(' ').rstrip(' ').replace(' ',
'_').lower() + '->' + ele.lstrip(
' ').rstrip(' ').replace(' ', '_').lower() + ';\n'
extend_array.append(extend_string)
return extend_array
def generate_include_relationships_string(extracted_relationships):
include_array = []
for element in extracted_relationships:
if element['include']:
for ele in element['include']:
include_string = element['use_case'].lstrip(' ').rstrip(' ').replace(' ','_').lower() + "->" + ele.lstrip(' ').rstrip(' ').replace(' ','_').lower() + ';\n'
include_string = element['use_case'].lstrip(' ').rstrip(' ').replace(' ',
'_').lower() + "->" + ele.lstrip(
' ').rstrip(' ').replace(' ', '_').lower() + ';\n'
include_array.append(include_string)
return include_array
def generate_random_string():
letters = string.ascii_lowercase
random_string = ''.join(random.choice(letters) for i in range(10))
return random_string
def generate_use_case_diagram(actors,extracted_relationships,actors_and_use_cases_array):
def generate_use_case_diagram(actors, extracted_relationships, actors_and_use_cases_array):
generated_actors_string = generate_dot_file_actors_string(actors)
generated_use_case_nodes_string = generate_use_case_nodes(actors_and_use_cases_array)
generated_edges_string = generate_edges(actors_and_use_cases_array)
......@@ -138,6 +150,8 @@ def generate_use_case_diagram(actors,extracted_relationships,actors_and_use_case
generate_diagram(dot_file_name)
return '/generated_use_case_diagrams/' + dot_file_name + '.png'
def generate_diagram(filename):
subprocess.run(["dot", "-Tpng", OUTPUTS_GENERATED_DOT_FILES_PATH+"/use_cases_"+filename+".dot", "-o", OUTPUTS_GENERATED_USE_CASE_DIAGRAMS_PATH+"/"+filename+".png"])
return True
\ No newline at end of file
subprocess.run(["dot", "-Tpng", OUTPUTS_GENERATED_DOT_FILES_PATH + "/use_cases_" + filename + ".dot", "-o",
OUTPUTS_GENERATED_USE_CASE_DIAGRAMS_PATH + "/" + filename + ".png"])
return True
......@@ -14,7 +14,7 @@ import tensorflow as tf
from config.database import db
from models.actor_and_use_case import ActorANDUseCase
# pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
# pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
from services.extend_include_relationship_detection_service import detect_extend_include_relationship
from services.generalization_relationship_detection_service import detect_generalization_relationship
......
......@@ -11,4 +11,9 @@ item {
item {
id: 3
name: 'class_name'
}
item {
id: 4
name: 'interface_name'
}
\ No newline at end of file
......@@ -119,7 +119,8 @@ abbr {
position: relative;
}
input::placeholder {
input::placeholder,
textarea::placeholder {
text-transform: uppercase;
font-size: 0.9rem !important;
letter-spacing: 2px;
......
......@@ -69,9 +69,15 @@
width: 100%;
box-sizing: border-box;
border: 2px solid var(--main-color-blue);
outline: none;
font-size: 1rem;
padding: 1rem;
color: #858585;
border-radius: 5px;
text-transform: uppercase;
font-size: 0.9rem !important;
letter-spacing: 2px;
font-weight: 550;
}
.rowpinfo select {
......
......@@ -191,7 +191,6 @@ textarea {
box-sizing: border-box;
border: 2px solid var(--main-color-blue);
border-radius: 4px;
background-color: #f8f8f8;
font-size: 16px;
font-family: "Inter", sans-serif;
resize: none;
......@@ -199,6 +198,4 @@ textarea {
textarea:focus {
outline: none !important;
box-shadow: 0 0 5px var(--main-color-blue);
border: 2px solid var(--main-color-blue);
}
import React from "react";
import "./Spinner.css";
import Spinner from "./Spinner";
const FullScreenLoader = ({ title }) => {
return (
<div className="full-screen-loader">
<Spinner title={title} />
</div>
);
};
export default FullScreenLoader;
.spinner-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 2rem;
}
.spinner {
width: 80px;
height: 80px;
......@@ -13,3 +16,13 @@
border-top-color: var(--main-color-blue);
animation: spin 1s linear infinite;
}
.full-screen-loader {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: rgba(255, 255, 255, 0.8);
z-index: 100;
}
......@@ -2,10 +2,11 @@ import React from "react";
import "./Spinner.css";
const Spinner = () => {
const Spinner = ({ title }) => {
return (
<div className="spinner-container">
<div className="spinner"></div>
<h2 style={{ paddingTop: "1rem" }}>{title}</h2>
</div>
);
};
......
export const assetsUrl = "http://localhost:5000/outputs";
import axios from "axios";
import { Link } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import React, { useEffect, useState } from "react";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import Spinner from "../components/loading/Spinner";
import { RiDeleteBinLine } from "react-icons/ri";
import Popup from "./Popup";
import { assetsUrl } from "../config/assets.config";
const ViewAssignment = () => {
const siteId = localStorage.getItem("site");
const [Materials, setMaterials] = useState([]);
const students = [
{
email: "email@gmail.com",
submittedAt: "2022-04-05",
submission: "IT1912192.png",
plagiarismPercentage: 40,
CorrectnessPercentage: 70,
},
{
email: "email@gmail.com",
submittedAt: "2022-04-05",
submission: "IT1912192.png",
plagiarismPercentage: 10,
CorrectnessPercentage: 70,
},
{
email: "email@gmail.com",
submittedAt: "2022-04-05",
submission: "IT1912192.png",
plagiarismPercentage: 30,
CorrectnessPercentage: 70,
},
];
const fields = [
"",
"Student Email",
"Submission",
"Plagiarism Percentage",
"Correctness Percentage",
"Submitted At",
"Action",
];
const permissionStatus = {
pending: "warning",
approved: "success",
rejected: "danger",
};
const [OrderDetail, setOrderDetail] = useState([]);
const { id } = useParams();
const [diagrams, setDiagrams] = useState({});
const [assignment, setAssignment] = useState({});
const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false);
const [Name, setName] = useState("");
const [Id, setId] = useState("");
const [ItemName, setItemName] = useState("");
const [Description, setDescription] = useState("");
const [Order, setOrder] = useState({
item: {},
quantity: 0,
siteid: siteId,
requiredDate: "",
urgentOrder: false,
});
console.log(Order);
const FetchData = async () => {
const resMaterials = await axios.get(`materials`);
setMaterials(resMaterials.data.materials);
const resOrders = await axios.get("/orders");
setOrderDetail(resOrders.data.orders);
if (resOrders.statusText === "OK") {
setLoading(true);
const getDiagrams = async () => {
setLoading(true);
try {
const res = await axios.get("/diagrams/" + id);
console.log(res);
setDiagrams(res.data.diagrams);
setLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => {
FetchData();
}, []);
const orderHandler = async () => {
const getAssignment = async () => {
setLoading(true);
try {
console.log(Order);
const res = await axios.post("/orders", Order);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
const res = await axios.get("/assignments/" + id);
console.log(res);
setAssignment(res.data.assignment);
setLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => {
getDiagrams();
getAssignment();
}, []);
return (
<div>
<Sidebar />
......@@ -102,43 +48,49 @@ const ViewAssignment = () => {
<div className="layout__content-main">
<div className="row">
<div className="col-10">
<h1 className="page-header">CTSE Assignment 01</h1>
<h1 className="page-header">{assignment.title}</h1>
</div>
<div className="col-1" style={{ marginTop: "1rem" }}>
<Link to={`/auth/teacher/assignments/1`}>
<div className="col-2" style={{ marginTop: "1rem" }}>
<Link to={`/auth/teacher/assignments/${id}`}>
<button className="view-btn">Back to Assignment</button>
</Link>
</div>
</div>
<div className="row">
<div className="col-12">
<div className="card">
<h3>Generated usecase diagram</h3>
<br />
<div className="flex" style={{ justifyContent: "center" }}>
<img
src="https://d2slcw3kip6qmk.cloudfront.net/marketing/pages/chart/what-is-a-use-case-diagram-in-UML/UML_use_case_example-800x707.PNG"
alt="usecase"
/>
{diagrams.usecase_diagram && (
<div className="row">
<div className="col-12">
<div className="card">
<h3 style={{ paddingBottom: "2rem" }}>Generated usecase diagram</h3>
<br />
<div className="flex" style={{ justifyContent: "center" }}>
<img
src={assetsUrl + diagrams.usecase_diagram}
alt="usecase"
style={{ width: "80%", height: "80%" }}
/>
</div>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-12">
<div className="card">
<h3>Generated class diagram</h3>
<br />
<div className="flex" style={{ justifyContent: "center" }}>
<img
src="https://www.researchgate.net/profile/Sergi-Valverde/publication/225686440/figure/fig3/AS:667828239732738@1536234068086/A-simple-class-diagram-for-a-commercial-software-application-in-UML-notation-The.png"
alt="usecase"
/>
)}
{diagrams.class_diagram && (
<div className="row">
<div className="col-12">
<div className="card">
<h3 style={{ paddingBottom: "2rem" }}>Generated class diagram</h3>
<br />
<div className="flex" style={{ justifyContent: "center" }}>
<img
src={assetsUrl + diagrams.class_diagram}
alt="usecase"
style={{ width: "80%", height: "80%" }}
/>
</div>
</div>
</div>
</div>
</div>
)}
</div>
</div>
</div>
......
This diff is collapsed.
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import axios from "axios";
import { RiDeleteBinLine } from "react-icons/ri";
import axios from "axios";
import Sidebar from "../components/sidebar/Sidebar";
import Spinner from "../components/loading/Spinner";
......@@ -10,27 +10,23 @@ import TopNav from "../components/topnav/TopNav";
import "../assets/css/Usercreate.css";
const ManageClasses = () => {
const ManageModules = () => {
const [btnState, setBtnState] = useState(false);
const [error, setError] = useState("");
const [isLoading, setIsLoading] = useState(true);
const [material, setMaterial] = useState({ code: "", name: "" });
const [materials, setMaterials] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [module, setModule] = useState({ code: "", name: "" });
const [modules, setModules] = useState([]);
const fields = ["", "Module Code", "Module Name", "Created At", "Actions"];
const fields = ["", "ID", "Module Code", "Module Name", "Created At", "Actions"];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const classes = [
{ code: "A001", name: "CTSE", createdAt: "2022-04-05" },
{ code: "A002", name: "CTSE", createdAt: "2022-04-05" },
{ code: "A003", name: "CTSE", createdAt: "2022-04-05" },
];
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.id}</td>
<td>{item.code}</td>
<td>{item.name}</td>
<td>{item.createdAt}</td>
<td>{new Date(item.created_at).toLocaleString()}</td>
<td>
<div style={{ display: "flex", alignItems: "center" }}>
<Link to={``}>
......@@ -40,8 +36,8 @@ const ManageClasses = () => {
className="action-btn x"
style={{ marginLeft: "2rem" }}
onClick={() => {
if (window.confirm("Are you sure to delete this class?")) {
deleteHandler(item._id, item.username);
if (window.confirm("Are you sure to delete this module?")) {
deleteHandler(item.id);
}
}}
>
......@@ -56,39 +52,35 @@ const ManageClasses = () => {
e.preventDefault();
setBtnState(true);
for (let key of Object.keys(material)) {
if (!material[key]) {
for (let key of Object.keys(module)) {
if (!module[key]) {
setBtnState(false);
return setError("Please fill all the fields");
}
}
try {
const res = await axios.post("materials", material);
console.log(res);
setMaterial({
code: "",
name: "",
});
getAllMaterial();
await axios.post("modules/create", module);
setModule({ code: "", name: "" });
setError("");
window.alert("Class added successfully");
window.alert("Module added successfully");
getAllModules();
setBtnState(false);
setIsLoading(true);
} catch (err) {
setBtnState(false);
setError(err.response.data.message);
console.log(err.response);
}
};
const deleteHandler = async (id, username) => {
const deleteHandler = async id => {
try {
const res = await axios.delete(`materials/${id}`);
const res = await axios.delete(`modules/${id}`);
if (res.statusText === "OK") {
getAllMaterial();
getAllModules();
setError("");
window.alert("Class has been successfully deleted");
window.alert("Module has been successfully deleted");
setIsLoading(true);
}
} catch (err) {
......@@ -96,17 +88,19 @@ const ManageClasses = () => {
}
};
const getAllMaterial = async () => {
const getAllModules = async () => {
setIsLoading(true);
try {
const res = await axios.get(`materials`);
setMaterials(res.data.materials);
const res = await axios.get("modules");
console.log(res);
setModules(res.data.modules);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => getAllMaterial(), []);
useEffect(() => getAllModules(), []);
return (
<div>
......@@ -129,10 +123,10 @@ const ManageClasses = () => {
<input
type="text"
placeholder="Module Code"
value={material.code}
value={module.code}
onChange={e =>
setMaterial({
...material,
setModule({
...module,
code: e.target.value,
})
}
......@@ -145,10 +139,10 @@ const ManageClasses = () => {
<input
type="text"
placeholder="Module Name"
value={material.name}
value={module.name}
onChange={e =>
setMaterial({
...material,
setModule({
...module,
name: e.target.value,
})
}
......@@ -167,14 +161,14 @@ const ManageClasses = () => {
</div>
<div className="card col-12">
<h2>Created Modules</h2>
{false ? (
{isLoading ? (
<Spinner />
) : (
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={classes}
bodyData={modules}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
)}
......@@ -185,4 +179,4 @@ const ManageClasses = () => {
);
};
export default ManageClasses;
export default ManageModules;
import axios from "axios";
import { Link } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import React, { useEffect, useState } from "react";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import Spinner from "../components/loading/Spinner";
import { RiDeleteBinLine } from "react-icons/ri";
import Popup from "./Popup";
const ViewAssignment = () => {
const siteId = localStorage.getItem("site");
const { id } = useParams();
const [Materials, setMaterials] = useState([]);
const [assignment, setAssignment] = useState({});
const students = [
{
email: "email@gmail.com",
......@@ -49,63 +48,23 @@ const ViewAssignment = () => {
approved: "success",
rejected: "danger",
};
const [OrderDetail, setOrderDetail] = useState([]);
const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false);
const [Name, setName] = useState("");
const [Id, setId] = useState("");
const [ItemName, setItemName] = useState("");
const [Description, setDescription] = useState("");
const [Order, setOrder] = useState({
item: {},
quantity: 0,
siteid: siteId,
requiredDate: "",
urgentOrder: false,
});
console.log(Order);
const FetchData = async () => {
const resMaterials = await axios.get(`materials`);
setMaterials(resMaterials.data.materials);
const resOrders = await axios.get("/orders");
setOrderDetail(resOrders.data.orders);
if (resOrders.statusText === "OK") {
setLoading(true);
const getAssignment = async () => {
setLoading(true);
try {
const res = await axios.get("/assignments/" + id);
console.log(res);
setAssignment(res.data.assignment);
setLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => {
FetchData();
getAssignment();
}, []);
const deleteHandler = async id => {
console.log(id);
try {
const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const orderHandler = async () => {
try {
console.log(Order);
const res = await axios.post("/orders", Order);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
......@@ -124,28 +83,7 @@ const ViewAssignment = () => {
<td>{item.submittedAt}</td>
<td>
<div style={{ display: "flex", alignItems: "center" }}>
<button className="action-btn check">
<i
className="bx bx-check"
onClick={() => {
if (window.confirm("Are you sure to accept this submission?")) {
// successHandler(item._id);
}
}}
></i>
</button>
<button
className="action-btn x"
style={{ marginRight: "2rem" }}
onClick={() => {
if (window.confirm("Are you sure to remove this submission?")) {
deleteHandler(item._id);
}
}}
>
<RiDeleteBinLine />
</button>
<Link to={``}>
<Link to={""}>
<button className="view-btn">View</button>
</Link>
</div>
......@@ -159,7 +97,7 @@ const ViewAssignment = () => {
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<h1 className="page-header">CTSE Assignment 01</h1>
<h1 className="page-header">{assignment.title}</h1>
<div className="row">
<div className="col-12">
<div className="card">
......@@ -170,31 +108,13 @@ const ViewAssignment = () => {
</h3>
</div>
<div className="col-1">
<Link to={`/auth/teacher/assignments/1/diagrams`}>
<Link to={`/auth/teacher/assignments/${id}/diagrams`}>
<button className="view-btn">View Generated Diagrams</button>
</Link>
</div>
</div>
<br />
<p>
GlamourFashions (GF) is a clothing store situated in Colombo and its planning
to build an online shopping system to promote their sales further. The management
of clothing store hired you as a System Analyst and asked to come up with the
design models for GlamourFashions Online Store (GFOS). GlamourFashions (GF) Online
Clothing Store is expected to organize clothing items under several categories
like office wear, casual wear, evening wear and so on. A visitor can browse on
items without being registering to the system. If he/she likes to order item, the
system facilitates to add selected items into the shopping cart and directly move
to checkout option. If the user interested to be a regular user, the system will
provide registration facility as well. Without even registering, the user can
directly go for the checkout. For a registered user, the system is expected to
send a promotion code for users mobile every month which can be used only once.
when the user logs into the system to do online shopping, user can enter this code
which will give a 5% discount for the order he/she makes. If the user does not use
the code within the month, automatically the system must discard promotion code.
If its been already used, the system must display a message saying its already
been used.
</p>
<p>{assignment.content}</p>
</div>
</div>
</div>
......
......@@ -13,7 +13,7 @@ import ManagerApprovedOrders from "../pages/ManagerApprovedOrders";
import TeacherDashboard from "../pages/TeacherDashboard";
import ManageServices from "../pages/ManageServices";
import ManageStudents from "../pages/ManageStudents";
import ManageClasses from "../pages/ManageClasses";
import ManageModules from "../pages/ManageModules";
import OfficerDashboard from "../pages/OfficerDashboard";
import OfficerOrders from "../pages/OfficerOrders";
import Register from "../pages/Register";
......@@ -38,7 +38,7 @@ const Routes = () => {
<Route exact path="/auth/teacher/dashboard" component={TeacherDashboard} />
<Route exact path="/auth/teacher/students" component={ManageStudents} />
<Route exact path="/auth/teacher/modules" component={ManageClasses} />
<Route exact path="/auth/teacher/modules" component={ManageModules} />
<Route exact path="/auth/teacher/assignments" component={ManageAssignments} />
<Route exact path="/auth/teacher/assignments/:id" component={ViewAssignment} />
<Route exact path="/auth/teacher/assignments/:id/diagrams" component={GeneratedDiagrams} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment