Skip to content
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

feat (admin): Add edit list item route #1447

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
23042d7
feat (admin): Add edit list item route (ongoing)
subotic Sep 24, 2019
f464797
Merge branch 'develop' into wip/1387-edit-list-item
subotic Oct 3, 2019
b94f851
Merge branch 'develop' into wip/1387-edit-list-item
subotic Nov 5, 2019
08ea8d5
Merge branch 'develop' into wip/1387-edit-list-item
subotic Nov 26, 2019
4572d19
docs (webapi): Update list docs
subotic Nov 26, 2019
f56ef84
update lists doc
LukasStoeckli Nov 26, 2019
c6423f4
ongoing(webapi): fix lists routing order of entry
LukasStoeckli Nov 26, 2019
ecce68e
ongoing(webapi): refactor ListRoute and adapt docs
LukasStoeckli Dec 3, 2019
b2d927d
test(webapi): adapt list routes
LukasStoeckli Dec 5, 2019
a4278ff
test(webapi): refactor, fix & expand listADME2E tests
LukasStoeckli Dec 6, 2019
4987b52
feat(webapi): update basic list information
LukasStoeckli Dec 10, 2019
e49a003
Merge branch 'develop' into wip/1387-edit-list-item
LukasStoeckli Dec 10, 2019
7358b10
ongoing(webapi): NONWORKING progress of basic list node information u…
LukasStoeckli Dec 13, 2019
2570ad6
feat(webapi): update basic list node information
LukasStoeckli Dec 16, 2019
26f574f
feat(webapi): name in changeListInfo must me unique in project
LukasStoeckli Dec 16, 2019
dbabdeb
feat(webapi): name in changeListNodeInfo must be unique in project
LukasStoeckli Dec 16, 2019
6b8a465
test(webapi): fix listResponderADM test
LukasStoeckli Dec 17, 2019
6dba1bc
Merge branch 'develop' into wip/1387-edit-list-item
LukasStoeckli Dec 17, 2019
f58c71b
fix(webapi): fix previous merge
LukasStoeckli Dec 17, 2019
595334d
fix(webapi): change list responder unique name
LukasStoeckli Dec 17, 2019
9b9fb7a
fix(webapi): adapt scope of iri lock for changeInfo
LukasStoeckli Dec 17, 2019
ada42e7
feat(webapi): independent routes for change list/node attributes
LukasStoeckli Dec 20, 2019
4085862
refactor(webapi): check list/node-name unique only if name update
LukasStoeckli Dec 23, 2019
e4e2659
Merge branch 'develop' into wip/1387-edit-list-item
LukasStoeckli Dec 23, 2019
c894a0c
fix(webapi): fix previous merge
LukasStoeckli Dec 23, 2019
f255ce5
fix(webapi): replace blocking awaits in edit list item
LukasStoeckli Jan 7, 2020
1c11060
Merge branch 'develop' into wip/1387-edit-list-item
LukasStoeckli Jan 10, 2020
abc858e
feat(webapi): change 'admin/nodes' to 'admin/lists/nodes'
LukasStoeckli Jan 10, 2020
a36e3e6
fix(webapi): adapt API path and refactor clientCode
LukasStoeckli Jan 10, 2020
67b19e5
feat(api-admin): Update client API defs for list endpoint (ongoing).
Jan 13, 2020
e6cf8fb
feat(api-admin): Update client API defs for list endpoint.
Jan 13, 2020
9c6fb12
Merge branch 'develop' into wip/1387-edit-list-item
Jan 13, 2020
7280800
Merge branch 'develop' into wip/1387-edit-list-item
Feb 7, 2020
e2a8481
Merge branch 'develop' into wip/1387-edit-list-item
Feb 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 144 additions & 34 deletions docs/src/paradox/03-apis/api-admin/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,49 @@ License along with Knora. If not, see <http://www.gnu.org/licenses/>.

**List Operations:**

