Skip to content

Commit

Permalink
Move templates from pia to processing (#71)
Browse files Browse the repository at this point in the history
* Move template reference from PIA to Processing
  • Loading branch information
GlennCavarle authored and PapsOu committed Sep 7, 2018
1 parent a1cd8c3 commit 44baf98
Show file tree
Hide file tree
Showing 28 changed files with 498 additions and 400 deletions.
14 changes: 7 additions & 7 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ security:
- CAN_EDIT_PORTFOLIO
- CAN_DELETE_PORTFOLIO

CAN_MANAGE_PIA_TEMPLATES:
- CAN_SHOW_PIA_TEMPLATE
- CAN_CREATE_PIA_TEMPLATE
- CAN_EDIT_PIA_TEMPLATE
- CAN_DELETE_PIA_TEMPLATE
CAN_MANAGE_PROCESSING_TEMPLATES:
- CAN_SHOW_PROCESSING_TEMPLATE
- CAN_CREATE_PROCESSING_TEMPLATE
- CAN_EDIT_PROCESSING_TEMPLATE
- CAN_DELETE_PROCESSING_TEMPLATE

CAN_EXPLORE_PIAS:
- CAN_SHOW_PROCESSING
Expand Down Expand Up @@ -140,7 +140,7 @@ security:
- CAN_MANAGE_PROCESSINGS
- CAN_MANAGE_PIAS
- CAN_ACCESS_BACK_OFFICE
- CAN_SHOW_PIA_TEMPLATE
- CAN_SHOW_PROCESSING_TEMPLATE
- CAN_IMPORT_PIA
- CAN_MANAGE_FOLDERS
- CAN_MANAGE_ONLY_OWNED_USERS
Expand Down Expand Up @@ -174,7 +174,7 @@ security:
ROLE_SUPER_ADMIN:
- ROLE_TECHNICAL_ADMIN
- CAN_EXPORT_PIA
- CAN_MANAGE_PIA_TEMPLATES
- CAN_MANAGE_PROCESSING_TEMPLATES


encoders:
Expand Down
2 changes: 1 addition & 1 deletion config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ services:
#
# test.App\Service\MyService: '@App\Service\MyService'
JsonToEntityTransformer: '@PiaApi\DataExchange\Transformer\JsonToEntityTransformer'
PiaTemplateService: '@PiaApi\Services\PiaTemplateService'
ProcessingTemplateService: '@PiaApi\Services\ProcessingTemplateService'
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use Doctrine\ORM\EntityManagerInterface;
use PiaApi\DataExchange\Transformer\JsonToEntityTransformer;
use PiaApi\Entity\Pia\Pia;
use PiaApi\Entity\Pia\PiaTemplate;
use PiaApi\Entity\Pia\ProcessingTemplate;
use PiaApi\Entity\Pia\Structure;
use PiaApi\Services\PiaTemplateService;
use PiaApi\Services\ProcessingTemplateService;
use splitbrain\PHPArchive\Tar;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -26,7 +26,7 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

class PiaTemplatesBatchImportCommand extends Command
class ProcessingTemplatesBatchImportCommand extends Command
{
const NAME = 'pia:templates:batch-import';

Expand All @@ -41,9 +41,9 @@ class PiaTemplatesBatchImportCommand extends Command
protected $entityManager;

/**
* @var PiaTemplateService
* @var ProcessingTemplateService
*/
protected $piaTemplateService;
protected $processingTemplateService;

/**
* @var SymfonyStyle
Expand All @@ -58,19 +58,19 @@ class PiaTemplatesBatchImportCommand extends Command
public function __construct(
EntityManagerInterface $entityManager,
JsonToEntityTransformer $jsonToEntityTransformer,
PiaTemplateService $piaTemplateService
ProcessingTemplateService $processingTemplateService
) {
parent::__construct();
$this->entityManager = $entityManager;
$this->jsonToEntityTransformer = $jsonToEntityTransformer;
$this->piaTemplateService = $piaTemplateService;
$this->processingTemplateService = $processingTemplateService;
}

protected function configure()
{
$this
->setName(self::NAME)
->setDescription('Imports a collection of PIA templates into backend')
->setDescription('Imports a collection of processing templates into backend')
->setHelp('This command allows you to import all json files included in a specific folder as PIA templates')
->addArgument('path', InputArgument::REQUIRED, 'The target directory (or archive) that contains templates json files (can be relative or absolute)')
->addOption('enable-all', null, InputOption::VALUE_NONE, 'Does the templates imported should be enabled ? By default, all templates are disabled')
Expand Down Expand Up @@ -136,14 +136,14 @@ private function extractArchive(string $archivePath): string
return $tempDir;
}

private function buildTemplate(string $filePath, string $fileName, bool $enabled = false): PiaTemplate
private function buildTemplate(string $filePath, string $fileName, bool $enabled = false): ProcessingTemplate
{
$templateJson = file_get_contents($filePath);

// Fetching template json as entity in order to get target template name only
$pia = $this->fetchDataAsEntities($templateJson);

$template = $this->piaTemplateService->createTemplate(
$template = $this->processingTemplateService->createTemplate(
$pia->getName(),
$templateJson,
$fileName
Expand Down
160 changes: 0 additions & 160 deletions src/Controller/BackOffice/PiaTemplateController.php

This file was deleted.

Loading

0 comments on commit 44baf98

Please sign in to comment.