Skip to content

Commit

Permalink
Merge pull request #52 from monarc-project/feature/353
Browse files Browse the repository at this point in the history
Feature/353 Changeable operational risks
  • Loading branch information
cedricbonhomme authored Sep 2, 2021
2 parents 10bc561 + 8194212 commit 07b633d
Show file tree
Hide file tree
Showing 74 changed files with 4,949 additions and 1,504 deletions.
118 changes: 85 additions & 33 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Monarc\Core\Service;
use Monarc\Core\Storage\Authentication as StorageAuthentication;
use Monarc\Core\Validator\LanguageValidator;
use Monarc\FrontOffice\Model\Table\Factory\CoreEntityManagerFactory;
use Ramsey\Uuid\Doctrine\UuidType;
use Laminas\Di\Container\AutowireFactory;
use Monarc\Core\Model\Entity as ModelEntity;
Expand Down Expand Up @@ -123,6 +124,19 @@
],
],

'monarc_api_anr_risk_owners' => [
'type' => 'segment',
'options' => [
'route' => '/api/anr/:anrid/risk-owners[/:id]',
'constraints' => [
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\ApiAnrRiskOwnersController::class,
],
],
],

'monarc_api_anr_instances_consequences' => [
'type' => 'segment',
'options' => [
Expand Down Expand Up @@ -292,6 +306,33 @@
],
],

'monarc_api_operational_scales' => [
'type' => 'segment',
'options' => [
'route' => '/api/anr/:anrId/operational-scales[/:id]',
'constraints' => [
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\ApiOperationalRisksScalesController::class,
],
],
],

'monarc_api_operational_scales_comment' => [
'type' => 'segment',
'options' => [
'route' => '/api/anr/:anrId/operational-scales/:scaleid/comments[/:id]',
'constraints' => [
'id' => '[0-9]+',
'scaleid' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\ApiOperationalRisksScalesCommentsController::class,
],
],
],

