Repository navigation
feat: add value objects to list routes - old and new (DEV-65) - #1917
Conversation
|
|
||
| val unescapedLabels = stringFormatter.unescapeStringLiteralSeq(labels) | ||
| val unescapedComments = stringFormatter.unescapeStringLiteralSeq(comments) | ||
| val unescapedComments = stringFormatter.unescapeStringLiteralSeq(comments.get) |
There was a problem hiding this comment.
What will happen if comments is None?
| */ | ||
| def getCommentInPreferredLanguage(userLang: String, fallbackLang: String): Option[String] = | ||
| comments.getPreferredLanguage(userLang, fallbackLang) | ||
| comments.get.getPreferredLanguage(userLang, fallbackLang) |
There was a problem hiding this comment.
What will happen if comments is None?
| "name" -> child.name.toJson, | ||
| "labels" -> JsArray(child.labels.stringLiterals.map(_.toJson)), | ||
| "comments" -> JsArray(child.comments.stringLiterals.map(_.toJson)), | ||
| "comments" -> JsArray(child.comments.get.stringLiterals.map(_.toJson)), |
There was a problem hiding this comment.
What will happen if comments is None?
| val LIST_NODE_IRI_INVALID_ERROR = "List node IRI is invalid." | ||
| val PROJECT_IRI_MISSING_ERROR = "Project IRI cannot be empty." | ||
| val PROJECT_IRI_INVALID_ERROR = "Project IRI is invalid." | ||
| val LIST_NAME_MISSING_ERROR = "List name cannot be empty." |
There was a problem hiding this comment.
A better name for ListsMessagesUtilADM would be ListsErrorMessagesADM
| } else { | ||
| val validatedLabels = Try(value.map { label => | ||
| val validatedLabel = | ||
| stringFormatter.toSparqlEncodedString(label.value, throw BadRequestException(LABEL_INVALID_ERROR)) |
There was a problem hiding this comment.
I think that you need to wrap the stringFormatter call into a Try and not the whole sequence.
There was a problem hiding this comment.
Tried it out again and looks like I need to have the outer Try anyway, to perform final match.
| } else { | ||
| val validatedComments = Try(value.map { comment => | ||
| val validatedComment = | ||
| stringFormatter.toSparqlEncodedString(comment.value, throw BadRequestException(COMMENT_INVALID_ERROR)) |
There was a problem hiding this comment.
I think that you need to wrap the stringFormatter call into a Try and not the whole sequence.
There was a problem hiding this comment.
I've tried the other way, but didn't work.
| makeMapIriToJSONLDString(OntologyConstants.Rdfs.Label, node.labels, userLang, fallbackLang) | ||
| val comment: Map[IRI, JsonLDString] = | ||
| makeMapIriToJSONLDString(OntologyConstants.Rdfs.Comment, node.comments, userLang, fallbackLang) | ||
| makeMapIriToJSONLDString(OntologyConstants.Rdfs.Comment, node.comments.get, userLang, fallbackLang) |
There was a problem hiding this comment.
What happens if comments is None?
| featureFactoryConfig: FeatureFactoryConfig | ||
| ): Future[IRI] = { | ||
|
|
||
| // println("ZZZZZ-createNode", createNodeRequest) |
There was a problem hiding this comment.
Yes and not, left few commented out prints, just for a reference to other routes refactoring - will remove when finish that.
|
@mpro7 you should also take a look at the code smells from from Sonar and get rid of those. |
|
@subotic most of the smells are TODOs which I added in places where I have either a question or somethings needs to be change in next tasks. Duplications are mainly caused by having 2 very similar route implementations - new and old. Could be removed if some parts of code would be moved to external helper methods. Not sure if we need it on this refactoring stage? Another thing is that some code smells are ridiculous, like here https://sonarcloud.io/project/issues?id=dasch-swiss_dsp-api&open=AXy9QqxAZq5_O1fmTzTh&pullRequest=1917&resolved=false&types=CODE_SMELL Not sure if this is my fault creating to generic messages or this test layout isn't the best to use for unit tests, because of so many cascades and repetitions... |
| id, | ||
| name, | ||
| labels, | ||
| comments = comments match { |
There was a problem hiding this comment.
tip: you could use .getOrElse(StringLiteralSequenceV2(Vector.empty[StringLiteralV2])) instead of the match
|
SonarCloud Quality Gate failed.
|








resolves DEV-65