- `GET: /admin/lists[?projectIri=<projectIri>]` : return all lists optionally filtered by project
- `GET: /admin/lists/<listIri>` : return complete list with children
- `GET: /admin/lists[?projectIRI=<projectIRI>]` : return all lists optionally filtered by project
- `GET: /admin/lists/<listIRI>` : return complete list with children
- `POST: /admin/lists` : create new list
- `POST: /admin/lists/<nodeIri>` : create new child node under the supplied parent node IRI
- NOT IMPLEMENTED: `DELETE: /admin/lists/<listIri>` : delete list including children if not used
- `GET: /admin/lists/infos/<listIri>` : return list information (without children)
- `PUT: /admin/lists/infos/<listIri>` : update list information
- NOT IMPLEMENTED: `PUT: /admin/lists/<listIRI>` : create new list with given IRI
- NOT IMPLEMENTED: `DELETE: /admin/lists/<listIRI>` : delete list including children if not used
- `GET: /admin/lists/<listIRI>/Info` : return list information (without children)
- `PUT: /admin/lists/<listIRI>/ListInfoName` : update list name information
- `PUT: /admin/lists/<listIRI>/ListInfoLabel` : update list label information
- `PUT: /admin/lists/<listIRI>/ListInfoComment` : update list comment information



**List Node operations**

- `GET: /admin/lists/nodes/<nodeIri>` : return list node information (without children)
- NOT IMPLEMENTED: `POST: /admin/lists/nodes/<nodeIri>` : update list node information
- NOT IMPLEMENTED: `DELETE: /admin/lists/nodes/<nodeIri>` : delete list node including children if not used
- NOT IMPLEMENTED: `GET: /admin/lists/nodes/<nodeIRI>` : return list node information (with children)
- `GET: /admin/lists/nodes/<nodeIRI>/Info` : return list node information (without children)
- `POST: /admin/lists/nodes` : create new child node under the supplied parent node IRI
- NOT IMPLEMENTED: `PUT: /admin/lists/nodes/<nodeIRI>` : create child node with given IRI und the supplied parent node IRI
- `PUT: /admin/lists/nodes/<nodeIRI>/NodeInfoName` : update list node name information
- `PUT: /admin/lists/nodes/<nodeIRI>/NodeInfoLabel` : update list node label information
- `PUT: /admin/lists/nodes/<nodeIRI>/NodeInfoComment` : update list node comment information
- NOT IMPLEMENTED: `PUT: /admin/lists/nodes/<nodeIRI>/NodeInfoPosition` : update list node position information
- NOT IMPLEMENTED: `PUT: /admin/lists/nodes/<nodeIRI>/NodeInfoParent` : update list node parent information
- NOT IMPLEMENTED: `DELETE: /admin/lists/nodes/<nodeIRI>` : delete list node including children if not used

## List Operations

### Get lists

- Required permission: none
- Return all lists optionally filtered by project
- GET: `/admin/lists[?projectIri=<projectIri>]`
- GET: `/admin/lists[?projectIRI=<projectIRI>]`

### Get list

- Required permission: none
- Return complete list with children
- GET: `/admin/lists/<listIri>`
- GET: `/admin/lists/<listIRI>`


### Create new list

- Required permission: SystemAdmin / ProjectAdmin
- Required permission: SystemAdmin or ProjectAdmin
- POST: `/admin/lists`
- BODY:
```
Expand All @@ -65,13 +76,88 @@ License along with Knora. If not, see <http://www.gnu.org/licenses/>.
}
```

### Get list's information

- Required permission: none
- Return list information (without children)
- GET: `/admin/lists/<listIRI>/Info`

### Update lists's name information

- Required permission: SystemAdmin or ProjectAdmin
- Update list name information
- PUT: `/admin/lists/<listIri>/ListInfoName`
- BODY
```
{
"listIri": "listIri",
"projectIri": "projectIri",
"name": "name"
}
```
- Submit empty parameter (`"name": ""`) to delete name
- `name` must be unique inside project