'monarc_api_scales_comments' => [
'type' => 'segment',
'options' => [
Expand Down Expand Up @@ -360,7 +401,7 @@
Service\HistoricalService::class => Service\HistoricalServiceFactory::class,
Service\InstanceService::class => Service\InstanceServiceFactory::class,
Service\InstanceRiskService::class => Service\InstanceRiskServiceFactory::class,
Service\InstanceRiskOpService::class => Service\InstanceRiskOpServiceFactory::class,
Service\InstanceRiskOpService::class => AutowireFactory::class,
Service\InstanceConsequenceService::class => Service\InstanceConsequenceServiceFactory::class,
Service\MailService::class => AutowireFactory::class,
Service\ReferentialService::class => Service\ReferentialServiceFactory::class,
Expand Down Expand Up @@ -388,6 +429,9 @@
Service\AnrObjectService::class => Service\AnrObjectServiceFactory::class,
Service\AssetImportService::class => AutowireFactory::class,
Service\ObjectImportService::class => AutowireFactory::class,
Service\OperationalRiskScaleService::class => AutowireFactory::class,
Service\OperationalRiskScaleCommentService::class => AutowireFactory::class,
Service\OperationalRiskScalesExportService::class => AutowireFactory::class,

// TODO: Entities are created from the code. Should be removed.
ModelEntity\DeliveriesModels::class => ServiceModelEntity\DeliveriesModelsServiceModelEntity::class,
Expand Down Expand Up @@ -422,37 +466,42 @@
ModelTable\UserTable::class => AutowireFactory::class,
ModelTable\UserTokenTable::class => AutowireFactory::class,
ModelTable\UserRoleTable::class => AutowireFactory::class,
ModelTable\ModelTable::class => AutowireFactory::class,
ModelTable\AnrTable::class => AutowireFactory::class,
ModelTable\AnrObjectCategoryTable::class => AutowireFactory::class,
ModelTable\QuestionTable::class => AutowireFactory::class,
ModelTable\QuestionChoiceTable::class => AutowireFactory::class,
ModelTable\GuideTable::class => AutowireFactory::class,
ModelTable\GuideItemTable::class => AutowireFactory::class,
ModelTable\ReferentialTable::class => AutowireFactory::class,
ModelTable\MeasureTable::class => AutowireFactory::class,
ModelTable\MeasureMeasureTable::class => AutowireFactory::class,
ModelTable\SoaCategoryTable::class => AutowireFactory::class,
ModelTable\MonarcObjectTable::class => AutowireFactory::class,
ModelTable\InstanceTable::class => AutowireFactory::class,
ModelTable\InstanceConsequenceTable::class => AutowireFactory::class,
ModelTable\InstanceRiskTable::class => AutowireFactory::class,
ModelTable\InstanceRiskOpTable::class => AutowireFactory::class,
ModelTable\ObjectCategoryTable::class => AutowireFactory::class,
ModelTable\ObjectObjectTable::class => AutowireFactory::class,
ModelTable\ThemeTable::class => AutowireFactory::class,
ModelTable\HistoricalTable::class => AutowireFactory::class,
ModelTable\AssetTable::class => AutowireFactory::class,
ModelTable\ModelTable::class => AutowireFactory::class,
ModelTable\AnrTable::class => AutowireFactory::class,
ModelTable\AnrObjectCategoryTable::class => AutowireFactory::class,
ModelTable\QuestionTable::class => AutowireFactory::class,
ModelTable\QuestionChoiceTable::class => AutowireFactory::class,
ModelTable\GuideTable::class => AutowireFactory::class,
ModelTable\GuideItemTable::class => AutowireFactory::class,
ModelTable\ReferentialTable::class => AutowireFactory::class,
ModelTable\MeasureTable::class => AutowireFactory::class,
ModelTable\MeasureMeasureTable::class => AutowireFactory::class,
ModelTable\SoaCategoryTable::class => AutowireFactory::class,
ModelTable\MonarcObjectTable::class => AutowireFactory::class,
ModelTable\InstanceTable::class => AutowireFactory::class,
ModelTable\InstanceConsequenceTable::class => AutowireFactory::class,
ModelTable\InstanceRiskTable::class => AutowireFactory::class,
ModelTable\InstanceRiskOpTable::class => AutowireFactory::class,
ModelTable\ObjectCategoryTable::class => AutowireFactory::class,
ModelTable\ObjectObjectTable::class => AutowireFactory::class,
ModelTable\ThemeTable::class => AutowireFactory::class,
ModelTable\HistoricalTable::class => AutowireFactory::class,
ModelTable\AssetTable::class => AutowireFactory::class,
ModelTable\AmvTable::class => AutowireFactory::class,
ModelTable\ThreatTable::class => AutowireFactory::class,
ModelTable\RolfTagTable::class => AutowireFactory::class,
ModelTable\RolfRiskTable::class => AutowireFactory::class,
ModelTable\ScaleTable::class => AutowireFactory::class,
ModelTable\ScaleCommentTable::class => AutowireFactory::class,
ModelTable\ScaleImpactTypeTable::class => AutowireFactory::class,
ModelTable\VulnerabilityTable::class => AutowireFactory::class,
ModelTable\PasswordTokenTable::class => AutowireFactory::class,
ModelTable\DeliveriesModelsTable::class => AutowireFactory::class,
ModelTable\ThreatTable::class => AutowireFactory::class,
ModelTable\RolfTagTable::class => AutowireFactory::class,
ModelTable\RolfRiskTable::class => AutowireFactory::class,
ModelTable\ScaleTable::class => AutowireFactory::class,
ModelTable\ScaleCommentTable::class => AutowireFactory::class,
ModelTable\OperationalRiskScaleTable::class => CoreEntityManagerFactory::class,
ModelTable\OperationalRiskScaleTypeTable::class => CoreEntityManagerFactory::class,
ModelTable\OperationalRiskScaleCommentTable::class => CoreEntityManagerFactory::class,
ModelTable\OperationalInstanceRiskScaleTable::class => CoreEntityManagerFactory::class,
ModelTable\ScaleImpactTypeTable::class => AutowireFactory::class,
ModelTable\VulnerabilityTable::class => AutowireFactory::class,
ModelTable\PasswordTokenTable::class => AutowireFactory::class,
ModelTable\DeliveriesModelsTable::class => AutowireFactory::class,
ModelTable\InstanceRiskOwnerTable::class => CoreEntityManagerFactory::class,

/* Authentification */
StorageAuthentication::class => ReflectionBasedAbstractFactory::class,
Expand Down Expand Up @@ -502,13 +551,14 @@
Controller\IndexController::class => InvokableFactory::class,
Controller\AuthenticationController::class => AutowireFactory::class,
Controller\ApiAnrController::class => Controller\ApiAnrControllerFactory::class,
Controller\ApiAnrRiskOwnersController::class => AutowireFactory::class,
Controller\ApiAnrRisksController::class => AutowireFactory::class,
Controller\ApiAnrRisksOpController::class => Controller\ApiAnrRisksOpControllerFactory::class,
Controller\ApiAnrRisksOpController::class => AutowireFactory::class,
Controller\ApiAnrExportController::class => AutowireFactory::class,
Controller\ApiAnrInstancesController::class => Controller\ApiAnrInstancesControllerFactory::class,
Controller\ApiAnrInstancesConsequencesController::class => Controller\ApiAnrInstancesConsequencesControllerFactory::class,
Controller\ApiAnrInstancesRisksController::class => Controller\ApiAnrInstancesRisksControllerFactory::class,
Controller\ApiAnrInstancesRisksOpController::class => Controller\ApiAnrInstancesRisksOpControllerFactory::class,
Controller\ApiAnrInstancesRisksOpController::class => AutowireFactory::class,
Controller\ApiAnrLibraryController::class => Controller\ApiAnrLibraryControllerFactory::class,
Controller\ApiAnrLibraryCategoryController::class => Controller\ApiAnrLibraryCategoryControllerFactory::class,
Controller\ApiAnrObjectController::class => Controller\ApiAnrObjectControllerFactory::class,
Expand All @@ -517,6 +567,8 @@
Controller\ApiAnrScalesController::class => Controller\ApiAnrScalesControllerFactory::class,
Controller\ApiAnrScalesTypesController::class => Controller\ApiAnrScalesTypesControllerFactory::class,
Controller\ApiAnrScalesCommentsController::class => Controller\ApiAnrScalesCommentsControllerFactory::class,
Controller\ApiOperationalRisksScalesController::class => AutowireFactory::class,
Controller\ApiOperationalRisksScalesCommentsController::class => AutowireFactory::class,
],
],

