Skip to content

Commit 82ca334

Browse files
committed
Only default to Global for the global MoleculeProperties container
Addresses review feedback: new parameters in local MoleculeProperties containers must stay Local. Only the global MoleculeProperties container, a special member of the SpatialStructure (marked ContainerType.Molecule), should default to Global. Introduce IsGlobalMoleculeProperties() to make that distinction and use it in DefaultParameterBuildMode.
1 parent abec76f commit 82ca334

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/MoBi.Core/Domain/Extensions/ContainerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ParameterBuildMode DefaultParameterBuildMode(this IContainer conta
2626
var needsGlobalParameter = container.IsAnImplementationOf<TransporterMoleculeContainer>() ||
2727
container.IsAnImplementationOf<ReactionBuilder>() ||
2828
container.IsAnImplementationOf<InteractionContainer>() ||
29-
container.IsMoleculeProperties();
29+
container.IsGlobalMoleculeProperties();
3030

3131
return needsGlobalParameter ? ParameterBuildMode.Global : ParameterBuildMode.Local;
3232
}

src/MoBi.Core/Domain/Extensions/EntityExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ public static bool IsMoleculeProperties(this IContainer container)
1616
return container.IsNamed(Constants.MOLECULE_PROPERTIES);
1717
}
1818

19+
/// <summary>
20+
/// Returns <c>true</c> for the global <c>MoleculeProperties</c> container that is a special member of a
21+
/// <see cref="OSPSuite.Core.Domain.Builder.SpatialStructure" /> (created with <see cref="ContainerType.Molecule" />),
22+
/// as opposed to the local <c>MoleculeProperties</c> containers nested in physical containers.
23+
/// </summary>
24+
public static bool IsGlobalMoleculeProperties(this IContainer container)
25+
{
26+
return container.IsMoleculeProperties() && container.ContainerType == ContainerType.Molecule;
27+
}
28+
1929
public static bool IsAtMoleculeBuilder(this IEntity entity)
2030
{
2131
return entity.RootContainer.IsAnImplementationOf<MoleculeBuilder>();

tests/MoBi.Tests/Core/Commands/AddParameterToContainerCommandSpecs.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ protected override ParameterBuildMode GetBuildModeType()
7575
}
7676
}
7777

78-
public class When_adding_a_new_parameter_to_molecule_properties_container : When_testing_for_appropriate_parameter_build_modes
78+
public class When_adding_a_new_parameter_to_the_global_molecule_properties_container : When_testing_for_appropriate_parameter_build_modes
7979
{
8080
protected override IContainer GetContainer()
8181
{
82-
return new Container().WithName(Constants.MOLECULE_PROPERTIES);
82+
return new Container().WithName(Constants.MOLECULE_PROPERTIES).WithContainerType(ContainerType.Molecule);
8383
}
8484

8585
protected override ParameterBuildMode GetBuildModeType()
@@ -88,6 +88,19 @@ protected override ParameterBuildMode GetBuildModeType()
8888
}
8989
}
9090

91+
public class When_adding_a_new_parameter_to_a_local_molecule_properties_container : When_testing_for_appropriate_parameter_build_modes
92+
{
93+
protected override IContainer GetContainer()
94+
{
95+
return new Container().WithName(Constants.MOLECULE_PROPERTIES).WithContainerType(ContainerType.Compartment);
96+
}
97+
98+
protected override ParameterBuildMode GetBuildModeType()
99+
{
100+
return ParameterBuildMode.Local;
101+
}
102+
}
103+
91104
public class When_adding_a_new_parameter_to_a_generic_container : When_testing_for_appropriate_parameter_build_modes
92105
{
93106
protected override IContainer GetContainer()

0 commit comments

Comments
 (0)