Class ExportMenu

java.lang.Object
cz.cuni.kubinja.hospitalsystem.UI.ExportMenu
All Implemented Interfaces:
Page

public class ExportMenu extends Object
Menu page containing options connected with exporting of hospital data.
  • Field Details

    • api

      protected Hospital api
      Connection to the hospital system
    • scanner

      protected Scanner scanner
      Scanner pointing to the input data
    • options

      protected List<cz.cuni.kubinja.hospitalsystem.UI.MenuEntry> options
      Options of the menu page
    • state

      protected UIState state
      State in which menu page is
    • exitSequence

      protected static final String exitSequence
      Sequence that forcefully stop entering data
      See Also:
  • Constructor Details

    • ExportMenu

      public ExportMenu(Hospital api, Scanner scanner)
      Creates exports menu page.
      Parameters:
      api - Hospital giving the menu options how to interact with hospital system.
      scanner - Scanner pointing to the input data.
  • Method Details

    • defineMenu

      public void defineMenu()
      Description copied from interface: Page
      Defines which options should menu provide and how will be mapped options to the functions.
    • exportPatients

      public void exportPatients()
      Exports patients data into file.
    • exportDoctors

      public void exportDoctors()
      Exports doctors data into file.
    • exportAppointments

      public void exportAppointments()
      Exports appointment data into file.
    • exportAll

      public void exportAll()
      Exports all hospital data into file.
    • printMenu

      public void printMenu()
      Description copied from interface: Page
      Shows menu options in terminal.
      Specified by:
      printMenu in interface Page
    • processMenu

      public void processMenu()
      Description copied from interface: Page
      Processes the user option based on page menu.
      Specified by:
      processMenu in interface Page
    • addOption

      protected void addOption(String text, Runnable action)
      Adds new option into the menu.
      Parameters:
      text - Text of the option.
      action - Action that will be called every time the option is selected.
    • end

      protected void end()
      Sets state of the menu to the end.
    • getOption

      public int getOption(int range)
      Processes input and returns extracted option.
      Parameters:
      range - Upper bound for not zero positive range of options, thus (0, range]
      Returns:
      First valid option in the input stream.
    • getPersonData

      public PersonData getPersonData(Person person)
      Processes input and extracts valid information into Person data wrapper.
      Parameters:
      person - Person whose data will be user as the default values.
      Returns:
      Wrapper containing data for Person creating (without id)
    • getPersonData

      public PersonData getPersonData()
      Processes input and extracts valid information into Person data wrapper.
      Returns:
      Person data wrapper containing data for person creation.
    • getPatientDetails

      public PatientsDetails getPatientDetails(Patient patient)
      Processes input and extracts valid information into patient details data wrapper.
      Parameters:
      patient - Patient object that will be used as default values.
      Returns:
      Patient details data wrapper.
    • getPatientDetails

      public PatientsDetails getPatientDetails()
      Processes input and extracts valid information into patient details data wrapper.
      Returns:
      Patient details data wrapper.
    • getDoctorDetails

      public DoctorDetails getDoctorDetails(Doctor doctor)
      Processes input and extracts valid information into doctors details data wrapper.
      Parameters:
      doctor - Doctor object that will be used as default values.
      Returns:
      Doctors details data wrapper.
    • getDoctorDetails

      public DoctorDetails getDoctorDetails()
      Processes input and extracts valid information into doctors details data wrapper.
      Returns:
      Doctor details data wrapper.
    • getQuestion

      public String getQuestion(String question)
      Returns question, where the default value is not present.
      Parameters:
      question - Text of the question.
      Returns:
      question, where the default value is not present.
    • getQuestion

      public String getQuestion(String question, String defaultValue)
      Returns question, where will be displayed default value.
      Parameters:
      question - Text of the question.
      defaultValue - Default value for the question.
      Returns:
      Question, where will be displayed default value.
    • clearConsole

      public void clearConsole()
      Clears console with appropriate command based on OS
    • getInteger

      public int getInteger(String question)
      Processes input and extracts first valid integer.
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      Valid integer.
    • getString

      public String getString(String question, String defaultValue)
      Processes input and extracts first not empty line.
      Parameters:
      question - Question with which will be user prompted.
      defaultValue - Default value that will be suggested to the user.
      Returns:
      Not empty string.
    • getString

      public String getString(String question)
      Processes input and extracts first not empty line.
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      First not empty line.
    • getDate

      public LocalDate getDate(String question, LocalDate defaultValue)
      Processes input and extracts first line containing valid date (in format YYYY-MM-DD)
      Parameters:
      question - Question with which will be user prompted.
      defaultValue - Default value that will be suggested to the user.
      Returns:
      LocalDate object containing valid date.
    • getDate

      public LocalDate getDate(String question)
      Processes input and extracts first line containing valid date (int format YYYY-MM-DD)
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      LocalDate object containing valid date.
    • getDateTime

      public LocalDateTime getDateTime(String question)
      Processes input and extracts first line containing valid date and time.

      (in format YYYY-MM-DDTHH:MM or YYYY-MM-DD HH:MM)

      Parameters:
      question - Question with which will be user prompted.
      Returns:
      LocalDateTime object containing valid date and time.
    • createNew

      public boolean createNew(String what)
      Checks whether the user wants to create new object.
      Parameters:
      what - The object in question.
      Returns:
      Whether the user wants to create new object.
    • getBool

      public boolean getBool(String question)
      Processes input from scanner and returns value after processing first line that contains some text that can be converted to bool value.
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      Value after processing first line that contains some text that can be converted to bool value.
    • waitForEnter

      public void waitForEnter()
      Show waiting text and prompts user into pressing any key.
    • printAndWait

      public void printAndWait(String text)
      Prints text and wait for the confirmation action from the user.
      Parameters:
      text - Text that will be displayed.
    • processPacketStatus

      public boolean processPacketStatus(GeneralPacket packet)
      Processes packet status and prints the resolved status.
      Parameters:
      packet - Packet that will be processed.
      Returns:
      Whether the packet came from successful API request.
    • processPacketStatusInSilence

      public boolean processPacketStatusInSilence(GeneralPacket packet)
      Processes packet status and prints the status if the API request was not successful.
      Parameters:
      packet - Packet that will be processed.
      Returns:
      Whether the packet came from successful API request.