Expand Down
63 changes: 63 additions & 0 deletions migrations/db/20210521080000_add_owner_context_risks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;

class AddOwnerContextRisks extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->execute(
'CREATE TABLE IF NOT EXISTS `instance_risk_owners` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`anr_id` int(11) unsigned,
`name` varchar(255) NOT NULL,
`creator` varchar(255) NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updater` varchar(255) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
INDEX `instance_risk_owners_anr_id_indx` (`anr_id`),
UNIQUE `instance_risk_owners_anr_id_name_unq` (`anr_id`, `name`),
CONSTRAINT `instance_risk_owners_anr_id_fk` FOREIGN KEY(`anr_id`) REFERENCES anrs (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
);'
);

// Migration for table instances_risks
$table = $this->table('instances_risks');
$table
->addColumn('owner_id', 'integer', array('null' => true, 'signed' => false, 'after' => 'instance_id'))
->addForeignKey('owner_id', 'instance_risk_owners', 'id', ['delete'=> 'CASCADE', 'update'=> 'RESTRICT'])
->addColumn('context', 'text', array('null' => true, 'limit' => MysqlAdapter::TEXT_REGULAR, 'after' => 'owner_id'))
->update();

// Migration for table instances_risks_op
$table = $this->table('instances_risks_op');
$table
->addColumn('owner_id', 'integer', array('null' => true, 'signed' => false, 'after' => 'instance_id'))
->addForeignKey('owner_id', 'instance_risk_owners', 'id', ['delete'=> 'CASCADE', 'update'=> 'RESTRICT'])
->addColumn('context', 'text', array('null' => true, 'limit' => MysqlAdapter::TEXT_REGULAR, 'after' => 'owner_id'))
->update();
}
}
Loading

0 comments on commit 07b633d

Please sign in to comment.