Commit 48dd80e8 authored by François Agneray's avatar François Agneray
Browse files

Add setters for entity attribute (name and id)

parent 7fb0694d
Pipeline #5232 passed with stages
in 2 minutes and 31 seconds
......@@ -80,6 +80,8 @@ final class AttributeAction extends AbstractAction
*/
private function editAttribute(Attribute $attribute, array $parsedBody): void
{
$attribute->setId($parsedBody['id']);
$attribute->setName($parsedBody['name']);
$attribute->setLabel($parsedBody['label']);
$attribute->setFormLabel($parsedBody['form_label']);
$attribute->setDescription($parsedBody['description']);
......
......@@ -100,51 +100,57 @@ final class AttributeListAction extends AbstractAction
*/
private function postAttribute(array $parsedBody, Dataset $dataset): Attribute
{
$attribute = new Attribute($parsedBody['id'], $dataset);
$attribute->setName($parsedBody['name']);
$attribute->setLabel($parsedBody['label']);
$attribute->setFormLabel($parsedBody['form_label']);
$attribute->setDescription($parsedBody['description']);
$attribute->setOutputDisplay($parsedBody['output_display']);
$attribute->setCriteriaDisplay($parsedBody['criteria_display']);
$attribute->setSearchFlag($parsedBody['search_flag']);
$attribute->setSearchType($parsedBody['search_type']);
$attribute->setOperator($parsedBody['operator']);
$attribute->setType($parsedBody['type']);
$attribute->setMin($parsedBody['min']);
$attribute->setMax($parsedBody['max']);
$attribute->setPlaceholderMin($parsedBody['placeholder_min']);
$attribute->setPlaceholderMax($parsedBody['placeholder_max']);
$attribute->setRenderer($parsedBody['renderer']);
$attribute->setRendererConfig($parsedBody['renderer_config']);
$attribute->setDisplayDetail($parsedBody['display_detail']);
$attribute->setSelected($parsedBody['selected']);
$attribute->setOrderBy($parsedBody['order_by']);
$attribute->setOrderDisplay($parsedBody['order_display']);
$attribute->setDetail($parsedBody['detail']);
$attribute->setRendererDetail($parsedBody['renderer_detail']);
$attribute->setOptions($parsedBody['options']);
$attribute->setVoUtype($parsedBody['vo_utype']);
$attribute->setVoUcd($parsedBody['vo_ucd']);
$attribute->setVoUnit($parsedBody['vo_unit']);
$attribute->setVoDescription($parsedBody['vo_description']);
$attribute->setVoDatatype($parsedBody['vo_datatype']);
$attribute->setVoSize($parsedBody['vo_size']);
if (is_null($parsedBody['id_criteria_family'])) {
$attribute = new Attribute($this->getValue($parsedBody, 'id'), $dataset);
$attribute->setName($this->getValue($parsedBody, 'name'));
$attribute->setLabel($this->getValue($parsedBody, 'label'));
$attribute->setFormLabel($this->getValue($parsedBody, 'form_label'));
$attribute->setDescription($this->getValue($parsedBody, 'description'));
$attribute->setOutputDisplay($this->getValue($parsedBody, 'output_display'));
$attribute->setCriteriaDisplay($this->getValue($parsedBody, 'criteria_display'));
$attribute->setSearchFlag($this->getValue($parsedBody, 'search_flag'));
$attribute->setSearchType($this->getValue($parsedBody, 'search_type'));
$attribute->setOperator($this->getValue($parsedBody, 'operator'));
$attribute->setType($this->getValue($parsedBody, 'type'));
$attribute->setMin($this->getValue($parsedBody, 'min'));
$attribute->setMax($this->getValue($parsedBody, 'max'));
$attribute->setPlaceholderMin($this->getValue($parsedBody, 'placeholder_min'));
$attribute->setPlaceholderMax($this->getValue($parsedBody, 'placeholder_max'));
$attribute->setRenderer($this->getValue($parsedBody, 'renderer'));
$attribute->setRendererConfig($this->getValue($parsedBody, 'renderer_config'));
$attribute->setDisplayDetail($this->getValue($parsedBody, 'display_detail'));
if (!is_null($this->getValue($parsedBody, 'selected'))) {
$attribute->setSelected($this->getValue($parsedBody, 'selected'));
}
if (!is_null($this->getValue($parsedBody, 'order_by'))) {
$attribute->setOrderBy($this->getValue($parsedBody, 'order_by'));
}
$attribute->setOrderDisplay($this->getValue($parsedBody, 'order_display'));
if (!is_null($this->getValue($parsedBody, 'detail'))) {
$attribute->setDetail($this->getValue($parsedBody, 'detail'));
}
$attribute->setRendererDetail($this->getValue($parsedBody, 'renderer_detail'));
$attribute->setOptions($this->getValue($parsedBody, 'options'));
$attribute->setVoUtype($this->getValue($parsedBody, 'vo_utype'));
$attribute->setVoUcd($this->getValue($parsedBody, 'vo_ucd'));
$attribute->setVoUnit($this->getValue($parsedBody, 'vo_unit'));
$attribute->setVoDescription($this->getValue($parsedBody, 'vo_description'));
$attribute->setVoDatatype($this->getValue($parsedBody, 'vo_datatype'));
$attribute->setVoSize($this->getValue($parsedBody, 'vo_size'));
if (is_null($this->getValue($parsedBody, 'id_criteria_family'))) {
$criteriaFamily = null;
} else {
$criteriaFamily = $this->em->find(
'App\Entity\CriteriaFamily',
$parsedBody['id_criteria_family']
$$parsedBody['id_criteria_family']
);
}
$attribute->setCriteriaFamily($criteriaFamily);
if (is_null($parsedBody['id_output_category'])) {
if (is_null($this->getValue($parsedBody, 'id_output_category'))) {
$outputCategory = null;
} else {
$outputCategory = $this->em->find(
'App\Entity\OutputCategory',
$parsedBody['id_output_category']
$$parsedBody['id_output_category']
);
}
$attribute->setOutputCategory($outputCategory);
......@@ -154,4 +160,13 @@ final class AttributeListAction extends AbstractAction
return $attribute;
}
private function getValue($parsedBody, $key)
{
if (array_key_exists($key, $parsedBody)) {
return $parsedBody[$key];
} else {
return null;
}
}
}
......@@ -268,6 +268,11 @@ class Attribute implements \JsonSerializable
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getDataset()
{
return $this->dataset;
......
......@@ -103,6 +103,8 @@ final class AttributeActionTest extends TestCase
private function getEditAttributeFields(): array
{
return array(
'id' => 1,
'name' => 'id',
'label' => 'ID',
'form_label' => 'ID',
'description' => 'ID description',
......
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