Beispiel #1
0
 def search_by_name(self):
     """
     Retrieves all the desired employees' data by taking employee's name
     as input at runtime.
     Creates a request class object,
     and sending it via a Wrapper class object to the request class object.
     Then sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     try:
         name = input("Enter the Name of the Employee : ")
         request = Request(manager="EmployeeManager",
                           action="get_by_name",
                           request_object=Wrapper(name))
         network_client = NetworkClient()
         response = network_client.send(request)
         if response.success:
             employees = ListHandler.from_json(response.result_json)
             for employee in employees:
                 print(
                     f"ID : {employee.emp_id} Name : {employee.name}, Designation : {employee.designation_code}, Gender : {employee.gender}"
                 )
         else:
             er = ExceptionHandler.from_json(response.error_json)
             if er.exceptions is None:
                 print(er.message)
             else:
                 for exception in er.exceptions.values():
                     print(exception[1])
     except:
         print("Invalid Entry for Name!!")
     print("-" * 50)
Beispiel #2
0
 def search_designation_by_title(self):
     """
     Retrieves the desired designation by taking designation title as input at runtime.
     Creates a request class object,
     and sending it via a Wrapper class object to the request class object.
     Then sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     title = input("Enter the Designation Name : ")
     request = Request(manager="DesignationManager",
                       action="getbytitle",
                       request_object=Wrapper(title))
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         designation = Designation.from_json(response.result_json)
         print(
             f"Code : {designation.code} Designation : {designation.title}")
     else:
         er = ExceptionHandler.from_json(response.error_json)
         if er.exceptions is None:
             print(er.message)
         else:
             for exception in er.exceptions.values():
                 print(exception[1])
     print("-" * 50)
Beispiel #3
0
 def get_all_employees(self):
     """
     Retrieves all the available employee entries and displays them.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response
     in the form of a list.
     """
     request = Request(manager="EmployeeManager", action="getall")
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         employees = ListHandler.from_json(response.result_json)
         for employee in employees:
             print(
                 f"ID : {employee.emp_id} Name : {employee.name}, Designation : {employee.designation_code}, Gender : {employee.gender}"
             )
     else:
         er = ExceptionHandler.from_json(response.error_json)
         if er.exceptions is None:
             print(er.message)
         else:
             for exception in er.exceptions.values():
                 print(exception[1])
     print("-" * 50)
Beispiel #4
0
 def search_employee_by_id(self):
     """
     Retrieves the desired employee data by taking employee id
     as input at runtime.
     Creates a request class object,
     and sending it via a Wrapper class object to the request class object.
     Then sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     try:
         emp_id = int(input("Enter the Employee ID : "))
         request = Request(manager="EmployeeManager",
                           action="get_by_id",
                           request_object=Wrapper(emp_id))
         network_client = NetworkClient()
         response = network_client.send(request)
         if response.success:
             employee = Employee.from_json(response.result_json)
             print(
                 f"ID : {employee.emp_id} Name : {employee.name}, Designation : {employee.designation_code}, Gender : {employee.gender}"
             )
         else:
             er = ExceptionHandler.from_json(response.error_json)
             if er.exceptions is None:
                 print(er.message)
             else:
                 for exception in er.exceptions.values():
                     print(exception[1])
     except:
         print(f"ID is of unexpected type, it should be of type {type(0)}")
     print("-" * 50)
Beispiel #5
0
 def get_all_designations(self):
     """
     Retrieves all the available designation entries and displays them.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response
     in the form of a list.
     """
     request = Request(manager="DesignationManager", action="getall")
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         designations = ListHandler.from_json(response.result_json)
         for designation in designations:
             print(
                 f"Code : {designation.code} Designation : {designation.title}"
             )
     else:
         er = ExceptionHandler.from_json(response.error_json)
         if er.exceptions is None:
             print(er.message)
         else:
             for exception in er.exceptions.values():
                 print(exception[1])
     print("-" * 50)
Beispiel #6
0
 def remove_employee(self):
     """
     deletes one of the existing employee data in the Employee Table
     by taking the employee ID as input at runtime,
     and sending it via a Wrapper class object to the request class object.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     try:
         emp_id = int(input("Enter the Employee ID : "))
         request = Request(manager="EmployeeManager",
                           action="remove",
                           request_object=Wrapper(emp_id))
         network_client = NetworkClient()
         response = network_client.send(request)
         if response.success:
             print("Employee Deleted")
         else:
             er = ExceptionHandler.from_json(response.error_json)
             if er.exceptions is None:
                 print(er.message)
             else:
                 for exception in er.exceptions.values():
                     print(exception[1])
     except:
         print(
             f"employee id is of unexpected type, it should be of type {type(0)}"
         )
     print("-" * 50)