### Update list's label information

- Required permission: SystemAdmin or ProjectAdmin
- Update list label information
- PUT: `/admin/lists/<listIri>/ListInfoLabel`
- BODY
```
{
"listIri": "listIri",
"projectIri": "projectIri",
"labels": [{"value": "New label", "language": "en"}]
}
```
- At least one label must be submitted

### Update list's comment information

- Required permission: SystemAdmin or ProjectAdmin
- Update list comment information
- PUT: `/admin/lists/<listIri>/ListInfoName`
- BODY
```
{
"listIri": "listIri",
"projectIri": "projectIri",
"comment": [{"value": "New Comment", "language": "en"}]
}
```
- Submit empty parameter (`"comment": []`) to delete comments



### Delete list

- Required permission: SystemAdmin or ProjectAdmin
- Delete List including children if not used
- DELETE: `/admin/lists/<listIRI>`


## List Node Operations

### Get List Node

- Required permission: none
- Return list node with children
- GET: `/admin/lists/nodes/<nodeIRI>`

### Get node's information

- Required permission: none
- Return node information (without children)
- GET: `/admin/lists/node/<nodeIRI>/Info`

### Create new child node

- Required permission: SystemAdmin / ProjectAdmin
- Required permission: SystemAdmin or ProjectAdmin
- Appends a new child node under the supplied nodeIri. If the supplied nodeIri
is the listIri, then a new child node is appended to the top level. Children
are currently only appended.
- POST: `/admin/lists/<nodeIri>`
- POST: `/admin/lists/nodes`
- BODY:
```
{
Expand All @@ -82,32 +168,56 @@ License along with Knora. If not, see <http://www.gnu.org/licenses/>.
"comments": [{ "value": "New First Child List Node Comment", "language": "en"}]
}
```

### Delete List node

### Get list's information

- Required permission: none
- Return list information (without children)
- GET: `/admin/lists/infos/<listIri>`
- Required permission: SystemAdmin or ProjectAdmin
- Delete node including children if not used
- DELETE: `/admin/lists/nodes/<nodeIRI>`

### Update list's information
### Update node's name information

- Required permission: none
- Update list information
- PUT: `/admin/lists/infos/<listIri>`
- BODY:
- Required permission: SystemAdmin or ProjectAdmin
- Update list node name information
- PUT: `/admin/lists/nodes/<nodeIRI>/NodeInfoName`
- BODY
```
{
"listIri": "listIri",
"projectIri": "someprojectiri",
"labels": [{ "value": "Neue geönderte Liste", "language": "de"}, { "value": "Changed list", "language": "en"}],
"comments": [{ "value": "Neuer Kommentar", "language": "de"}, { "value": "New comment", "language": "en"}]
"nodeIri": "nodeIri",
"projectIri": "projectIri",
"name": "name"
}
```
- Submit empty parameter (`"name": ""`) to delete name
- `name` must be unique inside project

### Update node's label information

## List Node Operations

### Get List Node Information
- Required permission: SystemAdmin or ProjectAdmin
- Update list node label information
- PUT: `/admin/lists/nodes/<nodeIRI>/NodeInfoLabel`
- BODY
```
{
"nodeIri": "nodeIri",
"projectIri": "projectIri",
"labels": [{"value": "New label", "language": "en"}]
}
```
- At least one label must be submitted

### Update node's comment information

- Required permission: none
- Return list node information (without children)
- GET: `/admin/lists/nodes/<nodeIri>`
- Required permission: SystemAdmin or ProjectAdmin
- Update list node comment information
- PUT: `/admin/lists/nodes/<nodeIRI>/NodeInfoName`
- BODY
```
{
"nodeIri": "nodeIri",
"projectIri": "projectIri",
"comment": [{"value": "New Comment", "language": "en"}]
}
```
- Submit empty parameter (`"comment": []`) to delete comments

