-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2586 parameters not common for all species (#2587)
* Added views to DB * DB - adjusted naming of view and columns * Fixes #2586 Provide info which parameters are not common for all species * Fixes #2586 Provide info which parameters are not common for all species * review comments * Add serializer for the new dummy type --------- Co-authored-by: Yuri05 <[email protected]>
- Loading branch information
Showing
12 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
UPDATE tab_container_parameter_values SET default_value=124000.0 WHERE parameter_value_version='InVitroClearance_PKSim' AND species='Cattle' AND container_id=159 AND container_type='ORGAN' AND container_name='Liver' AND parameter_name='Number of cells/g tissue'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace PKSim.Core.Model | ||
{ | ||
public class ContainerParameterBySpecies | ||
{ | ||
public string ContainerPath { get; set; } | ||
public string ParameterName { get; set; } | ||
public int SpeciesCount { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/PKSim.Core/Repositories/IContainerParametersNotCommonForAllSpeciesRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using OSPSuite.Utility.Collections; | ||
using PKSim.Core.Model; | ||
|
||
namespace PKSim.Core.Repositories | ||
{ | ||
public interface IContainerParametersNotCommonForAllSpeciesRepository : IStartableRepository<ContainerParameterBySpecies> | ||
{ | ||
bool UsedForAllSpecies(string containerPath, string parameterName); | ||
|
||
bool UsedForAllSpecies(string parameterFullPath); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/PKSim.Infrastructure/ORM/FlatObjects/FlatContainerParametersNotCommonForAllSpecies.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace PKSim.Infrastructure.ORM.FlatObjects | ||
{ | ||
public class FlatContainerParametersNotCommonForAllSpecies | ||
{ | ||
public int ContainerId { get; set; } | ||
public string ContainerType { get; set; } | ||
public string ContainerName { get; set; } | ||
public string ParameterName { get; set; } | ||
public int SpeciesCount { get; set; } | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...im.Infrastructure/ORM/Repositories/ContainerParametersNotCommonForAllSpeciesRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Utility.Collections; | ||
using PKSim.Core.Model; | ||
using PKSim.Core.Repositories; | ||
|
||
namespace PKSim.Infrastructure.ORM.Repositories | ||
{ | ||
public class ContainerParametersNotCommonForAllSpeciesRepository: StartableRepository<ContainerParameterBySpecies>, IContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private readonly IFlatContainerRepository _flatContainerRepository; | ||
private readonly IFlatContainerParametersNotCommonForAllSpeciesRepository _flatContainerParametersNotCommonForAllSpeciesRepository; | ||
|
||
private readonly List<ContainerParameterBySpecies> _containerParametersNotCommonForAllSpecies; | ||
private readonly ICache<string, List<string>> _parametersNotCommonForAllSpeciesByContainer; | ||
private readonly ICache<string, string> _parametersNotCommonForAllSpeciesByFullPath; | ||
|
||
public ContainerParametersNotCommonForAllSpeciesRepository( | ||
IFlatContainerRepository flatContainerRepository, | ||
IFlatContainerParametersNotCommonForAllSpeciesRepository flatContainerParametersNotCommonForAllSpeciesRepository) | ||
{ | ||
_flatContainerRepository = flatContainerRepository; | ||
_flatContainerParametersNotCommonForAllSpeciesRepository = flatContainerParametersNotCommonForAllSpeciesRepository; | ||
|
||
_containerParametersNotCommonForAllSpecies = new List<ContainerParameterBySpecies>(); | ||
_parametersNotCommonForAllSpeciesByContainer = new Cache<string, List<string>>(); | ||
_parametersNotCommonForAllSpeciesByFullPath = new Cache<string, string>(); | ||
} | ||
|
||
protected override void DoStart() | ||
{ | ||
var flatContainerParametersNotCommonForAllSpecies = _flatContainerParametersNotCommonForAllSpeciesRepository.All().ToList(); | ||
|
||
foreach(var containerParameter in flatContainerParametersNotCommonForAllSpecies) | ||
{ | ||
var containerPath = _flatContainerRepository.ContainerPathFrom(containerParameter.ContainerId).ToString(); | ||
var containerParameterBySpecies = new ContainerParameterBySpecies() | ||
{ | ||
ContainerPath = containerPath, | ||
ParameterName = containerParameter.ParameterName, | ||
SpeciesCount = containerParameter.SpeciesCount | ||
}; | ||
_containerParametersNotCommonForAllSpecies.Add(containerParameterBySpecies); | ||
|
||
//cache by full path | ||
var fullPath = $"{containerPath}{ObjectPath.PATH_DELIMITER}{containerParameter.ParameterName}"; | ||
_parametersNotCommonForAllSpeciesByFullPath.Add(fullPath, fullPath); | ||
} | ||
|
||
//cache the parameters by container path | ||
foreach (var containerParametersInContainer in _containerParametersNotCommonForAllSpecies.GroupBy(x => x.ContainerPath)) | ||
{ | ||
_parametersNotCommonForAllSpeciesByContainer.Add(containerParametersInContainer.Key, containerParametersInContainer.Select(cp=>cp.ParameterName).ToList()); | ||
} | ||
} | ||
|
||
public override IEnumerable<ContainerParameterBySpecies> All() | ||
{ | ||
Start(); | ||
return _containerParametersNotCommonForAllSpecies; | ||
} | ||
|
||
public bool UsedForAllSpecies(string containerPath, string parameterName) | ||
{ | ||
Start(); | ||
var parametersUsedNotForAllSpeciesInContainer = _parametersNotCommonForAllSpeciesByContainer[containerPath]; | ||
|
||
return parametersUsedNotForAllSpeciesInContainer == null || !parametersUsedNotForAllSpeciesInContainer.Contains(parameterName); | ||
} | ||
|
||
public bool UsedForAllSpecies(string parameterFullPath) | ||
{ | ||
Start(); | ||
return !_parametersNotCommonForAllSpeciesByFullPath.Contains(parameterFullPath); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...nfrastructure/ORM/Repositories/FlatContainerParametersNotCommonForAllSpeciesRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using PKSim.Core; | ||
using PKSim.Infrastructure.ORM.Core; | ||
using PKSim.Infrastructure.ORM.FlatObjects; | ||
using PKSim.Infrastructure.ORM.Mappers; | ||
|
||
namespace PKSim.Infrastructure.ORM.Repositories | ||
{ | ||
public interface IFlatContainerParametersNotCommonForAllSpeciesRepository : IMetaDataRepository<FlatContainerParametersNotCommonForAllSpecies> | ||
{ | ||
} | ||
|
||
public class FlatContainerParametersNotCommonForAllSpeciesRepository : MetaDataRepository<FlatContainerParametersNotCommonForAllSpecies>, IFlatContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
public FlatContainerParametersNotCommonForAllSpeciesRepository(IDbGateway dbGateway, IDataTableToMetaDataMapper<FlatContainerParametersNotCommonForAllSpecies> mapper) | ||
: base(dbGateway, mapper, CoreConstants.ORM.VIEW_CONTAINER_PARAMETER_NOT_FOR_ALL_SPECIES) | ||
{ | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...Sim.Infrastructure/Serialization/Xml/Serializers/ContainerParameterBySpeciesSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using PKSim.Core.Model; | ||
|
||
namespace PKSim.Infrastructure.Serialization.Xml.Serializers | ||
{ | ||
public class ContainerParameterBySpeciesSerializer : BaseXmlSerializer<ContainerParameterBySpecies> | ||
{ | ||
public override void PerformMapping() | ||
{ | ||
Map(x => x.ContainerPath); | ||
Map(x => x.ParameterName); | ||
Map(x => x.SpeciesCount); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
.../PKSim.Tests/IntegrationTests/ContainerParametersNotCommonForAllSpeciesRepositorySpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentNHibernate.Utils; | ||
using OSPSuite.BDDHelper; | ||
using OSPSuite.BDDHelper.Extensions; | ||
using PKSim.Core.Model; | ||
using PKSim.Core.Repositories; | ||
|
||
namespace PKSim.IntegrationTests | ||
{ | ||
public abstract class concern_for_ContainerParametersNotCommonForAllSpeciesRepository : ContextForIntegration<IContainerParametersNotCommonForAllSpeciesRepository> | ||
{ | ||
} | ||
|
||
public class When_retrieving_parameters_not_common_for_all_species_from_the_repository : concern_for_ContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private IEnumerable<ContainerParameterBySpecies> _result; | ||
|
||
protected override void Because() | ||
{ | ||
_result = sut.All(); | ||
} | ||
|
||
[Observation] | ||
public void should_return_at_least_one_parameter() | ||
{ | ||
_result.Count().ShouldBeGreaterThan(0); | ||
} | ||
|
||
[Observation] | ||
public void all_parameter_paths_should_start_with_organism_or_neighborhoods() | ||
{ | ||
//because we deal here with individual parameters only: only parameters with path "Organism|..." or "Neighborhoods|..." may appear in the list | ||
_result.Each(p=> | ||
{ | ||
var containerPath = p.ContainerPath; | ||
(containerPath.StartsWith("Organism")|| containerPath.StartsWith("Neighborhoods")).ShouldBeTrue($"{p.ContainerPath}|{p.ParameterName}"); | ||
}); | ||
} | ||
} | ||
|
||
public class When_testing_if_a_parameter_is_common_for_all_species : concern_for_ContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
[Observation] | ||
public void age_parameter_should_be_defined_not_for_all_species() | ||
{ | ||
sut.UsedForAllSpecies("Organism","Age").ShouldBeFalse(); | ||
} | ||
|
||
[Observation] | ||
public void weight_parameter_should_be_defined_for_all_species() | ||
{ | ||
sut.UsedForAllSpecies("Organism", "Weight").ShouldBeTrue(); | ||
} | ||
|
||
[Observation] | ||
public void age_parameter_should_be_defined_not_for_all_species_when_queried_by_full_path() | ||
{ | ||
sut.UsedForAllSpecies("Organism|Age").ShouldBeFalse(); | ||
} | ||
|
||
[Observation] | ||
public void weight_parameter_should_be_defined_for_all_species_when_queried_by_full_path() | ||
{ | ||
sut.UsedForAllSpecies("Organism|Weight").ShouldBeTrue(); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...im.Tests/IntegrationTests/FlatContainerParametersNotCommonForAllSpeciesRepositorySpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OSPSuite.BDDHelper; | ||
using OSPSuite.BDDHelper.Extensions; | ||
using PKSim.Infrastructure.ORM.FlatObjects; | ||
using PKSim.Infrastructure.ORM.Repositories; | ||
|
||
namespace PKSim.IntegrationTests | ||
{ | ||
public abstract class concern_for_FlatContainerParametersNotCommonForAllSpeciesRepository : ContextForIntegration<IFlatContainerParametersNotCommonForAllSpeciesRepository> | ||
{ | ||
} | ||
|
||
public class When_resolving_all_parameters_not_common_for_all_species_as_a_flat_table : concern_for_FlatContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private IEnumerable<FlatContainerParametersNotCommonForAllSpecies> _result; | ||
|
||
protected override void Because() | ||
{ | ||
_result = sut.All(); | ||
} | ||
|
||
[Observation] | ||
public void should_retrieve_some_object_from_the_underlying_database() | ||
{ | ||
_result.Count().ShouldBeGreaterThan(0); | ||
} | ||
} | ||
} |