Beispiel #7
0
 def update_designation(self):
     """
     edits any of the existing designations to the Designation Table
     by taking the designation code and title as input at runtime
     and creating a Designation class object.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     try:
         code = int(input("Enter the Designation Code : "))
         title = input("Enter the Designation Name : ")
         designation = Designation(code, title)
         request = Request(manager="DesignationManager",
                           action="update",
                           request_object=designation)
         network_client = NetworkClient()
         response = network_client.send(request)
         if response.success:
             print("Designation Update")
         else:
             er = ExceptionHandler.from_json(response.error_json)
             if er.exceptions is None:
                 print(er.message)
             else:
                 for exception in er.exceptions.values():
                     print(exception[1])
     except:
         print(
             "Invalid entry type for fields of employee information form!")
     print("-" * 50)
Beispiel #8
0
 def add_designation(self):
     """
     adds a new designation to the Designation Table
     by taking the designation title as input at runtime
     and creating a Designation class object.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     title = input("Enter the Designation to add : ")
     designation = Designation(0, title)
     request = Request(manager="DesignationManager",
                       action="add",
                       request_object=designation)
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         print("Designation Added")
     else:
         er = ExceptionHandler.from_json(response.error_json)
         if er.exceptions is None:
             print(er.message)
         else:
             for exception in er.exceptions.values():
                 print(exception[1])
     print("-" * 50)
Beispiel #9
0
 def add_employee(self):
     """
     adds a new employee's data to the Employee Table
     by taking the employee's required data as input at runtime
     and creating an Employee object.
     Creates a request class object,
     sends it using the NetworkClient class object and receives a response class object.
     This response object is then processed and prints the data sent in the response.
     """
     try:
         name = None
         designation_code = None
         date = None
         month = None
         year = None
         salary = None
         gender = None
         indian = None
         pan_no = None
         aadhar = None
         name = input("Enter Name of the Employee : ")
         designation_code = int(
             input("Enter the Designation Number of the Employee : "))
         date = int(input("Enter the Date : "))
         month = int(input("Enter the Month : "))
         year = int(input("Enter the Year : "))
         salary = float(input("Enter the Salary of the Employee : "))
         gender = input("Enter the Gender of the Employee : ")
         indian = int(input("Enter 1 for Indian otherwise enter 0 : "))
         pan_no = input("Enter the PAN Number of the employee : ")
         aadhar = input("Enter the Aadhar Number of the employee : ")
         employee = Employee(0, name, designation_code, date, month, year,
                             salary, gender, indian, pan_no, aadhar)
         request = Request(manager="EmployeeManager",
                           action="add",
                           request_object=employee)
         network_client = NetworkClient()
         response = network_client.send(request)
         if response.success:
             print("Employee Added")
         else:
             er = ExceptionHandler.from_json(response.error_json)
             if er.exceptions is None:
                 print(er.message)
             else:
                 for exception in er.exceptions.values():
                     print(exception[1])
     except:
         print(
             f"Invalid entry type for fields of employee information form!")
     print("-" * 50)
Beispiel #10
0
 def delete_designation(self):
     code = int(input("Enter code to delete : "))
     designation = Designation(code, "aa")
     request = Request(manager="DesignationManager",
                       action="delete",
                       request_object=designation)
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         print("Designation deleted")
     else:
         validationException = ValidationException.from_json(
             response.error_json_string)
         if validationException.message and len(
                 validationException.message) > 0:
             print(validationException.message)
         if validationException.exceptions:
             for exception in validationException.exceptions.values():
                 print(exception[1])
Beispiel #11
0
 def add_designation(self):
     title = input("Enter designation to add : ")
     designation = Designation(0, title)
     request = Request(manager="DesignationManager",
                       action="add",
                       request_object=designation)
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         print("Designation added")
     else:
         validationException = ValidationException.from_json(
             response.error_json_string)
         if validationException.message and len(
                 validationException.message) > 0:
             print(validationException.message)
         if validationException.exceptions:
             for exception in validationException.exceptions.values():
                 print(exception[1])
Beispiel #12
0
 def get_all_designations(self):
     request = Request(manager="DesignationManager", action="getAll")
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         designations = json.loads(response.result_json_string)
         designationsList = list(
             map(lambda obj: Designation(**obj), designations))
         for designation in designationsList:
             print(
                 f"Code : {designation.code}, Title : {designation.title}")
     else:
         validationException = ValidationException.from_json(
             response.error_json_string)
         if validationException.message and len(
                 validationException.message) > 0:
             print(validationException.message)
         if validationException.exceptions:
             for exception in validationException.exceptions.values():
                 print(exception[1])
Beispiel #13
0
 def get_designation(self):
     code = int(input("Enter code to search : "))
     designation = Designation(code, "aa")
     request = Request(manager="DesignationManager",
                       action="search",
                       request_object=designation)
     network_client = NetworkClient()
     response = network_client.send(request)
     if response.success:
         designation = Designation.from_json(response.result_json_string)
         print(f"Code : {designation.code}, Title : {designation.title}")
     else:
         validationException = ValidationException.from_json(
             response.error_json_string)
         if validationException.message and len(
                 validationException.message) > 0:
             print(validationException.message)
         if validationException.exceptions:
             for exception in validationException.exceptions.values():
                 print(exception[1])
Beispiel #14
0
from network_client.client import NetworkClient
from network_common.wrappers import Request

client = NetworkClient()
request = Request("DesignationMaster", "getAll")
response = client.send(request)