From 6a0be2930ee11f847a5de3f648cc1111f2e87e77 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Tue, 9 Feb 2021 11:12:19 +0100 Subject: [PATCH] Only use Jira ticket status for requested removal --- CHANGELOG.md | 4 +++ .../Application/Service/EntityService.php | 33 ++++--------------- .../Resources/config/services.yml | 1 - 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f561397e..be6a7788c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.7.2 +**Bugfix** +Set correct publication state for prod entities PART II #394 + ## 2.7.1 **Bugfix** diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Service/EntityService.php b/src/Surfnet/ServiceProviderDashboard/Application/Service/EntityService.php index e66101b7d..27f1e40b4 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Service/EntityService.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Service/EntityService.php @@ -72,11 +72,6 @@ class EntityService implements EntityServiceInterface */ private $prodManageConfig; - /** - * @var string - */ - private $publishStatus; - /** * @var string */ @@ -92,7 +87,6 @@ public function __construct( Config $productionConfig, RouterInterface $router, LoggerInterface $logger, - string $publishStatus, string $removalStatus ) { $this->queryRepositoryProvider = $entityQueryRepositoryProvider; @@ -101,7 +95,6 @@ public function __construct( $this->logger = $logger; $this->testManageConfig = $testConfig; $this->prodManageConfig = $productionConfig; - $this->publishStatus = $publishStatus; $this->removalStatus = $removalStatus; } @@ -161,13 +154,11 @@ public function getEntityByIdAndTarget($id, $manageTarget, Service $service) // with the service desk. $this->updateStatus($entity); - // Todo: review this construction, The ticket is used to determine request for removal, but not for the - // publication state $issue = $this->findIssueBy($entity); $shouldUseTicketStatus = $entity->getStatus() !== Constants::STATE_PUBLISHED && $entity->getStatus() !== Constants::STATE_PUBLICATION_REQUESTED; if ($issue && $shouldUseTicketStatus) { - $this->updateEntityStatusWithJiraTicketStatus($entity, $issue); + $entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED); } return $entity; @@ -293,6 +284,7 @@ private function findPublishedProductionEntitiesByTeamName($teamName) // Extract the Manage entity id's $manageIds = []; foreach ($entities as $entity) { + $this->updateStatus($entity); $manageIds[] = $entity->getId(); } $issueCollection = $this->ticketService->findByManageIds($manageIds); @@ -300,21 +292,15 @@ private function findPublishedProductionEntitiesByTeamName($teamName) // entities if (count($issueCollection) > 0) { foreach ($entities as $entity) { + $this->updateStatus($entity); $issue = $issueCollection->getIssueById($entity->getId()); - if ($issue && !$entity->isExcludedFromPush() && $issue->getIssueType() !== 'spd-delete-production-entity') { + if ($issue && !$entity->isExcludedFromPush() && $issue->getIssueType() !== $this->removalStatus) { // A published entity needs no status update unless it's a removal requested entity continue; } - if ($issue) { - switch ($issue->getIssueType()) { - case $this->publishStatus: - $entity->updateStatus(Constants::STATE_PUBLICATION_REQUESTED); - break; - case $this->removalStatus: - $entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED); - break; - } + if ($issue && $issue->getIssueType() === $this->removalStatus) { + $entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED); } } } @@ -349,13 +335,6 @@ private function findIssueBy(ManageEntity $entity) return null; } - private function updateEntityStatusWithJiraTicketStatus(ManageEntity $entity, Issue $issue) - { - if ($issue instanceof Issue) { - $entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED); - } - } - private function updateStatus(ManageEntity $entity) { $excludeFromPush = $entity->getMetaData()->getCoin()->getExcludeFromPush(); diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml index c6d8a4d88..06ee1a962 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml @@ -309,7 +309,6 @@ services: - '@surfnet.manage.configuration.production' - '@router' - '@logger' - - '%jira_issue_type_publication_request%' - '%jira_issue_type%' Surfnet\ServiceProviderDashboard\Application\Service\LoadEntityService: