From aa9bdd514ab90d0da0391b879255a22c29450e9a Mon Sep 17 00:00:00 2001 From: Szymon Szukalski Date: Thu, 25 Jul 2024 20:36:11 +1000 Subject: Validate import payload and return create/update stats - Add validation to /import payload - Move import logic to service bean - Track whether entities have been created or update - Report number of created and updated entities as return value for the import endpoint - Add some test coverage to exercise the validators --- .../markr/dto/ImportResponseDTO.java | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java (limited to 'src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java') diff --git a/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java b/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java new file mode 100644 index 0000000..8613865 --- /dev/null +++ b/src/main/java/com/stileeducation/markr/dto/ImportResponseDTO.java @@ -0,0 +1,115 @@ +package com.stileeducation.markr.dto; + +public class ImportResponseDTO { + + private String status; + private String message; + private ImportData data; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public ImportData getData() { + return data; + } + + public void setData(ImportData data) { + this.data = data; + } + + public static class ImportData { + private int studentsCreated = 0; + private int studentsUpdated = 0; + + private int testsCreated = 0; + private int testsUpdated = 0; + + private int testResultsCreated = 0; + private int testResultsUpdated = 0; + + public int getStudentsCreated() { + return studentsCreated; + } + + public void setStudentsCreated(int studentsCreated) { + this.studentsCreated = studentsCreated; + } + + public int getStudentsUpdated() { + return studentsUpdated; + } + + public void setStudentsUpdated(int studentsUpdated) { + this.studentsUpdated = studentsUpdated; + } + + public int getTestsCreated() { + return testsCreated; + } + + public void setTestsCreated(int testsCreated) { + this.testsCreated = testsCreated; + } + + public int getTestsUpdated() { + return testsUpdated; + } + + public void setTestsUpdated(int testsUpdated) { + this.testsUpdated = testsUpdated; + } + + public int getTestResultsCreated() { + return testResultsCreated; + } + + public void setTestResultsCreated(int testResultsCreated) { + this.testResultsCreated = testResultsCreated; + } + + public int getTestResultsUpdated() { + return testResultsUpdated; + } + + public void setTestResultsUpdated(int testResultsUpdated) { + this.testResultsUpdated = testResultsUpdated; + } + + public void incrementStudentsCreated() { + this.studentsCreated++; + } + + public void incrementStudentsUpdated() { + this.studentsUpdated++; + } + + public void incrementTestsCreated() { + this.testsCreated++; + } + + public void incrementTestsUpdated() { + this.testsUpdated++; + } + + public void incrementTestResultsCreated() { + this.testResultsCreated++; + } + + public void incrementTestResultsUpdated() { + this.testResultsUpdated++; + } + } +} -- cgit v1.2.3