Commit 41c8352b authored by François Agneray's avatar François Agneray
Browse files

Change the property name label by role (group)

parent 0619a8c8
Pipeline #3631 passed with stages
in 1 minute and 33 seconds
...@@ -196,5 +196,5 @@ curl -d '{"id":57,"name":"spec1dnoise","table_name":"aspic_vipers_dr2_w1","label ...@@ -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 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 # 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 '{"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 '{"label":"ASPIC","datasets":[]}' --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
-----BEGIN PUBLIC KEY----- -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsoH0IhiG5WNeUu/UytNnEIO5Uf9PXdFknRG4L6c2xuIQeqb6Bn/Xco5R9aV2upn0nk77LvPVG1cmjgl96rgfsYsWB7rPxy7BLhb7xWU0LNOQMuvClWxhDeNQyKE8H1URgHMQjhu+i0hQnXBVDK2fantbjLeo4v30DuVw2ZIco8YBzKI7ENDEcMLdCV5FI7Jq0XNG8ZCzd0ocg9UuwMTPREWHN0SZyr2V4HPmYASNokPuO9fNhekIii7yLWxU2K/qpTiSFMxDORRjtMalHjKXWZBGtipZ6LAb42BFNx0HDUYA7uUcZEk0Fr5KVcN1qu4hoamyj5L40quljCHFakqRLQIDAQAB MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1PHpi8f0iWxr1M9lwlL9tWwfZCIfO/oUFvtAPz94wOJCnISVe1AZDvHba2+Zn6fGQ9iXBkxjjz0Qn/p4YiV1zM/TaPme/LFrefTyrI8fhIQmucMSGWm37DgWPJrb5aZDJIdt7GKoEpAAMFFhh0qAH1BZ9s9vVNBCTSyhpsela9+XLTwIDGU0pAyEBNyc8/AOLiNv9LgPJoe/GHixJKcGkoyEacKJfhfzM36EpZedHBMvIv/ENUanMcD4aHhSIm44i6uEcZvFnQUtYCj9MluyJhfCw+arDja8bghB/6Wwzg7hq3H1oLfOJotpPculNaRA2ppTD/qIkdyiBmLw/puSEQIDAQAB
-----END PUBLIC KEY----- -----END PUBLIC KEY-----
...@@ -56,7 +56,7 @@ final class GroupAction extends AbstractAction ...@@ -56,7 +56,7 @@ final class GroupAction extends AbstractAction
$parsedBody = $request->getParsedBody(); $parsedBody = $request->getParsedBody();
// If mandatories empty fields 400 // If mandatories empty fields 400
foreach (array('label') as $a) { foreach (array('role', 'datasets') as $a) {
if ($this->isEmptyField($a, $parsedBody)) { if ($this->isEmptyField($a, $parsedBody)) {
throw new HttpBadRequestException( throw new HttpBadRequestException(
$request, $request,
...@@ -88,7 +88,7 @@ final class GroupAction extends AbstractAction ...@@ -88,7 +88,7 @@ final class GroupAction extends AbstractAction
*/ */
private function editGroup(Group $group, array $parsedBody): void private function editGroup(Group $group, array $parsedBody): void
{ {
$group->setLabel($parsedBody['label']); $group->setRole($parsedBody['role']);
$group->setDatasets($this->getDatasets($parsedBody['datasets'])); $group->setDatasets($this->getDatasets($parsedBody['datasets']));
$this->em->flush(); $this->em->flush();
} }
......
...@@ -57,7 +57,7 @@ final class GroupListAction extends AbstractAction ...@@ -57,7 +57,7 @@ final class GroupListAction extends AbstractAction
$parsedBody = $request->getParsedBody(); $parsedBody = $request->getParsedBody();
// To work this action needs group information // To work this action needs group information
foreach (array('label', 'datasets') as $a) { foreach (array('role', 'datasets') as $a) {
if ($this->isEmptyField($a, $parsedBody)) { if ($this->isEmptyField($a, $parsedBody)) {
throw new HttpBadRequestException( throw new HttpBadRequestException(
$request, $request,
...@@ -86,7 +86,7 @@ final class GroupListAction extends AbstractAction ...@@ -86,7 +86,7 @@ final class GroupListAction extends AbstractAction
private function postGroup(array $parsedBody, Instance $instance): Group private function postGroup(array $parsedBody, Instance $instance): Group
{ {
$group = new Group($instance); $group = new Group($instance);
$group->setLabel($parsedBody['label']); $group->setRole($parsedBody['role']);
$group->setDatasets($this->getDatasets($parsedBody['datasets'])); $group->setDatasets($this->getDatasets($parsedBody['datasets']));
$this->em->persist($group); $this->em->persist($group);
......
...@@ -30,9 +30,9 @@ class Group implements \JsonSerializable ...@@ -30,9 +30,9 @@ class Group implements \JsonSerializable
/** /**
* @var string * @var string
* *
* @Column(type="string", nullable=true) * @Column(type="string", nullable=false)
*/ */
protected $label; protected $role;
/** /**
* @var Anis\Entity\Instance * @var Anis\Entity\Instance
...@@ -64,14 +64,14 @@ class Group implements \JsonSerializable ...@@ -64,14 +64,14 @@ class Group implements \JsonSerializable
return $this->id; return $this->id;
} }
public function getLabel() public function getRole()
{ {
return $this->label; return $this->role;
} }
public function setLabel($label) public function setRole($role)
{ {
$this->label = $label; $this->role = $role;
} }
public function getInstance() public function getInstance()
...@@ -98,7 +98,7 @@ class Group implements \JsonSerializable ...@@ -98,7 +98,7 @@ class Group implements \JsonSerializable
return [ return [
'id' => $this->getId(), 'id' => $this->getId(),
'label' => $this->getLabel(), 'role' => $this->getRole(),
'instance_name' => $this->getInstance()->getName(), 'instance_name' => $this->getInstance()->getName(),
'datasets' => $datasets 'datasets' => $datasets
]; ];
......
...@@ -60,11 +60,11 @@ final class GroupActionTest extends TestCase ...@@ -60,11 +60,11 @@ final class GroupActionTest extends TestCase
$this->assertSame(json_encode($group), (string) $response->getBody()); $this->assertSame(json_encode($group), (string) $response->getBody());
} }
public function testEditAGroupEmptyLabelField(): void public function testEditAGroupEmptyRoleField(): void
{ {
$this->addAGroup(); $this->addAGroup();
$this->expectException(HttpBadRequestException::class); $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()); $request = $this->getRequest('PUT')->withParsedBody(array());
$response = ($this->action)($request, new Response(), array('id' => 1)); $response = ($this->action)($request, new Response(), array('id' => 1));
$this->assertEquals(400, (int) $response->getStatusCode()); $this->assertEquals(400, (int) $response->getStatusCode());
...@@ -73,7 +73,7 @@ final class GroupActionTest extends TestCase ...@@ -73,7 +73,7 @@ final class GroupActionTest extends TestCase
public function testEditAGroupWithoutDataset(): void public function testEditAGroupWithoutDataset(): void
{ {
$fields = array( $fields = array(
'label' => 'New_label', 'role' => 'New_role',
'datasets' => array() 'datasets' => array()
); );
$this->addAGroup(); $this->addAGroup();
...@@ -82,7 +82,7 @@ final class GroupActionTest extends TestCase ...@@ -82,7 +82,7 @@ final class GroupActionTest extends TestCase
$this->assertSame( $this->assertSame(
json_encode(array( json_encode(array(
'id' => 1, 'id' => 1,
'label' => $fields['label'], 'role' => $fields['role'],
'instance_name' => 'default', 'instance_name' => 'default',
'datasets' => $fields['datasets'] 'datasets' => $fields['datasets']
)), )),
...@@ -94,7 +94,7 @@ final class GroupActionTest extends TestCase ...@@ -94,7 +94,7 @@ final class GroupActionTest extends TestCase
{ {
$dataset = $this->addADataset(); $dataset = $this->addADataset();
$fields = array( $fields = array(
'label' => 'New_label', 'role' => 'New_role',
'datasets' => array($dataset->getName()) 'datasets' => array($dataset->getName())
); );
$this->addAGroup($dataset->getDatasetFamily()->getInstance()); $this->addAGroup($dataset->getDatasetFamily()->getInstance());
...@@ -103,7 +103,7 @@ final class GroupActionTest extends TestCase ...@@ -103,7 +103,7 @@ final class GroupActionTest extends TestCase
$this->assertSame( $this->assertSame(
json_encode(array( json_encode(array(
'id' => 1, 'id' => 1,
'label' => $fields['label'], 'role' => $fields['role'],
'instance_name' => 'default', 'instance_name' => 'default',
'datasets' => $fields['datasets'] 'datasets' => $fields['datasets']
)), )),
...@@ -141,7 +141,7 @@ final class GroupActionTest extends TestCase ...@@ -141,7 +141,7 @@ final class GroupActionTest extends TestCase
} }
$group = new Group($instance); $group = new Group($instance);
$group->setLabel('Group1'); $group->setRole('Group1');
$group->setDatasets(array()); $group->setDatasets(array());
$this->entityManager->persist($group); $this->entityManager->persist($group);
$this->entityManager->flush(); $this->entityManager->flush();
......
...@@ -53,11 +53,11 @@ final class GroupListActionTest extends TestCase ...@@ -53,11 +53,11 @@ final class GroupListActionTest extends TestCase
); );
} }
public function testAddANewGroupEmptyLabelField(): void public function testAddANewGroupEmptyRoleField(): void
{ {
$this->addInstance(); $this->addInstance();
$this->expectException(HttpBadRequestException::class); $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()); $request = $this->getRequest('POST')->withParsedBody(array());
$response = ($this->action)($request, new Response(), array('name' => 'default')); $response = ($this->action)($request, new Response(), array('name' => 'default'));
$this->assertEquals(400, (int) $response->getStatusCode()); $this->assertEquals(400, (int) $response->getStatusCode());
...@@ -66,7 +66,7 @@ final class GroupListActionTest extends TestCase ...@@ -66,7 +66,7 @@ final class GroupListActionTest extends TestCase
public function testAddANewGroupWithoutDataset(): void public function testAddANewGroupWithoutDataset(): void
{ {
$fields = array( $fields = array(
'label' => 'group1', 'role' => 'group1',
'datasets' => [] 'datasets' => []
); );
$this->addInstance(); $this->addInstance();
...@@ -75,7 +75,7 @@ final class GroupListActionTest extends TestCase ...@@ -75,7 +75,7 @@ final class GroupListActionTest extends TestCase
$this->assertSame( $this->assertSame(
json_encode(array( json_encode(array(
'id' => 1, 'id' => 1,
'label' => $fields['label'], 'role' => $fields['role'],
'instance_name' => 'default', 'instance_name' => 'default',
'datasets' => $fields['datasets'] 'datasets' => $fields['datasets']
)), )),
...@@ -88,7 +88,7 @@ final class GroupListActionTest extends TestCase ...@@ -88,7 +88,7 @@ final class GroupListActionTest extends TestCase
{ {
$dataset = $this->addADataset(); $dataset = $this->addADataset();
$fields = array( $fields = array(
'label' => 'group1', 'role' => 'group1',
'datasets' => array($dataset->getName()) 'datasets' => array($dataset->getName())
); );
$request = $this->getRequest('POST')->withParsedBody($fields); $request = $this->getRequest('POST')->withParsedBody($fields);
...@@ -96,7 +96,7 @@ final class GroupListActionTest extends TestCase ...@@ -96,7 +96,7 @@ final class GroupListActionTest extends TestCase
$this->assertSame( $this->assertSame(
json_encode(array( json_encode(array(
'id' => 1, 'id' => 1,
'label' => $fields['label'], 'role' => $fields['role'],
'instance_name' => 'default', 'instance_name' => 'default',
'datasets' => $fields['datasets'] 'datasets' => $fields['datasets']
)), )),
...@@ -122,12 +122,12 @@ final class GroupListActionTest extends TestCase ...@@ -122,12 +122,12 @@ final class GroupListActionTest extends TestCase
$instance = $this->addInstance(); $instance = $this->addInstance();
$group = new Group($instance); $group = new Group($instance);
$group->setLabel('Group1'); $group->setRole('Group1');
$group->setDatasets(array()); $group->setDatasets(array());
$this->entityManager->persist($group); $this->entityManager->persist($group);
$group2 = new Group($instance); $group2 = new Group($instance);
$group2->setLabel('Group2'); $group2->setRole('Group2');
$group2->setDatasets(array()); $group2->setDatasets(array());
$this->entityManager->persist($group2); $this->entityManager->persist($group2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment