Class FormRecognizerServiceImpl

java.lang.Object
com.markvarga21.studentmanager.service.form.impl.FormRecognizerServiceImpl
All Implemented Interfaces:
FormRecognizerService

@Component @Generated public class FormRecognizerServiceImpl extends Object implements FormRecognizerService
A service which is used to verify the data entered by the user against the data which can be found on the uploaded passport. It uses Azure's Form Recognizer services.
  • Field Details

    • EMPTY_FIELD_VALUE

      public static final String EMPTY_FIELD_VALUE
      The default value if the field is empty.
      See Also:
  • Constructor Details

    • FormRecognizerServiceImpl

      public FormRecognizerServiceImpl()
  • Method Details

    • getFieldsFromDocument

      public Map<String,com.azure.ai.formrecognizer.documentanalysis.models.DocumentField> getFieldsFromDocument(org.springframework.web.multipart.MultipartFile passport)
      Extracts all fields from the uploaded passport.
      Specified by:
      getFieldsFromDocument in interface FormRecognizerService
      Parameters:
      passport - The uploaded passport.
      Returns:
      The extracted fields stored in a Map.
    • extractDataFromPassport

      public StudentDto extractDataFromPassport(org.springframework.web.multipart.MultipartFile passport)
      Extracts and returns the data from the passport.
      Specified by:
      extractDataFromPassport in interface FormRecognizerService
      Parameters:
      passport - The photo of the passport.
      Returns:
      The extracted StudentDto object.
    • validatePassport

      public PassportValidationResponse validatePassport(String studentJson, org.springframework.web.multipart.MultipartFile passport)
      Validates the data entered by the user against the data, which can be found-, and has been extracted from the passport.
      Specified by:
      validatePassport in interface FormRecognizerService
      Parameters:
      studentJson - The student itself in a JSON String format.
      passport - The passport file.
      Returns:
      A PassportValidationResponse object.
    • deletePassportValidationByPassportNumber

      public String deletePassportValidationByPassportNumber(String passportNumber)
      Deletes a passport validation data identified by the passport number.
      Specified by:
      deletePassportValidationByPassportNumber in interface FormRecognizerService
      Parameters:
      passportNumber - The passport number.
      Returns:
      A feedback message.
    • validatePassportManually

      public String validatePassportManually(Long studentId)
      Validates the passport manually.
      Specified by:
      validatePassportManually in interface FormRecognizerService
      Parameters:
      studentId - The id of the student.
      Returns:
      An informational message.
    • isUserValid

      public Boolean isUserValid(String passportNumber)
      Checks if the user is valid or not.
      Specified by:
      isUserValid in interface FormRecognizerService
      Parameters:
      passportNumber - The passport number.
      Returns:
      true if the user is valid, false otherwise.