-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Author type enum #614
Author type enum #614
Conversation
f13bcb9
to
f2f95c4
Compare
f2f95c4
to
de48c37
Compare
article-api/src/main/scala/no/ndla/articleapi/validation/ContentValidator.scala
Show resolved
Hide resolved
private def convertAuthors(authors: List[OldAuthor]): List[Author] = { | ||
authors.map(author => { | ||
ContributorType.valueOf(author.`type`.toLowerCase) match { | ||
case None => Author(ContributorType.mapping(author.`type`.toLowerCase), author.name) | ||
case Some(a) => Author(a, author.name) | ||
} | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeg henger ikke helt med på hvorfor denne migreringen trengs jeg.
Er det færre mulige typer nå, eller har de andre navn?
Må vi endre frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nei, vi må ikkje endre frontend. Men vi har en toLower i frontend som vi kan droppe. Hovedpoenget med dette er å få samme verdier overalt. I article og draft er det mest Writer
og writer
som er forskjellene, men i learningpath er det Forfatter
. Dette sikrer at alt er lowercase og kan knyttes til enum.
common/src/main/scala/no/ndla/common/model/domain/ContributorType.scala
Outdated
Show resolved
Hide resolved
|} | ||
|""".stripMargin | ||
|
||
val expected = parser.parse(newDocument).toTry.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synes dette var greit slik så slipper vi å ha expected på ei lang linje.
ac0e741
to
2bc4a1f
Compare
2bc4a1f
to
1f468c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeg liker det, LGTM!! 💯
Innfører enum for ContributorType slik at vi får ordentlig validering på lisensinfo.
Migrerer alt av eksisterende lisenser slik at disse blir i henhold til ny enum. Har også endra validering slik at vi dropper sjekk om type er korrekt siden serialisering vil feile dersom det er feil og dermed vil det aldri treffe valideringa. Innfører heller sjekk på at navn på author er større enn 0.