115 changes: 111 additions & 4 deletions webapi/src/main/scala/org/knora/webapi/SharedTestDataADM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectADM
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2
import org.knora.webapi.util.StringFormatter
import spray.json.{JsArray, JsObject, JsString}

/**
* This object holds the same user which are loaded with '_test_data/all_data/admin-data.ttl'. Using this object
Expand Down Expand Up @@ -632,19 +633,125 @@ object SharedTestDataADM {
val createListRequest: String =
s"""{
| "projectIri": "${SharedTestDataADM.ANYTHING_PROJECT_IRI}",
| "name": "newList",
| "labels": [{ "value": "Neue Liste", "language": "de"}],
| "comments": []
|}""".stripMargin

def updateListInfoRequest(listIri: IRI): String = {
def updateListNameRequest(listIri: IRI, projectIri: IRI, name: String): String = {
s"""{
| "listIri": "$listIri",
| "projectIri": "${SharedTestDataADM.ANYTHING_PROJECT_IRI}",
| "labels": [{ "value": "Neue geänderte Liste", "language": "de"}, { "value": "Changed list", "language": "en"}],
| "comments": [{ "value": "Neuer Kommentar", "language": "de"}, { "value": "New comment", "language": "en"}]
| "projectIri": "$projectIri",
| "name": "$name"
|}""".stripMargin
}

def updateListLabelsRequest(listIri: IRI, projectIri: IRI, labels: Vector[Map[String, String]]): String = {
JsObject(
Map(
"listIri" -> JsString(listIri),
"projectIri" -> JsString(projectIri),
"labels" -> JsArray(
labels.map {
labelMap =>
JsObject(
labelMap.map {
case (key, value) => key -> JsString(value)
}
)
}
)
)
).prettyPrint
}

def updateListCommentsRequest(listIri: IRI, projectIri: IRI, comments: Vector[Map[String, String]]): String = {
JsObject(
Map(
"listIri" -> JsString(listIri),
"projectIri" -> JsString(projectIri),
"comments" -> JsArray(
comments.map {
labelMap =>
JsObject(
labelMap.map {
case (key, value) => key -> JsString(value)
}
)
}
)
)
).prettyPrint
}

def updateListNodeNameRequest(nodeIri: IRI, projectIri: IRI, name: String): String = {
s"""{
| "nodeIri": "$nodeIri",
| "projectIri": "$projectIri",
| "name": "$name"
|}""".stripMargin
}

def updateListNodeLabelsRequest(nodeIri: IRI, projectIri: IRI, labels: Vector[Map[String, String]]): String = {
JsObject(
Map(
"nodeIri" -> JsString(nodeIri),
"projectIri" -> JsString(projectIri),
"labels" -> JsArray(
labels.map {
labelMap =>
JsObject(
labelMap.map {
case (key, value) => key -> JsString(value)
}
)
}
)
)
).prettyPrint
}

def updateListNodeCommentsRequest(nodeIri: IRI, projectIri: IRI, comments: Vector[Map[String, String]]): String = {
JsObject(
Map(
"nodeIri" -> JsString(nodeIri),
"projectIri" -> JsString(projectIri),
"comments" -> JsArray(
comments.map {
labelMap =>
JsObject(
labelMap.map {
case (key, value) => key -> JsString(value)
}
)
}
)
)
).prettyPrint
}

val updatedLabels: Vector[Map[String, String]] = Vector(
Map(
"value" -> "Geändertes Etikett",
"language" -> "de"
),
Map(
"value" -> "Changed label",
"language" -> "en"
)
)

val updatedComments: Vector[Map[String, String]] = Vector(
Map(
"value" -> "Geänderter Kommentar",
"language" -> "de"
),
Map(
"value" -> "Changed comment",
"language" -> "en"
)
)

def addChildListNodeRequest(parentNodeIri: IRI,
name: String,
label: String,
Expand Down
Loading