Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
anis
anis-server
Commits
41c8352b
Commit
41c8352b
authored
Nov 27, 2020
by
François Agneray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the property name label by role (group)
parent
0619a8c8
Pipeline
#3631
passed with stages
in 1 minute and 33 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
29 deletions
+29
-29
conf-dev/create-db.sh
conf-dev/create-db.sh
+2
-2
conf-dev/public_key
conf-dev/public_key
+1
-1
src/Action/GroupAction.php
src/Action/GroupAction.php
+2
-2
src/Action/GroupListAction.php
src/Action/GroupListAction.php
+2
-2
src/Entity/Group.php
src/Entity/Group.php
+7
-7
tests/Action/GroupActionTest.php
tests/Action/GroupActionTest.php
+7
-7
tests/Action/GroupListActionTest.php
tests/Action/GroupListActionTest.php
+8
-8
No files found.
conf-dev/create-db.sh
View file @
41c8352b
...
...
@@ -196,5 +196,5 @@ curl -d '{"id":57,"name":"spec1dnoise","table_name":"aspic_vipers_dr2_w1","label
curl
-d
'{"id":58,"name":"spec1dsky","table_name":"aspic_vipers_dr2_w1","label":"spec1dsky","form_label":"spec1dsky","description":null,"output_display":580,"criteria_display":580,"search_flag":null,"search_type":null,"type":"text","operator":null,"min":null,"max":null,"placeholder_min":null,"placeholder_max":null,"renderer":"download","renderer_config":{"display":"icon-button","text":"DOWNLOAD","icon":"fas fa-download"},"display_detail":580,"selected":true,"order_by":false,"order_display":580,"detail":true,"renderer_detail":null,"options":null,"vo_utype":null,"vo_ucd":null,"vo_unit":null,"vo_description":null,"vo_datatype":null,"vo_size":null,"id_criteria_family":null,"id_output_category":8}'
--header
'Content-Type: application/json'
--header
"Authorization: Bearer
$admin_token
"
-X
PUT http://localhost/dataset/vipers_dr2_w1/attribute/58
# Add groups
curl
-d
'{"
label
":"SVOM","datasets":["obs_cat","observations"]}'
--header
'Content-Type: application/json'
--header
"Authorization: Bearer
$admin_token
"
-X
POST http://localhost/instance/default/group
curl
-d
'{"
label
":"ASPIC","datasets":[]}'
--header
'Content-Type: application/json'
--header
"Authorization: Bearer
$admin_token
"
-X
POST http://localhost/instance/default/group
curl
-d
'{"
role
":"SVOM","datasets":["obs_cat","observations"]}'
--header
'Content-Type: application/json'
--header
"Authorization: Bearer
$admin_token
"
-X
POST http://localhost/instance/default/group
curl
-d
'{"
role
":"ASPIC","datasets":[]}'
--header
'Content-Type: application/json'
--header
"Authorization: Bearer
$admin_token
"
-X
POST http://localhost/instance/default/group
conf-dev/public_key
View file @
41c8352b
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
soH0IhiG5WNeUu/UytNnEIO5Uf9PXdFknRG4L6c2xuIQeqb6Bn/Xco5R9aV2upn0nk77LvPVG1cmjgl96rgfsYsWB7rPxy7BLhb7xWU0LNOQMuvClWxhDeNQyKE8H1URgHMQjhu+i0hQnXBVDK2fantbjLeo4v30DuVw2ZIco8YBzKI7ENDEcMLdCV5FI7Jq0XNG8ZCzd0ocg9UuwMTPREWHN0SZyr2V4HPmYASNokPuO9fNhekIii7yLWxU2K/qpTiSFMxDORRjtMalHjKXWZBGtipZ6LAb42BFNx0HDUYA7uUcZEk0Fr5KVcN1qu4hoamyj5L40quljCHFakqRL
QIDAQAB
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
1PHpi8f0iWxr1M9lwlL9tWwfZCIfO/oUFvtAPz94wOJCnISVe1AZDvHba2+Zn6fGQ9iXBkxjjz0Qn/p4YiV1zM/TaPme/LFrefTyrI8fhIQmucMSGWm37DgWPJrb5aZDJIdt7GKoEpAAMFFhh0qAH1BZ9s9vVNBCTSyhpsela9+XLTwIDGU0pAyEBNyc8/AOLiNv9LgPJoe/GHixJKcGkoyEacKJfhfzM36EpZedHBMvIv/ENUanMcD4aHhSIm44i6uEcZvFnQUtYCj9MluyJhfCw+arDja8bghB/6Wwzg7hq3H1oLfOJotpPculNaRA2ppTD/qIkdyiBmLw/puSE
QIDAQAB
-----END PUBLIC KEY-----
src/Action/GroupAction.php
View file @
41c8352b
...
...
@@ -56,7 +56,7 @@ final class GroupAction extends AbstractAction
$parsedBody
=
$request
->
getParsedBody
();
// If mandatories empty fields 400
foreach
(
array
(
'
label
'
)
as
$a
)
{
foreach
(
array
(
'
role'
,
'datasets
'
)
as
$a
)
{
if
(
$this
->
isEmptyField
(
$a
,
$parsedBody
))
{
throw
new
HttpBadRequestException
(
$request
,
...
...
@@ -88,7 +88,7 @@ final class GroupAction extends AbstractAction
*/
private
function
editGroup
(
Group
$group
,
array
$parsedBody
):
void
{
$group
->
set
Label
(
$parsedBody
[
'
label
'
]);
$group
->
set
Role
(
$parsedBody
[
'
role
'
]);
$group
->
setDatasets
(
$this
->
getDatasets
(
$parsedBody
[
'datasets'
]));
$this
->
em
->
flush
();
}
...
...
src/Action/GroupListAction.php
View file @
41c8352b
...
...
@@ -57,7 +57,7 @@ final class GroupListAction extends AbstractAction
$parsedBody
=
$request
->
getParsedBody
();
// To work this action needs group information
foreach
(
array
(
'
label
'
,
'datasets'
)
as
$a
)
{
foreach
(
array
(
'
role
'
,
'datasets'
)
as
$a
)
{
if
(
$this
->
isEmptyField
(
$a
,
$parsedBody
))
{
throw
new
HttpBadRequestException
(
$request
,
...
...
@@ -86,7 +86,7 @@ final class GroupListAction extends AbstractAction
private
function
postGroup
(
array
$parsedBody
,
Instance
$instance
):
Group
{
$group
=
new
Group
(
$instance
);
$group
->
set
Label
(
$parsedBody
[
'
label
'
]);
$group
->
set
Role
(
$parsedBody
[
'
role
'
]);
$group
->
setDatasets
(
$this
->
getDatasets
(
$parsedBody
[
'datasets'
]));
$this
->
em
->
persist
(
$group
);
...
...
src/Entity/Group.php
View file @
41c8352b
...
...
@@ -30,9 +30,9 @@ class Group implements \JsonSerializable
/**
* @var string
*
* @Column(type="string", nullable=
tru
e)
* @Column(type="string", nullable=
fals
e)
*/
protected
$
label
;
protected
$
role
;
/**
* @var Anis\Entity\Instance
...
...
@@ -64,14 +64,14 @@ class Group implements \JsonSerializable
return
$this
->
id
;
}
public
function
get
Label
()
public
function
get
Role
()
{
return
$this
->
label
;
return
$this
->
role
;
}
public
function
set
Label
(
$label
)
public
function
set
Role
(
$role
)
{
$this
->
label
=
$label
;
$this
->
role
=
$role
;
}
public
function
getInstance
()
...
...
@@ -98,7 +98,7 @@ class Group implements \JsonSerializable
return
[
'id'
=>
$this
->
getId
(),
'
label
'
=>
$this
->
get
Label
(),
'
role
'
=>
$this
->
get
Role
(),
'instance_name'
=>
$this
->
getInstance
()
->
getName
(),
'datasets'
=>
$datasets
];
...
...
tests/Action/GroupActionTest.php
View file @
41c8352b
...
...
@@ -60,11 +60,11 @@ final class GroupActionTest extends TestCase
$this
->
assertSame
(
json_encode
(
$group
),
(
string
)
$response
->
getBody
());
}
public
function
testEditAGroupEmpty
Label
Field
():
void
public
function
testEditAGroupEmpty
Role
Field
():
void
{
$this
->
addAGroup
();
$this
->
expectException
(
HttpBadRequestException
::
class
);
$this
->
expectExceptionMessage
(
'Param
label
needed to edit the group'
);
$this
->
expectExceptionMessage
(
'Param
role
needed to edit the group'
);
$request
=
$this
->
getRequest
(
'PUT'
)
->
withParsedBody
(
array
());
$response
=
(
$this
->
action
)(
$request
,
new
Response
(),
array
(
'id'
=>
1
));
$this
->
assertEquals
(
400
,
(
int
)
$response
->
getStatusCode
());
...
...
@@ -73,7 +73,7 @@ final class GroupActionTest extends TestCase
public
function
testEditAGroupWithoutDataset
():
void
{
$fields
=
array
(
'
label
'
=>
'New_
label
'
,
'
role
'
=>
'New_
role
'
,
'datasets'
=>
array
()
);
$this
->
addAGroup
();
...
...
@@ -82,7 +82,7 @@ final class GroupActionTest extends TestCase
$this
->
assertSame
(
json_encode
(
array
(
'id'
=>
1
,
'
label
'
=>
$fields
[
'
label
'
],
'
role
'
=>
$fields
[
'
role
'
],
'instance_name'
=>
'default'
,
'datasets'
=>
$fields
[
'datasets'
]
)),
...
...
@@ -94,7 +94,7 @@ final class GroupActionTest extends TestCase
{
$dataset
=
$this
->
addADataset
();
$fields
=
array
(
'
label
'
=>
'New_
label
'
,
'
role
'
=>
'New_
role
'
,
'datasets'
=>
array
(
$dataset
->
getName
())
);
$this
->
addAGroup
(
$dataset
->
getDatasetFamily
()
->
getInstance
());
...
...
@@ -103,7 +103,7 @@ final class GroupActionTest extends TestCase
$this
->
assertSame
(
json_encode
(
array
(
'id'
=>
1
,
'
label
'
=>
$fields
[
'
label
'
],
'
role
'
=>
$fields
[
'
role
'
],
'instance_name'
=>
'default'
,
'datasets'
=>
$fields
[
'datasets'
]
)),
...
...
@@ -141,7 +141,7 @@ final class GroupActionTest extends TestCase
}
$group
=
new
Group
(
$instance
);
$group
->
set
Label
(
'Group1'
);
$group
->
set
Role
(
'Group1'
);
$group
->
setDatasets
(
array
());
$this
->
entityManager
->
persist
(
$group
);
$this
->
entityManager
->
flush
();
...
...
tests/Action/GroupListActionTest.php
View file @
41c8352b
...
...
@@ -53,11 +53,11 @@ final class GroupListActionTest extends TestCase
);
}
public
function
testAddANewGroupEmpty
Label
Field
():
void
public
function
testAddANewGroupEmpty
Role
Field
():
void
{
$this
->
addInstance
();
$this
->
expectException
(
HttpBadRequestException
::
class
);
$this
->
expectExceptionMessage
(
'Param
label
needed to add a new group'
);
$this
->
expectExceptionMessage
(
'Param
role
needed to add a new group'
);
$request
=
$this
->
getRequest
(
'POST'
)
->
withParsedBody
(
array
());
$response
=
(
$this
->
action
)(
$request
,
new
Response
(),
array
(
'name'
=>
'default'
));
$this
->
assertEquals
(
400
,
(
int
)
$response
->
getStatusCode
());
...
...
@@ -66,7 +66,7 @@ final class GroupListActionTest extends TestCase
public
function
testAddANewGroupWithoutDataset
():
void
{
$fields
=
array
(
'
label
'
=>
'group1'
,
'
role
'
=>
'group1'
,
'datasets'
=>
[]
);
$this
->
addInstance
();
...
...
@@ -75,7 +75,7 @@ final class GroupListActionTest extends TestCase
$this
->
assertSame
(
json_encode
(
array
(
'id'
=>
1
,
'
label
'
=>
$fields
[
'
label
'
],
'
role
'
=>
$fields
[
'
role
'
],
'instance_name'
=>
'default'
,
'datasets'
=>
$fields
[
'datasets'
]
)),
...
...
@@ -88,7 +88,7 @@ final class GroupListActionTest extends TestCase
{
$dataset
=
$this
->
addADataset
();
$fields
=
array
(
'
label
'
=>
'group1'
,
'
role
'
=>
'group1'
,
'datasets'
=>
array
(
$dataset
->
getName
())
);
$request
=
$this
->
getRequest
(
'POST'
)
->
withParsedBody
(
$fields
);
...
...
@@ -96,7 +96,7 @@ final class GroupListActionTest extends TestCase
$this
->
assertSame
(
json_encode
(
array
(
'id'
=>
1
,
'
label
'
=>
$fields
[
'
label
'
],
'
role
'
=>
$fields
[
'
role
'
],
'instance_name'
=>
'default'
,
'datasets'
=>
$fields
[
'datasets'
]
)),
...
...
@@ -122,12 +122,12 @@ final class GroupListActionTest extends TestCase
$instance
=
$this
->
addInstance
();
$group
=
new
Group
(
$instance
);
$group
->
set
Label
(
'Group1'
);
$group
->
set
Role
(
'Group1'
);
$group
->
setDatasets
(
array
());
$this
->
entityManager
->
persist
(
$group
);
$group2
=
new
Group
(
$instance
);
$group2
->
set
Label
(
'Group2'
);
$group2
->
set
Role
(
'Group2'
);
$group2
->
setDatasets
(
array
());
$this
->
entityManager
->
persist
(
$group2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment