diff --git a/src/Controller/Pia/FolderController.php b/src/Controller/Pia/FolderController.php index 53ff1da..f11e6bd 100644 --- a/src/Controller/Pia/FolderController.php +++ b/src/Controller/Pia/FolderController.php @@ -146,6 +146,7 @@ public function showAction(Request $request, $id) * type="object", * required={"name"}, * @Swg\Property(property="name", type="string"), + * @Swg\Property(property="person_in_charge", type="string"), * @Swg\Property(property="parent", type="object", @Swg\Property(property="id", type="number")) * ), * description="The Folder content" @@ -173,7 +174,8 @@ public function createAction(Request $request) $folder = $this->folderService->createFolder( $request->get('name'), $structure, - $parent + $parent, + $request->get('person_in_charge') ); $this->persist($folder); @@ -214,6 +216,7 @@ public function createAction(Request $request) * @Swg\Schema( * type="object", * @Swg\Property(property="name", type="string"), + * @Swg\Property(property="person_in_charge", type="string"), * @Swg\Property(property="parent", type="object", @Swg\Property(property="id", type="number")) * ), * description="The Folder content" @@ -238,8 +241,9 @@ public function updateAction(Request $request, $id) $this->canAccessResourceOr403($folder); $updatableAttributes = [ - 'name' => RequestDataHandler::TYPE_STRING, - 'parent' => Folder::class, + 'name' => RequestDataHandler::TYPE_STRING, + 'person_in_charge' => RequestDataHandler::TYPE_STRING, + 'parent' => Folder::class, ]; $this->mergeFromRequest($folder, $updatableAttributes, $request); diff --git a/src/Controller/Pia/PiaController.php b/src/Controller/Pia/PiaController.php index 68d5332..0327123 100644 --- a/src/Controller/Pia/PiaController.php +++ b/src/Controller/Pia/PiaController.php @@ -15,7 +15,6 @@ use PiaApi\DataExchange\Transformer\PiaTransformer; use PiaApi\DataHandler\RequestDataHandler; use PiaApi\Entity\Pia\Pia; -use PiaApi\Entity\Pia\ProcessingTemplate; use PiaApi\Entity\Pia\Processing; use PiaApi\Exception\DataImportException; use PiaApi\Entity\Pia\Answer; @@ -218,74 +217,6 @@ public function createAction(Request $request) return $this->view($pia, Response::HTTP_OK); } - /** - * Creates a PIA from a template. - * - * @Swg\Tag(name="Pia") - * - * @FOSRest\Post("/pias/new-from-template/{id}") - * - * @Swg\Parameter( - * name="Authorization", - * in="header", - * type="string", - * required=true, - * description="The API token. e.g.: Bearer " - * ) - * @Swg\Parameter( - * name="id", - * in="path", - * type="string", - * required=true, - * description="The ID of the PIA's template" - * ) - * @Swg\Parameter( - * name="PIA", - * in="body", - * required=true, - * @Swg\Schema( - * type="object", - * required={"author_name","evaluator_name","validator_name","processing"}, - * @Swg\Property(property="author_name", type="string"), - * @Swg\Property(property="evaluator_name", type="string"), - * @Swg\Property(property="validator_name", type="string"), - * @Swg\Property(property="processing", type="object", required={"id"}, @Swg\Property(property="id", type="number")) - * ), - * description="The PIA content" - * ) - * - * @Swg\Response( - * response=200, - * description="Returns the newly created PIA", - * @Swg\Schema( - * type="object", - * ref=@Nelmio\Model(type=Pia::class, groups={"Default"}) - * ) - * ) - * - * @Security("is_granted('CAN_CREATE_PIA')") - * - * @return array - */ - public function createFromTemplateAction(Request $request, $id) - { - /** @var ProcessingTemplate $pTemplate */ - $pTemplate = $this->getDoctrine()->getRepository(ProcessingTemplate::class)->find($id); - if ($pTemplate === null) { - return $this->view($pTemplate, Response::HTTP_NOT_FOUND); - } - - $pia = $this->jsonToEntityTransformer->transform($pTemplate->getData()); - $pia->setAuthorName($request->get('author_name', $pia->getAuthorName())); - $pia->setEvaluatorName($request->get('evaluator_name', $pia->getEvaluatorName())); - $pia->setValidatorName($request->get('validator_name', $pia->getValidatorName())); - $pia->setStructure($this->getUser()->getStructure()); - $pia->setProcessing($this->getResource($request->get('processing', ['id' => -1])['id'], Processing::class)); - $this->persist($pia); - - return $this->view($pia, Response::HTTP_OK); - } - /** * Updates a PIA. * diff --git a/src/Controller/Pia/ProcessingCommentController.php b/src/Controller/Pia/ProcessingCommentController.php index 12154ad..ef14169 100644 --- a/src/Controller/Pia/ProcessingCommentController.php +++ b/src/Controller/Pia/ProcessingCommentController.php @@ -11,7 +11,6 @@ namespace PiaApi\Controller\Pia; use PiaApi\DataHandler\RequestDataHandler; -use PiaApi\Services\ProcessingCommentService; use PiaApi\Entity\Pia\ProcessingComment; use PiaApi\Entity\Pia\Processing; use FOS\RestBundle\Controller\Annotations as FOSRest; @@ -25,7 +24,8 @@ class ProcessingCommentController extends RestController { - public function __construct(PropertyAccessorInterface $propertyAccessor) { + public function __construct(PropertyAccessorInterface $propertyAccessor) + { parent::__construct($propertyAccessor); } @@ -224,7 +224,7 @@ public function updateAction(Request $request, $id) $this->canAccessResourceOr403($processingComment); $updatableAttributes = [ - 'content' => RequestDataHandler::TYPE_STRING, + 'content' => RequestDataHandler::TYPE_STRING, 'field' => RequestDataHandler::TYPE_STRING, ]; diff --git a/src/Controller/Pia/ProcessingController.php b/src/Controller/Pia/ProcessingController.php index cbcff85..ade489c 100644 --- a/src/Controller/Pia/ProcessingController.php +++ b/src/Controller/Pia/ProcessingController.php @@ -12,6 +12,7 @@ use PiaApi\Services\ProcessingService; use PiaApi\Entity\Pia\Processing; +use PiaApi\Entity\Pia\ProcessingTemplate; use PiaApi\Entity\Pia\Folder; use PiaApi\DataHandler\RequestDataHandler; use PiaApi\Entity\Pia\ProcessingDataType; @@ -54,7 +55,7 @@ public function __construct( SerializerInterface $serializer ) { parent::__construct($propertyAccessor); - + $this->processingService = $processingService; $this->processingTransformer = $processingTransformer; $this->serializer = $serializer; @@ -177,6 +178,7 @@ public function showAction(Request $request, $id) * @Swg\Property(property="controllers", type="string"), * @Swg\Property(property="non_eu_transfer", type="string"), * @Swg\Property(property="context_of_implementation", type="string"), + * @Swg\Property(property="concerned_people", type="string"), * @Swg\Property(property="processing_data_types", type="array", @Swg\Items( * ref=@Nelmio\Model(type=ProcessingDataType::class, groups={"Default"}) * )), @@ -260,6 +262,7 @@ public function createAction(Request $request) * @Swg\Property(property="rights_guarantee", type="string"), * @Swg\Property(property="exactness", type="string"), * @Swg\Property(property="consent", type="string"), + * @Swg\Property(property="concerned_people", type="string"), * @Swg\Property(property="non_eu_transfer", type="string"), * @Swg\Property(property="context_of_implementation", type="string"), * @Swg\Property(property="processing_data_types", type="array", @Swg\Items( @@ -268,7 +271,7 @@ public function createAction(Request $request) * @Swg\Property(property="recipients", type="string"), * @Swg\Property(property="evaluationComment", type="string"), * @Swg\Property(property="evaluationState", type="integer"), - * @Swg\Property(property="folder", required={"id"}, type="object", + * @Swg\Property(property="folder", required={"id"}, type="object", * @Swg\Property(property="id", type="number")), * @Swg\Property(property="comments", type="array", @Swg\Items( * ref=@Nelmio\Model(type=ProcessingComment::class, groups={"Default"}) @@ -320,6 +323,7 @@ public function updateAction(Request $request, $id) 'rights_guarantee' => RequestDataHandler::TYPE_STRING, 'exactness' => RequestDataHandler::TYPE_STRING, 'consent' => RequestDataHandler::TYPE_STRING, + 'concerned_people' => RequestDataHandler::TYPE_STRING, 'status' => RequestDataHandler::TYPE_INT, 'evaluation_comment' => RequestDataHandler::TYPE_STRING, 'evaluation_state' => RequestDataHandler::TYPE_INT, @@ -466,4 +470,95 @@ public function importAction(Request $request) return $this->view($processing, Response::HTTP_OK); } + + /** + * Creates a PIA from a template. + * + * @Swg\Tag(name="Processing") + * + * @FOSRest\Post("/processings/new-from-template/{id}") + * + * @Swg\Parameter( + * name="Authorization", + * in="header", + * type="string", + * required=true, + * description="The API token. e.g.: Bearer " + * ) + * @Swg\Parameter( + * name="id", + * in="path", + * type="string", + * required=true, + * description="The ID of the Processing template" + * ) + * @Swg\Parameter( + * name="Processing", + * in="body", + * required=true, + * description="The Processing content", + * @Swg\Schema( + * type="object", + * ref=@Nelmio\Model(type=Processing::class, groups={"Default"}) + * ) + * ) + * + * @Swg\Response( + * response=200, + * description="Returns the newly created Processing", + * @Swg\Schema( + * type="object", + * ref=@Nelmio\Model(type=Processing::class, groups={"Default"}) + * ) + * ) + * + * @Security("is_granted('CAN_CREATE_PROCESSING')") + * + * @return array + */ + public function createFromTemplateAction(Request $request, $id) + { + /** @var ProcessingTemplate $pTemplate */ + $pTemplate = $this->getDoctrine()->getRepository(ProcessingTemplate::class)->find($id); + $folder = $this->getResource($request->get('folder', ['id' => -1])['id'], Folder::class); + + if ($pTemplate === null || $folder === null) { + return $this->view($pTemplate, Response::HTTP_NOT_FOUND); + } + + $this->processingTransformer->setFolder($folder); + + try { + $tplData = json_decode($pTemplate->getData(), true); + $processing = $this->processingTransformer->jsonToProcessing($tplData); + $processing->setAuthor($request->get('author')); + $processing->setDesignatedController($request->get('designated_controller')); + + $this->persist($processing); + + $descriptor = $this->processingTransformer->fromJson($tplData, ProcessingDescriptor::class); + + //only last PIA is used + if (count($descriptor->getPias()) > 0) { + $pias = $descriptor->getPias(); + $pia = $this->processingTransformer->extractPia($processing, end($pias)); + $processing->addPia($pia); + $pia->setProcessing($processing); + $pia->setStructure($folder->getStructure()); //@todo to be removed, a Pia do not need a structure + $this->persist($pia); + } + + foreach ($descriptor->getProcessingDataTypes() as $types) { + $processing->addProcessingDataType($this->processingTransformer->extractDataType($processing, $types)); + } + + $processing->setTemplate($pTemplate); + + $this->persist($processing); + } catch (DataImportException $ex) { + return $this->view(unserialize($ex->getMessage()), Response::HTTP_BAD_REQUEST); + } + + return $this->view($processing, Response::HTTP_OK); + } } diff --git a/src/Controller/Pia/StructureController.php b/src/Controller/Pia/StructureController.php index 9991a2d..1ff7326 100644 --- a/src/Controller/Pia/StructureController.php +++ b/src/Controller/Pia/StructureController.php @@ -232,6 +232,9 @@ public function createAction(Request $request) * @Swg\Property(property="siret", type="string"), * @Swg\Property(property="vat_number", type="string"), * @Swg\Property(property="activity_code", type="string"), + * @Swg\Property(property="executive", type="string"), + * @Swg\Property(property="backup", type="string"), + * @Swg\Property(property="dpo", type="string"), * @Swg\Property(property="legal_form", type="string"), * @Swg\Property(property="registration_date", type="string") * ), @@ -266,6 +269,9 @@ public function updateAction(Request $request, $id) 'siret' => RequestDataHandler::TYPE_STRING, 'vat_number' => RequestDataHandler::TYPE_STRING, 'activity_code' => RequestDataHandler::TYPE_STRING, + 'executive' => RequestDataHandler::TYPE_STRING, + 'backup' => RequestDataHandler::TYPE_STRING, + 'dpo' => RequestDataHandler::TYPE_STRING, 'legal_form' => RequestDataHandler::TYPE_STRING, 'registration_date' => \DateTime::class, ]; diff --git a/src/Controller/Pia/StructureFolderController.php b/src/Controller/Pia/StructureFolderController.php index 611b5bf..58b0bf4 100644 --- a/src/Controller/Pia/StructureFolderController.php +++ b/src/Controller/Pia/StructureFolderController.php @@ -165,6 +165,7 @@ public function showAction(Request $request, $structureId, $id) * type="object", * required={"name"}, * @Swg\Property(property="name", type="string"), + * @Swg\Property(property="person_in_charge", type="string"), * @Swg\Property(property="parent", type="object", @Swg\Property(property="id", type="number")) * ), * description="The Folder content" @@ -194,7 +195,8 @@ public function createAction(Request $request, $structureId) $folder = $this->folderService->createFolder( $request->get('name'), $structure, - $parent + $parent, + $request->get('person_in_charge') ); $this->canAccessResourceOr403($folder); @@ -243,6 +245,7 @@ public function createAction(Request $request, $structureId) * @Swg\Schema( * type="object", * @Swg\Property(property="name", type="string"), + * @Swg\Property(property="person_in_charge", type="string"), * @Swg\Property(property="parent", type="object", @Swg\Property(property="id", type="number")) * ), * description="The Folder content" @@ -272,6 +275,7 @@ public function updateAction(Request $request, $structureId, $id) $updatableAttributes = [ 'name' => RequestDataHandler::TYPE_STRING, + 'person_in_charge' => RequestDataHandler::TYPE_STRING, 'parent' => Folder::class, ]; diff --git a/src/DataExchange/Descriptor/PiaDescriptor.php b/src/DataExchange/Descriptor/PiaDescriptor.php index d153348..a53974d 100644 --- a/src/DataExchange/Descriptor/PiaDescriptor.php +++ b/src/DataExchange/Descriptor/PiaDescriptor.php @@ -120,7 +120,6 @@ class PiaDescriptor extends AbstractDescriptor /** * @JMS\Type("string") * @JMS\Groups({"Default", "Export"}) - * @Assert\NotBlank * * @var string */ @@ -195,15 +194,15 @@ public function __construct( string $evaluator, string $validator, int $dpoStatus, - string $dpoOpinion, - string $concernedPeopleOpinion, + ?string $dpoOpinion, + ?string $concernedPeopleOpinion, int $concernedPeopleStatus, bool $concernedPeopleSearchedOpinion, - string $concernedPeopleSearchedContent, - string $rejectionReason, - string $appliedAdjustments, - string $dposNames, - string $peopleNames, + ?string $concernedPeopleSearchedContent, + ?string $rejectionReason, + ?string $appliedAdjustments, + ?string $dposNames, + ?string $peopleNames, bool $isExample, \DateTime $createdAt, \DateTime $updatedAt, diff --git a/src/DataExchange/Descriptor/ProcessingDescriptor.php b/src/DataExchange/Descriptor/ProcessingDescriptor.php index fd8d41a..c3f456e 100644 --- a/src/DataExchange/Descriptor/ProcessingDescriptor.php +++ b/src/DataExchange/Descriptor/ProcessingDescriptor.php @@ -36,7 +36,6 @@ class ProcessingDescriptor extends AbstractDescriptor /** * @JMS\Type("string") * @JMS\Groups({"Default", "Export"}) - * @Assert\NotBlank * * @var string|null */ diff --git a/src/DataExchange/Transformer/ProcessingTransformer.php b/src/DataExchange/Transformer/ProcessingTransformer.php index 5f68eab..fcb1e30 100644 --- a/src/DataExchange/Transformer/ProcessingTransformer.php +++ b/src/DataExchange/Transformer/ProcessingTransformer.php @@ -78,7 +78,7 @@ public function toProcessing(ProcessingDescriptor $descriptor): Processing $processing->setLifeCycle($descriptor->getLifeCycle()); $processing->setStorage($descriptor->getStorage()); $processing->setStandards($descriptor->getStandards()); - $processing->setStatus($descriptor->getStatus()); + $processing->setStatus((int) $descriptor->getStatus()); $processing->setLawfulness($descriptor->getLawfulness()); $processing->setMinimization($descriptor->getMinimization()); $processing->setRightsGuarantee($descriptor->getRightsGuarantee()); diff --git a/src/DataExchange/Validator/JsonValidator.php b/src/DataExchange/Validator/JsonValidator.php index 3d1ac1f..b63806f 100644 --- a/src/DataExchange/Validator/JsonValidator.php +++ b/src/DataExchange/Validator/JsonValidator.php @@ -18,7 +18,7 @@ class JsonValidator { /** - * Validates that the json is a valid representation of Pia end serve array representation. + * Validates that the json is a valid representation of Pia and serve array representation. * * @param string $json * diff --git a/src/Entity/Pia/Folder.php b/src/Entity/Pia/Folder.php index bdc6bbe..ce7fdf4 100644 --- a/src/Entity/Pia/Folder.php +++ b/src/Entity/Pia/Folder.php @@ -38,6 +38,14 @@ class Folder implements Timestampable */ private $name; + /** + * @ORM\Column(type="string", nullable=true) + * @JMS\Groups({"Default"}) + * + * @var string + */ + private $personInCharge; + /** * @Gedmo\TreeLeft * @ORM\Column(name="lft", type="integer") @@ -270,6 +278,22 @@ public function setName(string $name): void $this->name = $name; } + /** + * @return string + */ + public function getPersonInCharge(): string + { + return $this->personInCharge; + } + + /** + * @param string $personInCharge + */ + public function setPersonInCharge(string $personInCharge): void + { + $this->personInCharge = $personInCharge; + } + /** * @JMS\VirtualProperty * @JMS\SerializedName("path") diff --git a/src/Entity/Pia/Processing.php b/src/Entity/Pia/Processing.php index b0f5051..e154ab9 100644 --- a/src/Entity/Pia/Processing.php +++ b/src/Entity/Pia/Processing.php @@ -180,6 +180,14 @@ class Processing */ protected $consent; + /** + * @ORM\Column(type="text", nullable=true) + * @JMS\Groups({"Default", "Export"}) + * + * @var string|null + */ + protected $concernedPeople; + /** * @ORM\Column(type="text", nullable=true) * @JMS\Groups({"Default", "Export"}) @@ -472,6 +480,22 @@ public function setConsent(?string $consent = null): void $this->consent = $consent; } + /** + * @return string + */ + public function getConcernedPeople(): ?string + { + return $this->concernedPeople; + } + + /** + * @param string $concernedPeople + */ + public function setConcernedPeople(?string $concernedPeople = null): void + { + $this->concernedPeople = $concernedPeople; + } + /** * @return array|ProcessingComment[] */ diff --git a/src/Entity/Pia/ProcessingComment.php b/src/Entity/Pia/ProcessingComment.php index dfb8159..3cd9925 100644 --- a/src/Entity/Pia/ProcessingComment.php +++ b/src/Entity/Pia/ProcessingComment.php @@ -49,12 +49,11 @@ class ProcessingComment implements Timestampable * @var Processing */ protected $processing; - public function __construct(Processing $processing, string $content, string $field) { $this->processing = $processing; - $this->content = $content; + $this->content = $content; $this->field = $field; } @@ -90,7 +89,6 @@ public function setField(string $field): void $this->field = $field; } - /** * @return Processing */ diff --git a/src/Entity/Pia/ProcessingTemplate.php b/src/Entity/Pia/ProcessingTemplate.php index d8ed40f..8f2932a 100644 --- a/src/Entity/Pia/ProcessingTemplate.php +++ b/src/Entity/Pia/ProcessingTemplate.php @@ -216,11 +216,11 @@ public function addFile(UploadedFile $file): void } /** - * @return array|Structure[] + * @return Collection|Structure[] */ - public function getStructures(): array + public function getStructures(): Collection { - return $this->structures->getValues(); + return $this->structures; } /** @@ -285,7 +285,7 @@ public function removeStructureType(StructureType $structureType): void { if (!$this->structureTypes->contains($structureType)) { throw new \InvalidArgumentException( - sprintf('The ProcessingTemplate « %s » is not allowed for StructureType « %s » and so cannot be disociated', $this->name, $structureType) + sprintf('The ProcessingTemplate « %s » is not allowed for StructureType « %s » and so cannot be disociated', $this->name, $structureType) ); } $this->structureTypes->removeElement($structureType); diff --git a/src/Entity/Pia/Traits/StructureInformationsTrait.php b/src/Entity/Pia/Traits/StructureInformationsTrait.php index 22b634a..87d8014 100644 --- a/src/Entity/Pia/Traits/StructureInformationsTrait.php +++ b/src/Entity/Pia/Traits/StructureInformationsTrait.php @@ -12,6 +12,30 @@ trait StructureInformationsTrait { + /** + * @ORM\Column(type="string", nullable=true) + * @JMS\Groups({"Default", "Export"}) + * + * @var string + */ + protected $executive; + + /** + * @ORM\Column(type="string", nullable=true) + * @JMS\Groups({"Default", "Export"}) + * + * @var string + */ + protected $backup; + + /** + * @ORM\Column(type="string", nullable=true) + * @JMS\Groups({"Default", "Export"}) + * + * @var string + */ + protected $dpo; + /** * @ORM\Column(type="string", nullable=true) * @JMS\Groups({"Default", "Export"}) @@ -76,6 +100,54 @@ trait StructureInformationsTrait */ protected $registrationDate; + /** + * @return string + */ + public function getExecutive(): ?string + { + return $this->executive; + } + + /** + * @param string $executive + */ + public function setExecutive(?string $executive = null): void + { + $this->executive = $executive; + } + + /** + * @return string + */ + public function getBackup(): ?string + { + return $this->backup; + } + + /** + * @param string $backup + */ + public function setBackup(?string $backup = null): void + { + $this->backup = $backup; + } + + /** + * @return string + */ + public function getDpo(): ?string + { + return $this->dpo; + } + + /** + * @param string $dpo + */ + public function setDpo(?string $dpo = null): void + { + $this->dpo = $dpo; + } + /** * @return string */ diff --git a/src/Migrations/Version20180924091844.php b/src/Migrations/Version20180924091844.php index 58c2bde..9976a72 100644 --- a/src/Migrations/Version20180924091844.php +++ b/src/Migrations/Version20180924091844.php @@ -1,5 +1,13 @@ addSql('DROP SEQUENCE pia_processing_comment_id_seq CASCADE'); $this->addSql('DROP TABLE pia_processing_comment'); } -} \ No newline at end of file +} diff --git a/src/Migrations/Version20181010095819.php b/src/Migrations/Version20181010095819.php new file mode 100644 index 0000000..332d5ce --- /dev/null +++ b/src/Migrations/Version20181010095819.php @@ -0,0 +1,31 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_structure ADD executive VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE pia_structure ADD backup VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE pia_structure ADD dpo VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema) + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_structure DROP executive'); + $this->addSql('ALTER TABLE pia_structure DROP backup'); + $this->addSql('ALTER TABLE pia_structure DROP dpo'); + } +} \ No newline at end of file diff --git a/src/Migrations/Version20181010123814.php b/src/Migrations/Version20181010123814.php new file mode 100644 index 0000000..6c27e00 --- /dev/null +++ b/src/Migrations/Version20181010123814.php @@ -0,0 +1,27 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_folder ADD person_in_charge VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema) + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_folder DROP person_in_charge'); + } +} \ No newline at end of file diff --git a/src/Migrations/Version20181015084613.php b/src/Migrations/Version20181015084613.php new file mode 100644 index 0000000..16a70c5 --- /dev/null +++ b/src/Migrations/Version20181015084613.php @@ -0,0 +1,27 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_processing ADD concerned_people TEXT DEFAULT NULL'); + } + + public function down(Schema $schema) + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE pia_processing DROP concerned_people'); + } +} \ No newline at end of file diff --git a/src/Services/FolderService.php b/src/Services/FolderService.php index 1f7ba70..6a16355 100644 --- a/src/Services/FolderService.php +++ b/src/Services/FolderService.php @@ -27,7 +27,7 @@ public function getEntityClass(): string * * @return Folder */ - public function createFolder(string $name, ?Structure $structure = null, ?Folder $parent = null): Folder + public function createFolder(string $name, ?Structure $structure = null, ?Folder $parent = null, ?string $personInCharge = null): Folder { $folder = new Folder($name, $structure); @@ -35,6 +35,10 @@ public function createFolder(string $name, ?Structure $structure = null, ?Folder $folder->setParent($parent); } + if($personInCharge !== null) { + $folder->setPersonInCharge($personInCharge); + } + return $folder; } } diff --git a/tests/api/060_PiaFoldersCest.php b/tests/api/060_PiaFoldersCest.php index c254e7f..13b8b85 100644 --- a/tests/api/060_PiaFoldersCest.php +++ b/tests/api/060_PiaFoldersCest.php @@ -21,22 +21,24 @@ class PiaFoldersCest use _support\ApiFixturesTrait; private $folderJsonType = [ - 'isRoot' => 'boolean', - 'path' => 'string', - 'hierarchy' => 'array', - 'name' => 'string', - 'lft' => 'integer', - 'lvl' => 'integer', - 'rgt' => 'integer', - 'parent' => 'array|null', - 'children' => 'array', - 'id' => 'integer', - 'created_at' => 'string', - 'updated_at' => 'string', + 'isRoot' => 'boolean', + 'path' => 'string', + 'hierarchy' => 'array', + 'name' => 'string', + 'person_in_charge' => 'string|null', + 'lft' => 'integer', + 'lvl' => 'integer', + 'rgt' => 'integer', + 'parent' => 'array|null', + 'children' => 'array', + 'id' => 'integer', + 'created_at' => 'string', + 'updated_at' => 'string', ]; private $folderData = [ 'name' => 'codecept-folder', + 'person_in_charge' => 'codecept-person-in-charge' ]; private $folder = []; diff --git a/tests/api/110_AdminStructuresCest.php b/tests/api/110_AdminStructuresCest.php index 18c7033..7c8172e 100644 --- a/tests/api/110_AdminStructuresCest.php +++ b/tests/api/110_AdminStructuresCest.php @@ -42,6 +42,9 @@ class AdminStructuresCest 'vat_number' => 'string|null', 'activity_code' => 'string|null', 'legal_form' => 'string|null', + 'executive' => 'string|null', + 'backup' => 'string|null', + 'dpo' => 'string|null', 'registration_date' => 'string|null', ]; diff --git a/tests/api/130_ProcessingCest.php b/tests/api/130_ProcessingCest.php index db0be52..dbc4e32 100644 --- a/tests/api/130_ProcessingCest.php +++ b/tests/api/130_ProcessingCest.php @@ -52,6 +52,7 @@ class ProcessingCest 'life_cycle' => 'life cycle edited', 'storage' => 'storage edited', 'standards' => 'standards edited', + 'concernd_people' => 'concerned people edited', 'status' => 3, 'created_at' => '2018-08-01T17:17:16+0200', 'updated_at' => '2018-08-03T11:55:27+0200', @@ -98,6 +99,7 @@ class ProcessingCest 'rights_guarantee' => 'string|null', 'exactness' => 'string|null', 'consent' => 'string|null', + 'concerned_people' => 'string|null', 'processing_data_types' => 'array', 'pias_count' => 'integer', 'folder' => 'array', diff --git a/tests/api/141_ProcessingCommentCest.php b/tests/api/141_ProcessingCommentCest.php index eb96bac..9c78a18 100644 --- a/tests/api/141_ProcessingCommentCest.php +++ b/tests/api/141_ProcessingCommentCest.php @@ -99,7 +99,7 @@ public function edit_processing_comment_test(ApiTester $I) $field = 'edited field'; $data = array_merge($this->processingComment, [ - 'content' => $content, + 'content' => $content, 'field' => $field, ]);