Class AppointmentImportJsonService
java.lang.Object
fr.paris.lutece.plugins.appointment.modules.importer.service.AppointmentImportJsonService
JSON encoding shared by the persistent importer records and reports.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringerrorsAsCsv(String strJson, Locale locale) Formats the validation errors stored instrJsonas a semicolon-separated CSV.static List<AppointmentValidationError>readErrors(String strJson) Deserializes a JSON validation-report string back to a list ofAppointmentValidationError.Deserializes a JSON string.static StringwriteErrors(List<AppointmentValidationError> listErrors) Serializes a list ofAppointmentValidationErrorto a JSON string for storage invalidation_report.static StringSerializes a map to a JSON string.
-
Method Details
-
writeMap
Serializes a map to a JSON string. Used to persist generic-attribute and form-field values in the database.- Parameters:
mapValues- the map to serialize; must not benull- Returns:
- the JSON representation
-
readMap
Deserializes a JSON string. The map preserves insertion order (LinkedHashMapunder the hood).- Parameters:
strJson- the JSON string produced bywriteMap(java.util.Map<java.lang.String, java.lang.String>)- Returns:
- the deserialized map
- Throws:
IllegalArgumentException- if the JSON is invalid
-
readErrors
Deserializes a JSON validation-report string back to a list ofAppointmentValidationError. Row-level errors have a non-nulllinefield; workbook-level errors havenull.- Parameters:
strJson- the JSON string produced bywriteErrors(java.util.List<fr.paris.lutece.plugins.appointment.modules.importer.business.AppointmentValidationError>)- Returns:
- the list of errors in original order
- Throws:
IllegalArgumentException- if the JSON is invalid
-
errorsAsCsv
Formats the validation errors stored instrJsonas a semicolon-separated CSV.- Parameters:
strJson- the serialised validation reportlocale- the locale used to localise column headers- Returns:
- the CSV string
-
writeErrors
Serializes a list ofAppointmentValidationErrorto a JSON string for storage invalidation_report. Each error is represented as{"line": <int|null>, "field": "<string>", "message": "<string>"}.- Parameters:
listErrors- the errors to serialize; must not benull- Returns:
- the JSON array string
-