Skip to content

Commit

Permalink
Merge pull request #537 from digital-preservation/DR2-2069_makeUiRefi…
Browse files Browse the repository at this point in the history
…nements

DR2 2069 Make UI refinements
  • Loading branch information
techncl authored Feb 12, 2025
2 parents 57e46ae + 6c6af64 commit 99da52c
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class RowIterator(parser: CsvParser, progress: Option[ProgressFor], maxCharsPerC
case Failure(ex: TextParsingException) if(ex.toString.contains("exceeds the maximum number of characters")) =>
val cellLocationMsg =
potentialHeaderRow match {
case Some(headerRow) => s"in the cell located at line: ${ex.getLineIndex}, column: ${headerRow.cells(ex.getColumnIndex).value},"
case Some(headerRow) => s"in the cell located at row: ${ex.getLineIndex}, column: ${headerRow.cells(ex.getColumnIndex).value},"
case None => s"in column ${ex.getColumnIndex + 1} of the header row"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ abstract class Rule(name: String, val argProviders: ArgProvider*) extends Positi

def fail(columnIndex: Int, row: Row, schema: Schema): RuleValidation[Any] = {
val columnDefinition = schema.columnDefinitions(columnIndex)
s"$toError fails for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
s"$toError fails for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
}

def cellValue(columnIndex: Int, row: Row, schema: Schema): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ case class UniqueRule() extends Rule("unique") {
originalValue match {
case None => distinctValues.put(cellValueCorrectCase, row.lineNumber); true.validNel
case Some(o) => {
s"$toError fails for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)} (original at line: ${distinctValues(o)})".invalidNel[Any]
s"$toError fails for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)} (original at row: ${distinctValues(o)})".invalidNel[Any]
}
}
}
Expand All @@ -304,7 +304,7 @@ case class UniqueMultiRule(columns: List[ColumnReference]) extends Rule("unique(
originalValue match {
case None => distinctValues.put(cellValueCorrectCase, row.lineNumber); true.validNel
case Some(o) => {
s"$toError ${columns.map(_.toError).mkString(", ")} ) fails for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)} (original at line: ${distinctValues(o)})".invalidNel[Any]
s"$toError ${columns.map(_.toError).mkString(", ")} ) fails for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)} (original at row: ${distinctValues(o)})".invalidNel[Any]
}
}
}
Expand All @@ -322,8 +322,8 @@ case class ChecksumRule(rootPath: ArgProvider, file: ArgProvider, algorithm: Str
} else {
search(filename(columnIndex, row, schema)) match {
case Validated.Valid(hexValue: String) if hexValue == cellValue(columnIndex, row, schema) => true.validNel[String]
case Validated.Valid(hexValue: String) => s"""$toError file "${TypedPath(filename(columnIndex, row, schema)._1 + filename(columnIndex, row, schema)._2).toPlatform}" checksum match fails for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row, columnIndex)}. Computed checksum value:"${hexValue}"""".invalidNel[Any]
case Validated.Invalid(errMsg) => s"$toError ${errMsg.head} for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row, columnIndex)}".invalidNel[Any]
case Validated.Valid(hexValue: String) => s"""$toError file "${TypedPath(filename(columnIndex, row, schema)._1 + filename(columnIndex, row, schema)._2).toPlatform}" checksum match fails for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row, columnIndex)}. Computed checksum value:"${hexValue}"""".invalidNel[Any]
case Validated.Invalid(errMsg) => s"$toError ${errMsg.head} for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row, columnIndex)}".invalidNel[Any]
}
}
}
Expand Down Expand Up @@ -458,11 +458,11 @@ case class FileCountRule(rootPath: ArgProvider, file: ArgProvider, pathSubstitut
case scala.util.Success(cellCount) =>
search(filename(columnIndex, row, schema)) match {
case Validated.Valid(count: Int) if count == cellCount => true.validNel[String]
case Validated.Valid(count: Int) => s"$toError found $count file(s) for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
case Validated.Invalid(errMsg) => s"$toError ${errMsg.head} for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
case Validated.Valid(count: Int) => s"$toError found $count file(s) for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
case Validated.Invalid(errMsg) => s"$toError ${errMsg.head} for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
}

case scala.util.Failure(_) => s"$toError '${cellValue(columnIndex,row,schema)}' is not a number for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
case scala.util.Failure(_) => s"$toError '${cellValue(columnIndex,row,schema)}' is not a number for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${toValueError(row,columnIndex)}".invalidNel[Any]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ case class IntegrityCheckRule(pathSubstitutions: List[(String,String)], enforceC
catch {
case ex: FileNotFoundException =>
val columnDefinition = schema.columnDefinitions(columnIndex)
s"$toError fails for line: ${row.lineNumber}, column: ${columnDefinition.id}, ${ex.getMessage} with substitution paths ${pathSubstitutions.mkString(", ")}".invalidNel[Any]
s"$toError fails for row: ${row.lineNumber}, column: ${columnDefinition.id}, ${ex.getMessage} with substitution paths ${pathSubstitutions.mkString(", ")}".invalidNel[Any]
}
}

Expand Down
Loading

0 comments on commit 99da52c

Please sign in to comment.