Skip to content
Permalink
Browse files
feat: add value objects to list routes - old and new (DEV-65) (#1917)
* refactor: fix filename

* feat: add create list payload & value objects

* feat: add update list payload & value objects + update routes & responder

* test: update test data

* many things happened, mainly add ChangeNodeInfoPayloadADM

* update NodeCreatePayloadADM class

* refactor list payloads

* WIP - fix tests

* fix tests

* separate root and child nodes creation

* WIP: fix tests

* bring back ListChildNodeInfoADM non-optional comments

* fix tests

* update tests

* refactor list value objects + add tests

* remove redundant fields from RootNodeCreatePayloadADM

* refactor list naming + remove redundand request type

* fix test

* add ProjectIRI value object

* add CustomID value object

* add ListIRI value object

* add RootNodeIRI value object

* fix tests

* update value objects + add unit tests

* update value objects

* remove RootNodeIRI value object

* add more checks to value objects + update tests

* remove redundand tests

* fix optional comments creating child node

* clenup

* review fixes

* minor improvements
  • Loading branch information
mpro7 committed Oct 29, 2021
1 parent 2d39a1f commit 7752a364e2e361f354c060b428f9e565edd15741
Showing with 1,086 additions and 748 deletions.
  1. 0 ...webapi/messages/admin/responder/groupsmessages/{GroupsPayloadsADM.scala → GroupPayloadsADM.scala}
  2. +68 −0 webapi/src/main/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListPayloadsADM.scala
  3. +6 −1 ...messages/admin/responder/listsmessages/{ListsMessagesUtilADM.scala → ListsErrorMessagesADM.scala}
  4. +40 −174 webapi/src/main/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADM.scala
  5. +155 −0 .../src/main/scala/org/knora/webapi/messages/admin/responder/valueObjects/ListsValueObjectsADM.scala
  6. +13 −15 webapi/src/main/scala/org/knora/webapi/messages/admin/responder/valueObjects/ValueObjectsADM.scala
  7. +9 −4 webapi/src/main/scala/org/knora/webapi/messages/v2/responder/listsmessages/ListsMessagesV2.scala
  8. +129 −77 webapi/src/main/scala/org/knora/webapi/responders/admin/ListsResponderADM.scala
  9. +2 −2 webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala
  10. +125 −9 webapi/src/main/scala/org/knora/webapi/routing/admin/lists/NewListsRouteADMFeature.scala
  11. +144 −10 webapi/src/main/scala/org/knora/webapi/routing/admin/lists/OldListsRouteADMFeature.scala
  12. +18 −5 webapi/src/main/scala/org/knora/webapi/routing/admin/lists/UpdateListItemsRouteADM.scala
  13. +10 −8 ...i/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewListNode.scala.txt
  14. +10 −10 webapi/src/test/scala/org/knora/webapi/e2e/admin/lists/NewListsRoutesADMFeatureE2ESpec.scala
  15. +10 −12 webapi/src/test/scala/org/knora/webapi/e2e/admin/lists/OldListsRouteADMFeatureE2ESpec.scala
  16. +39 −5 webapi/src/test/scala/org/knora/webapi/e2e/admin/lists/UpdateListItemsRouteADME2ESpec.scala
  17. +21 −349 ...src/test/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADMSpec.scala
  18. +1 −0 webapi/src/test/scala/org/knora/webapi/messages/admin/responder/valueObjects/BUILD.bazel
  19. +162 −0 .../test/scala/org/knora/webapi/messages/admin/responder/valueObjects/ListsValueObjectsADMSpec.scala
  20. +117 −60 webapi/src/test/scala/org/knora/webapi/responders/admin/ListsResponderADMSpec.scala
  21. +7 −7 webapi/src/test/scala/org/knora/webapi/sharedtestdata/SharedListsTestDataADM.scala
@@ -0,0 +1,68 @@
package org.knora.webapi.messages.admin.responder.listsmessages

import org.knora.webapi.messages.admin.responder.valueObjects.{
Comments,
Labels,
ListIRI,
ListName,
Position,
ProjectIRI
}

/**
* List (parent node, former root node) and Node (former child node) creation payloads
*/
sealed trait NodeCreatePayloadADM
object NodeCreatePayloadADM {
final case class ListCreatePayloadADM(
id: Option[ListIRI] = None,
projectIri: ProjectIRI,
name: Option[ListName] = None,
labels: Labels,
comments: Comments
) extends NodeCreatePayloadADM
final case class ChildNodeCreatePayloadADM(
id: Option[ListIRI] = None,
parentNodeIri: Option[ListIRI] = None,
projectIri: ProjectIRI,
name: Option[ListName] = None,
position: Option[Position] = None,
labels: Labels,
comments: Option[Comments] = None
) extends NodeCreatePayloadADM
}

/**
* Node Info update payload
*/
final case class NodeInfoChangePayloadADM(
listIri: ListIRI,
projectIri: ProjectIRI,
hasRootNode: Option[ListIRI] = None,
position: Option[Position] = None,
name: Option[ListName] = None,
labels: Option[Labels] = None,
comments: Option[Comments] = None
)

/**
* Node Name update payload
*/
final case class NodeNameChangePayloadADM(
name: ListName
)

/**
* Node Labels update payload
*/
final case class NodeLabelsChangePayloadADM(
labels: Labels
)

/**
* Node Comments update payload
*/
final case class NodeCommentsChangePayloadADM(
// TODO: remove Option here
comments: Option[Comments] = None
)
@@ -5,14 +5,19 @@

package org.knora.webapi.messages.admin.responder.listsmessages

object ListsMessagesUtilADM {
object ListsErrorMessagesADM {
val LIST_IRI_MISSING_ERROR = "List IRI cannot be empty."
val LIST_IRI_INVALID_ERROR = "List IRI cannot be empty."
val LIST_NODE_IRI_MISSING_ERROR = "List node IRI cannot be empty."
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."
val LIST_NAME_INVALID_ERROR = "List name is invalid."
val LABEL_MISSING_ERROR = "At least one label needs to be supplied."
val LABEL_INVALID_ERROR = "Invalid label."
val COMMENT_MISSING_ERROR = "At least one comment needs to be supplied."
val COMMENT_INVALID_ERROR = "Invalid comment."
val LIST_CREATE_PERMISSION_ERROR = "A list can only be created by the project or system administrator."
val LIST_NODE_CREATE_PERMISSION_ERROR = "A list node can only be created by the project or system administrator."
val LIST_CHANGE_PERMISSION_ERROR = "A list can only be changed by the project or system administrator."
Loading

0 comments on commit 7752a36

Please sign in to comment.