Skip to content

Commit 24e34dd

Browse files
authored
refactor(lists+groups): improve value objects + remove new lists implementation (DEV-160) (#1932)
* refactor group create payload * separate group route value object * add group iri value object * use project IRI in group create patload + add group value object error messages & test * updated groups value objects and tests * add value objects to groups update payload * move optional params to value objects + replace either by zio.Validation * refactor(list): replace Either with zio.Validation + move option to value objects * refactor projectIri value object * fix node creation * add validation to payloads creation in lists and groups * remove doubled checks and related tests * disable new list route + separate NodeApiRequestADM to root & child * list route factory + new list route implementation * refactor list naming * make parentNodeIri required for ListChildNodeCreatePayloadADM * fix tests * refactor lists get methods * update lists docs * fix update single lists properties + groups cleanup * fix client-test-data * bring back GET methods * fix file extension * fix testdata
1 parent ca0c532 commit 24e34dd

44 files changed

Lines changed: 1238 additions & 3221 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/03-apis/api-admin/groups.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ hasProjectRestrictedGroupAdminPermission (for this group)
8787
- PUT: `/admin/groups/<groupIri>/status`
8888
- BODY:
8989

90-
```
90+
```json
9191
{
9292
"status": false
9393
}

‎docs/03-apis/api-admin/index.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ The Knora admin API makes it possible to administer Knora projects, users, user
1313
- [Projects Endpoint](projects.md)
1414
- [Groups Endpoint](groups.md)
1515
- [Lists Endpoint](lists.md)
16-
- [New Lists Endpoint](lists_new-list-admin-routes_v1.md)
1716
- [Permissions Endpoint](permissions.md)
1817
- [Stores Endpoint](stores.md)

‎docs/03-apis/api-admin/lists.md‎

Lines changed: 103 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
**List Item Operations:**
1111

1212
- `GET: /admin/lists[?projectIri=<projectIri>]` : return all lists optionally filtered by project
13-
- `GET: /admin/lists/<listItemIri>` : return complete list with all children if IRI of the list (i.e. root node) is given.
14-
If IRI of the child node is given, return the node with its immediate children.
13+
- `GET: /admin/lists/<listItemIri>` : return complete list with all children if IRI of the list (i.e. root node) is given
14+
If IRI of the child node is given, return the node with its immediate children
1515
- `GET: /admin/lists/infos/<listIri>` : return list information (without children)
1616
- `GET: /admin/lists/nodes/<nodeIri>` : return list node information (without children)
17+
- `GET: /admin/lists/<listIri>/info` : return list basic information (without children)
1718

1819
- `POST: /admin/lists` : create new list
1920
- `POST: /admin/lists/<parentNodeIri>` : create new child node under the supplied parent node IRI
2021

21-
- `PUT: /admin/lists/<listItemIri>` : update node information (root or child.)
22-
- `PUT: /admin/lists/<listItemIri>/name` : update the name of the node (root or child).
23-
- `PUT: /admin/lists/<listItemIri>/labels` : update labels of the node (root or child).
24-
- `PUT: /admin/lists/<listItemIri>/comments` : update comments of the node (root or child).
22+
- `PUT: /admin/lists/<listItemIri>` : update node information (root or child)
23+
- `PUT: /admin/lists/<listItemIri>/name` : update the name of the node (root or child)
24+
- `PUT: /admin/lists/<listItemIri>/labels` : update labels of the node (root or child)
25+
- `PUT: /admin/lists/<listItemIri>/comments` : update comments of the node (root or child)
2526
- `PUT: /admin/lists/<nodeIri>/position` : update position of a child node within its current parent or by changing its
26-
parent node.
27+
parent node
2728

28-
- `DELETE: /admin/lists/<listItemIri>` : delete a list (i.e. root node) or a child node and
29-
all its children, if not used
29+
- `DELETE: /admin/lists/<listItemIri>` : delete a list (i.e. root node) or a child node and all its children, if not used
3030

3131
## List Item Operations
3232

@@ -39,20 +39,39 @@ all its children, if not used
3939
### Get list
4040

4141
- Required permission: none
42-
- Return complete `list` including basic information of the list, `listinfo`, and all its children.
42+
- Return complete `list` (or `node`) including basic information of the list (or child node), `listinfo` (or `nodeinfo`),
43+
and all its children
4344
- GET: `/admin/lists/<listIri>`
4445

46+
### Get list's information
47+
48+
- Required permission: none
49+
- Return list information, `listinfo` (without children).
50+
- GET: `/admin/lists/infos/<listIri>`
51+
52+
### Get list node Information
53+
54+
- Required permission: none
55+
- Return node information, `nodeinfo`, (without children).
56+
- GET: `/admin/lists/nodes/<nodeIri>`
57+
58+
### Get list's information (merged)
59+
60+
- Required permission: none
61+
- Return list (or node) basic information, `listinfo` (or `nodeinfo`), without its children
62+
- GET: `/admin/lists/<listIri>/info`
4563

4664
### Create new list
4765

4866
- Required permission: SystemAdmin / ProjectAdmin
67+
- Required fields: `projectIri`, `labels`, `comments`
4968
- POST: `/admin/lists`
5069
- BODY:
5170

5271
```json
5372
{
5473
"projectIri": "someprojectiri",
55-
"labels": [{ "value": "Neue Liste", "language": "de"}],
74+
"labels": [{ "value": "New list", "language": "en"}],
5675
"comments": []
5776
}
5877
```
@@ -64,8 +83,8 @@ Additionally, each list can have an optional custom IRI (of [Knora IRI](../api-v
6483
"id": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
6584
"projectIri": "http://rdfh.ch/projects/0001",
6685
"name": "a new list",
67-
"labels": [{ "value": "Neue Liste mit IRI", "language": "de"}],
68-
"comments": []
86+
"labels": [{ "value": "New list with IRI", "language": "en"}],
87+
"comments": [{ "value": "New comment", "language": "en"}]
6988
}
7089
```
7190

@@ -75,13 +94,13 @@ The response will contain the basic information of the list, `listinfo` and an e
7594
"list": {
7695
"children": [],
7796
"listinfo": {
78-
"comments": [],
97+
"comments": [{ "value": "New comment", "language": "en"}],
7998
"id": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
8099
"isRootNode": true,
81100
"labels": [
82101
{
83-
"value": "Neue Liste mit IRI",
84-
"language": "de"
102+
"value": "New list with IRI",
103+
"language": "en"
85104
}
86105
],
87106
"name": "a new list",
@@ -90,18 +109,79 @@ The response will contain the basic information of the list, `listinfo` and an e
90109
}
91110
}
92111
```
93-
### Get list's information
94112

95-
- Required permission: none
96-
- Return list information, `listinfo` (without children).
97-
- GET: `/admin/lists/infos/<listIri>`
113+
### Create new child node
114+
115+
- Required permission: SystemAdmin / ProjectAdmin
116+
- Required fields: `parentNodeIri`, `projectIri`, `labels`,
117+
- Appends a new child node under the supplied nodeIri. If the supplied nodeIri
118+
is the listIri, then a new child node is appended to the top level. If a position is given
119+
for the new child node, the node will be created and inserted in the specified position, otherwise
120+
the node is appended to the end of parent's children.
121+
- POST: `/admin/lists/<parentNodeIri>`
122+
- BODY:
123+
124+
```json
125+
{
126+
"parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
127+
"projectIri": "http://rdfh.ch/projects/0001",
128+
"name": "a child",
129+
"labels": [{ "value": "New List Node", "language": "en"}]
130+
}
131+
```
132+
133+
Additionally, each child node can have an optional custom IRI (of [Knora IRI](../api-v2/knora-iris.md#iris-for-data) form) specified by the `id` in the request body as below:
134+
135+
```json
136+
{ "id": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
137+
"parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
138+
"projectIri": "http://rdfh.ch/projects/0001",
139+
"name": "a child",
140+
"labels": [{ "value": "New List Node", "language": "en"}]
141+
}
142+
```
143+
144+
The response will contain the basic information of the node, `nodeinfo`, as below:
145+
```json
146+
{
147+
"nodeinfo": {
148+
"comments": [],
149+
"hasRootNode": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
150+
"id": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
151+
"labels": [
152+
{
153+
"value": "New List Node",
154+
"language": "en"
155+
}
156+
],
157+
"name": "a new child",
158+
"position": 1
159+
}
160+
}
161+
```
162+
The new node can be created and inserted in a specific position which must be given in the payload as shown below. If necessary,
163+
according to the given position, the sibling nodes will be shifted. Note that `position` cannot have a value higher than the
164+
number of existing children.
165+
166+
```json
167+
{ "parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
168+
"projectIri": "http://rdfh.ch/projects/0001",
169+
"name": "Inserted new child",
170+
"position": 0,
171+
"labels": [{ "value": "New List Node", "language": "en"}]
172+
}
173+
```
174+
175+
In case the new node should be appended to the list of current children, either `position: -1` must be given in the
176+
payload or the `position` parameter must be left out of the payload.
98177

99-
### Update list's information
100-
The basic information of a list such as its labels, comments, name, or all of them can be updated. The parameters that
178+
### Update list's or node's information
179+
The basic information of a list (or node) such as its labels, comments, name, or all of them can be updated. The parameters that
101180
must be updated together with the new value must be given in the JSON body of the request together with the IRI of the
102181
list and the IRI of the project it belongs to.
103182

104183
- Required permission: SystemAdmin / ProjectAdmin
184+
- Required fields: `listIri`, `projectIri`
105185
- Update list information
106186
- PUT: `/admin/lists/<listIri>`
107187
- BODY:
@@ -115,7 +195,7 @@ list and the IRI of the project it belongs to.
115195
}
116196
```
117197

118-
The response will contain the basic information of the list, `listinfo`, without its children, as below:
198+
The response will contain the basic information of the list, `listinfo` (or `nodeinfo`), without its children, as below:
119199
```json
120200
{
121201
"listinfo": {
@@ -193,144 +273,6 @@ There is no need to specify the project IRI because it is automatically extracte
193273
```
194274
There is no need to specify the project IRI because it is automatically extracted using the given `<listItemIRI>`.
195275

196-
### Get node
197-
198-
- Required permission: none
199-
- Return complete `node` including basic information of the list, `nodeinfo`, and all its immediate children.
200-
- GET: `/admin/lists/<nodeIri>`
201-
202-
### Get List Node Information
203-
204-
- Required permission: none
205-
- Return node information, `nodeinfo`, (without children).
206-
- GET: `/admin/lists/nodes/<nodeIri>`
207-
208-
209-
### Create new child node
210-
211-
- Required permission: SystemAdmin / ProjectAdmin
212-
- Appends a new child node under the supplied nodeIri. If the supplied nodeIri
213-
is the listIri, then a new child node is appended to the top level. If a position is given
214-
for the new child node, the node will be created and inserted in the specified position, otherwise
215-
the node is appended to the end of parent's children.
216-
- POST: `/admin/lists/<parentNodeIri>`
217-
- BODY:
218-
219-
```json
220-
{
221-
"parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
222-
"projectIri": "http://rdfh.ch/projects/0001",
223-
"name": "a child",
224-
"labels": [{ "value": "New List Node", "language": "en"}],
225-
"comments": []
226-
}
227-
```
228-
229-
Additionally, each child node can have an optional custom IRI (of [Knora IRI](../api-v2/knora-iris.md#iris-for-data) form) specified by the `id` in the request body as below:
230-
231-
```json
232-
{ "id": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
233-
"parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
234-
"projectIri": "http://rdfh.ch/projects/0001",
235-
"name": "a child",
236-
"labels": [{ "value": "New List Node", "language": "en"}],
237-
"comments": []
238-
}
239-
```
240-
241-
The response will contain the basic information of the node, `nodeinfo`, as below:
242-
```json
243-
{
244-
"nodeinfo": {
245-
"comments": [],
246-
"hasRootNode": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
247-
"id": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
248-
"labels": [
249-
{
250-
"value": "New List Node",
251-
"language": "en"
252-
}
253-
],
254-
"name": "a new child",
255-
"position": 1
256-
}
257-
}
258-
```
259-
The new node can be created and inserted in a specific position which must be given in the payload as shown below. If necessary,
260-
according to the given position, the sibling nodes will be shifted. Note that `position` cannot have a value higher than the
261-
number of existing children.
262-
263-
```json
264-
{ "parentNodeIri": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
265-
"projectIri": "http://rdfh.ch/projects/0001",
266-
"name": "Inserted new child",
267-
"position": 0,
268-
"labels": [{ "value": "New List Node", "language": "en"}],
269-
"comments": []
270-
}
271-
```
272-
273-
In case the new node should be appended to the list of current children, either `position: -1` must be given in the
274-
payload or the `position` parameter must be left out of the payload.
275-
276-
### Update node's information
277-
The basic information of a node such as its labels, comments, name, or all of them can be updated. The parameters that
278-
must be updated together with the new value must be given in the JSON body of the request together with the IRI of the
279-
node and the IRI of the project it belongs to.
280-
281-
- Required permission: SystemAdmin / ProjectAdmin
282-
- Update node information
283-
- PUT: `/admin/lists/<nodeIri>`
284-
- BODY:
285-
286-
```json
287-
{ "listIri": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
288-
"projectIri": "http://rdfh.ch/projects/0001",
289-
"name": "new node name",
290-
"labels": [{ "value": "new node label", "language": "en"}],
291-
"comments": [{ "value": "new node comment", "language": "en"}]
292-
}
293-
```
294-
295-
The response will contain the basic information of the node as `nodeInfo` without its children, as below:
296-
297-
```json
298-
{
299-
"nodeinfo": {
300-
"comments": [
301-
{
302-
"value": "new node comment",
303-
"language": "en"
304-
}
305-
],
306-
"hasRootNode": "http://rdfh.ch/lists/0001/yWQEGXl53Z4C4DYJ-S2c5A",
307-
"id": "http://rdfh.ch/lists/0001/8u37MxBVMbX3XQ8-d31x6w",
308-
"labels": [
309-
{
310-
"value": "new node label",
311-
"language": "en"
312-
}
313-
],
314-
"name": "new node name",
315-
"position": 0
316-
}
317-
}
318-
```
319-
320-
If only name of the node must be updated, it can be given as below in the body of the request:
321-
322-
```json
323-
{
324-
"listIri": "nodeIri",
325-
"projectIri": "projectIri",
326-
"name": "another name"
327-
}
328-
```
329-
330-
Alternatively, basic information of the child node can be updated individually as explained above (See
331-
[update node name](#update-list-or-nodes-name), [update node labels](#update-list-or-nodes-labels), and
332-
[update node comments](#update-list-or-nodes-comments)).
333-
334276
### Repositioning a child node
335277

336278
The position of an existing child node can be updated. The child node can be either repositioned within its

0 commit comments

Comments
 (0)