Skip to content

Commit

Permalink
Merge pull request #4264 from nationalarchives/TDRD-428-duplicate-col…
Browse files Browse the repository at this point in the history
…umn-errors

Tdrd 428 duplicate column errors
  • Loading branch information
TomJKing authored Nov 4, 2024
2 parents 4fc0bc3 + 00f711f commit 6d6e81d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/controllers/DraftMetadataChecksResultsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ class DraftMetadataChecksResultsController @Inject() (

private def getAffectedProperties(errorReport: Option[ErrorFileData]): Set[String] = {
errorReport match {
case Some(er) if er.fileError == FileError.SCHEMA_REQUIRED => er.validationErrors.flatMap(_.errors.map(_.property)).toSet
case _ => Set()
case Some(er)
if er.fileError == FileError.SCHEMA_REQUIRED
|| er.fileError == FileError.DUPLICATE_HEADER =>
er.validationErrors.flatMap(_.errors.map(_.property)).toSet
case _ => Set()
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/services/DraftMetadataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.concurrent.{ExecutionContext, Future}

object FileError extends Enumeration {
type FileError = Value
val UTF_8, INVALID_CSV, SCHEMA_REQUIRED, SCHEMA_VALIDATION, VIRUS, UNKNOWN, NONE = Value
val UTF_8, INVALID_CSV, DUPLICATE_HEADER, SCHEMA_REQUIRED, SCHEMA_VALIDATION, VIRUS, UNKNOWN, NONE = Value
}

case class Error(validationProcess: String, property: String, errorKey: String, message: String)
Expand Down
2 changes: 2 additions & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ draftMetadata.validation.details.VIRUS=A virus was found in your metadata file.
draftMetadata.validation.action.VIRUS=Please get in touch on <a href="mailto:tdr@nationalarchives.gov.uk">tdr@nationalarchives.gov.uk</a>, so that we can validate this before contacting your own internal support.
draftMetadata.validation.details.SCHEMA_REQUIRED=There was at least one missing column in your metadata file. The metadata file must contain specific column headers.
draftMetadata.validation.action.SCHEMA_REQUIRED=Add the following column headers to your metadata file and re-load.
draftMetadata.validation.details.DUPLICATE_HEADER=There was at least one duplicate column in your metadata file.
draftMetadata.validation.action.DUPLICATE_HEADER=Ensure there is only one of the following duplicated columns.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ class DraftMetadataChecksResultsControllerSpec extends FrontEndTestHelper {
"There was at least one missing column in your metadata file. The metadata file must contain specific column headers.",
"Add the following column headers to your metadata file and re-load.",
Set("Closure Status", "Description")
),
(
CompletedWithIssuesValue.value,
FileError.DUPLICATE_HEADER,
"There was at least one duplicate column in your metadata file.",
"Ensure there is only one of the following duplicated columns.",
Set("Closure Status", "Description")
)
)
forAll(draftMetadataStatuses) { (statusValue, fileError, detailsMessage, actionMessage, affectedProperties) =>
Expand Down

0 comments on commit 6d6e81d

Please sign in to comment.