Skip to content

Commit

Permalink
Task/rdmp 207 cohort version description (#1900)
Browse files Browse the repository at this point in the history
* cohort description update

* add test

* update from codeql
  • Loading branch information
JFriel authored Jul 25, 2024
1 parent 2ec63bd commit c2ad6d7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Misc improvements to the DQE
- Fix Project Creation UI issue
- Fix issue with whitespace confusing encryption key paths
- Add ability to add description to new cohort versions
- Add functionality to revert to historical cohort version

## [8.2.1] - 2024-07-18
Expand Down
17 changes: 17 additions & 0 deletions Rdmp.Core.Tests/CohortCreation/CohortVersioningTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ public void TestCreationOfNewVersionOfCohort()
});
}

[Test]
public void TestCreationOfNewVersionOfCohortWithDescription()
{
var activator = new ConsoleInputManager(RepositoryLocator, ThrowImmediatelyCheckNotifier.Quiet)
{ DisallowInput = true };
var cic = GenerateCIC();
var cmd = new ExecuteCommandCreateVersionOfCohortConfiguration(activator, cic,"Name","Description");
Assert.DoesNotThrow(() => cmd.Execute());
var newCic = CatalogueRepository.GetAllObjectsWhere<CohortIdentificationConfiguration>("ClonedFrom_ID", cic.ID);
Assert.That(newCic, Has.Length.EqualTo(1));
Assert.That(newCic.First().Version, Is.EqualTo(1));
Assert.That(newCic.First().Name, Is.EqualTo("Name"));
Assert.That(newCic.First().Description, Is.EqualTo("Description"));


}

[Test]
public void TestCreatingCohortVersionWithName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public class ExecuteCommandCreateVersionOfCohortConfiguration : BasicCommandExec
readonly CohortIdentificationConfiguration _cic;
readonly IBasicActivateItems _activator;
readonly string _name;
readonly string _description;

public ExecuteCommandCreateVersionOfCohortConfiguration(IBasicActivateItems activator, CohortIdentificationConfiguration cic, string name = null) : base(activator)
public ExecuteCommandCreateVersionOfCohortConfiguration(IBasicActivateItems activator, CohortIdentificationConfiguration cic, string name = null,string description=null) : base(activator)
{
_cic = cic;
_activator = activator;
_name = name;
_description = description;
}


Expand All @@ -36,5 +38,16 @@ public override void Execute()
}
var cmd = new ExecuteCommandCloneCohortIdentificationConfiguration(_activator, _cic, _name, version, true);
cmd.Execute();
if (_description is not null)
{
var createdItem = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere<CohortIdentificationConfiguration>("ClonedFrom_ID", _cic.ID).Where(cic => cic.Name == _name);
if (createdItem.Any())
{
createdItem.First().Description = _description;
createdItem.First().SaveToDatabase();
Publish(createdItem.First());
}
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c2ad6d7

Please sign in to comment.