Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 7752a36
Show file tree
Hide file tree
Showing 21 changed files with 1,086 additions and 748 deletions.
@@ -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
)
Expand Up @@ -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."
Expand Down

0 comments on commit 7752a36

Please sign in to comment.