Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
madis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Soluris
madis
Commits
16315766
Commit
16315766
authored
1 year ago
by
Jonathan Foucher
Browse files
Options
Downloads
Patches
Plain Diff
cs-fix
parent
25d41d43
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#57857
failed
1 year ago
Stage: cache
Stage: tests
Stage: quality-assurance
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Domain/AIPD/Command/ImportModelCommand.php
+5
-19
5 additions, 19 deletions
src/Domain/AIPD/Command/ImportModelCommand.php
src/Domain/Maturity/Command/ImportReferentielCommand.php
+5
-22
5 additions, 22 deletions
src/Domain/Maturity/Command/ImportReferentielCommand.php
with
10 additions
and
41 deletions
src/Domain/AIPD/Command/ImportModelCommand.php
+
5
−
19
View file @
16315766
...
...
@@ -4,19 +4,6 @@ namespace App\Domain\AIPD\Command;
use
App\Domain\AIPD\Model\ModeleAnalyse
;
use
App\Domain\AIPD\Model\ModeleScenarioMenace
;
use
App\Domain\Maturity\Repository\Survey
as
SurveyRepository
;
use
App\Domain\Notification\Event\ConformiteTraitementNeedsAIPDEvent
;
use
App\Domain\Notification\Event\LateActionEvent
;
use
App\Domain\Notification\Event\LateRequestEvent
;
use
App\Domain\Notification\Event\LateSurveyEvent
;
use
App\Domain\Notification\Event\NoLoginEvent
;
use
App\Domain\Registry\Model\ConformiteTraitement\ConformiteTraitement
;
use
App\Domain\Registry\Model\Mesurement
;
use
App\Domain\Registry\Model\TreatmentDataCategory
;
use
App\Domain\User\Repository\User
as
UserRepository
;
use
App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement\ConformiteTraitement
as
ConformiteTraitementRepository
;
use
App\Infrastructure\ORM\Registry\Repository\Mesurement
as
MesurementRepository
;
use
App\Infrastructure\ORM\Registry\Repository\Request
as
RequestRepository
;
use
Doctrine\ORM\EntityManagerInterface
;
use
JMS\Serializer\SerializerBuilder
;
use
Symfony\Component\Console\Command\Command
;
...
...
@@ -24,7 +11,6 @@ use Symfony\Component\Console\Input\InputArgument;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Style\SymfonyStyle
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
class
ImportModelCommand
extends
Command
{
...
...
@@ -34,7 +20,6 @@ class ImportModelCommand extends Command
private
SymfonyStyle
$io
;
private
EntityManagerInterface
$entityManager
;
public
function
__construct
(
EntityManagerInterface
$entityManager
)
{
parent
::
__construct
();
...
...
@@ -60,7 +45,7 @@ class ImportModelCommand extends Command
protected
function
importAIPDModel
(
string
$file
):
int
{
$this
->
io
->
title
(
'Importing AIPD model from '
.
$file
);
$this
->
io
->
title
(
'Importing AIPD model from '
.
$file
);
$content
=
file_get_contents
(
$file
);
$serializer
=
SerializerBuilder
::
create
()
->
build
();
/** @var ModeleAnalyse $object */
...
...
@@ -70,17 +55,18 @@ class ImportModelCommand extends Command
$existing
=
$this
->
entityManager
->
getRepository
(
ModeleAnalyse
::
class
)
->
findBy
([
'nom'
=>
$object
->
getNom
(),
'description'
=>
$object
->
getDescription
()]);
if
(
count
(
$existing
))
{
$this
->
io
->
warning
(
'AIPD model "'
.
$object
->
getNom
()
.
'" already exists'
);
$this
->
io
->
warning
(
'AIPD model "'
.
$object
->
getNom
()
.
'" already exists'
);
return
0
;
}
$sm
=
[];
foreach
(
$object
->
getScenarioMenaces
()
as
$scenarioMenace
)
{
$this
->
io
->
writeln
(
'Importing scenario menace '
.
$scenarioMenace
->
getNom
());
$this
->
io
->
writeln
(
'Importing scenario menace '
.
$scenarioMenace
->
getNom
());
/** @var ModeleScenarioMenace $scenarioMenace */
$mesures
=
[];
foreach
(
$scenarioMenace
->
getMesuresProtections
()
as
$mesureProtection
)
{
$this
->
io
->
writeln
(
'Importing $mesureProtection '
.
$mesureProtection
->
getNom
());
$this
->
io
->
writeln
(
'Importing $mesureProtection '
.
$mesureProtection
->
getNom
());
// Check if this mesure already exists
$mm
=
$this
->
entityManager
->
find
(
\App\Domain\AIPD\Model\ModeleMesureProtection
::
class
,
$mesureProtection
->
getId
());
if
(
$mm
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Domain/Maturity/Command/ImportReferentielCommand.php
+
5
−
22
View file @
16315766
...
...
@@ -2,22 +2,7 @@
namespace
App\Domain\Maturity\Command
;
use
App\Domain\AIPD\Model\ModeleAnalyse
;
use
App\Domain\AIPD\Model\ModeleScenarioMenace
;
use
App\Domain\Maturity\Model\Referentiel
;
use
App\Domain\Maturity\Repository\Survey
as
SurveyRepository
;
use
App\Domain\Notification\Event\ConformiteTraitementNeedsAIPDEvent
;
use
App\Domain\Notification\Event\LateActionEvent
;
use
App\Domain\Notification\Event\LateRequestEvent
;
use
App\Domain\Notification\Event\LateSurveyEvent
;
use
App\Domain\Notification\Event\NoLoginEvent
;
use
App\Domain\Registry\Model\ConformiteTraitement\ConformiteTraitement
;
use
App\Domain\Registry\Model\Mesurement
;
use
App\Domain\Registry\Model\TreatmentDataCategory
;
use
App\Domain\User\Repository\User
as
UserRepository
;
use
App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement\ConformiteTraitement
as
ConformiteTraitementRepository
;
use
App\Infrastructure\ORM\Registry\Repository\Mesurement
as
MesurementRepository
;
use
App\Infrastructure\ORM\Registry\Repository\Request
as
RequestRepository
;
use
Doctrine\ORM\EntityManagerInterface
;
use
JMS\Serializer\SerializerBuilder
;
use
Symfony\Component\Console\Command\Command
;
...
...
@@ -25,7 +10,6 @@ use Symfony\Component\Console\Input\InputArgument;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Style\SymfonyStyle
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\Finder\Finder
;
class
ImportReferentielCommand
extends
Command
...
...
@@ -36,7 +20,6 @@ class ImportReferentielCommand extends Command
private
SymfonyStyle
$io
;
private
EntityManagerInterface
$entityManager
;
public
function
__construct
(
EntityManagerInterface
$entityManager
)
{
parent
::
__construct
();
...
...
@@ -56,7 +39,7 @@ class ImportReferentielCommand extends Command
$this
->
io
=
new
SymfonyStyle
(
$input
,
$output
);
$finder
=
new
Finder
();
$finder
->
files
()
->
in
(
$input
->
getArgument
(
'folder'
));
$finder
->
files
()
->
in
(
$input
->
getArgument
(
'folder'
));
if
(
$finder
->
hasResults
())
{
foreach
(
$finder
as
$file
)
{
...
...
@@ -64,13 +47,12 @@ class ImportReferentielCommand extends Command
}
}
return
Command
::
SUCCESS
;
}
protected
function
importReferentiel
(
string
$file
):
int
{
$this
->
io
->
title
(
'Importing Référentiel from '
.
$file
);
$this
->
io
->
title
(
'Importing Référentiel from '
.
$file
);
$content
=
file_get_contents
(
$file
);
$serializer
=
SerializerBuilder
::
create
()
->
build
();
/** @var Referentiel $object */
...
...
@@ -80,14 +62,15 @@ class ImportReferentielCommand extends Command
$existing
=
$this
->
entityManager
->
getRepository
(
Referentiel
::
class
)
->
findBy
([
'name'
=>
$object
->
getName
()]);
if
(
count
(
$existing
))
{
$this
->
io
->
warning
(
'Référentiel "'
.
$object
->
getName
()
.
'" already exists'
);
$this
->
io
->
warning
(
'Référentiel "'
.
$object
->
getName
()
.
'" already exists'
);
return
0
;
}
$object
->
setCreatedAt
(
new
\DateTimeImmutable
());
$this
->
entityManager
->
persist
(
$object
);
$this
->
entityManager
->
flush
();
$this
->
io
->
success
(
'Référentiel "'
.
$object
->
getName
()
.
'" imported'
);
$this
->
io
->
success
(
'Référentiel "'
.
$object
->
getName
()
.
'" imported'
);
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment