Skip to content

Commit

Permalink
fixup! fixup! Fixes #15265: Migrate ncf delete api and improve workflow
Browse files Browse the repository at this point in the history
Fixes #15265: Migrate ncf delete api and improve workflow
  • Loading branch information
VinceMacBuche committed Jul 31, 2019
1 parent 07d4015 commit 5d27ecf
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,25 @@ class TechniqueWriter (
directives <- readDirectives.getFullDirectiveLibrary().map(_.allActiveTechniques.values.filter(_.techniqueName.value == techniqueId.name).flatMap(_.directives).filter(_.techniqueVersion == techniqueId.version))

technique <- techniqueRepository.get(techniqueId).notOptional(s"No Technique with ID '${techniqueId.toString()}' found in reference library.")

// Check if we have directives, and either, make an error, if we don't force deletion, or delete them all, creating a change request
_ <- directives match {
case Nil => directives.succeed
case Nil => UIO.unit
case _ =>
if (deleteDirective) {
val wf = workflowLevelService.getWorkflowService()
for {
cr <- directives.map(createCr(_,technique.rootSection)).reduceOption(mergeCrs).notOptional(s"Could not create a change request to delete ${techniqueName}/${techniqueVersion} directives")
_ <- wf.startWorkflow(cr, committer, Some(s"Deleting technique ${techniqueName}/${techniqueVersion}")).succeed
} yield {
cr
()
}
} else
Unexpected(s"${directives.size} directives are defined for ${techniqueName}/${techniqueVersion} please delete them, or force deletion").fail
}
_ <- archiver.deleteTechnique(techniqueName,techniqueVersion,modId,committer, s"Deleting technique ${techniqueName}/${techniqueVersion}")

libUpdate <- techLibUpdate.update(modId, committer, Some(s"Update Technique library after deletion of Technique ${techniqueName}")).succeed.chainError(s"An error occurred during technique update after deletion of Technique ${techniqueName}")
_ <- techLibUpdate.update(modId, committer, Some(s"Update Technique library after deletion of Technique ${techniqueName}")).succeed.chainError(s"An error occurred during technique update after deletion of Technique ${techniqueName}")
} yield {
()
}
Expand Down

0 comments on commit 5d27ecf

Please sign in to comment.