Class ImportValidationSettings

java.lang.Object
fr.paris.lutece.plugins.appointment.modules.importer.service.ImportValidationSettings

public final class ImportValidationSettings extends Object
What the validation of a workbook depends on: the columns, the messages, the email check, the current date and the limits.

fromLutece(Locale) reads them from Lutece; a test builds them with the constructor.

  • Field Details

    • DEFAULT_EMAIL_FIELD_PATTERN

      public static final String DEFAULT_EMAIL_FIELD_PATTERN
      Found in the normalized title or code of a field: "email du CAR", "email_car", "Courriel"
      See Also:
  • Constructor Details

    • ImportValidationSettings

      public ImportValidationSettings(ImportColumns columns, BiFunction<String,Object[],String> messages, Predicate<String> emailChecker, LocalDateTime dtNow, int nMaxRows, int nMaxNameLength, String strPhonePattern, String strEmailFieldPattern)
      Parameters:
      columns - the standard columns
      messages - gives the localized message of a key and its arguments
      emailChecker - tells whether an email is valid
      dtNow - the current date: an appointment cannot start before it
      nMaxRows - the maximum number of rows of a workbook
      nMaxNameLength - the maximum length of a last or first name
      strPhonePattern - the pattern a phone number must match once its separators are removed
      strEmailFieldPattern - the pattern found in the normalized title or code of the form fields whose value must be an email
  • Method Details

    • fromLutece

      public static ImportValidationSettings fromLutece(Locale locale)
      Parameters:
      locale - the locale of the messages
      Returns:
      the settings of the running Lutece
    • getColumns

      public ImportColumns getColumns()
    • message

      public String message(String strKey, Object... arguments)
      Parameters:
      strKey - the i18n key
      arguments - the arguments of the message
      Returns:
      the localized message
    • isValidEmail

      public boolean isValidEmail(String strEmail)
      Parameters:
      strEmail - an email
      Returns:
      true if it is valid
    • isValidPhoneNumber

      public boolean isValidPhoneNumber(String strPhoneNumber)
      Parameters:
      strPhoneNumber - a phone number, separators removed
      Returns:
      true if it is valid
    • isEmailField

      public boolean isEmailField(String strNormalizedName)
      Parameters:
      strNormalizedName - the normalized title or code of a form field
      Returns:
      true if the value of the field must be an email
    • getNow

      public LocalDateTime getNow()
    • getMaxRows

      public int getMaxRows()
    • getMaxNameLength

      public int getMaxNameLength()