Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/OSPSuite.Assets/UIConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,12 @@ public static string UpdatedMappingsMessage(IEnumerable<(string ParameterName, s
{
sb.AppendLine($" - Output Path: {mapping.OutputPath}");
}

sb.AppendLine();
}

return sb.ToString();
}

}

public static class Diff
Expand Down Expand Up @@ -1065,12 +1065,9 @@ public static string ParameterIdentificationFinished(string parameterIdentificat
return $"Parameter identification '{parameterIdentificationName}' finished in {duration}";
}


public static string SensitivityCalculationFailed(string parameterIdentificationName, IReadOnlyList<string> errorMessages, string duration = null)
{
return string.IsNullOrEmpty(duration) ?
$"Parameter identification '{parameterIdentificationName}' finished but sensitivity calculation failed.\n\n {string.Join("\n\n", errorMessages)}" :
$"Parameter identification '{parameterIdentificationName}' finished in {duration} but sensitivity calculation failed.\n\n {string.Join("\n\n", errorMessages)}";
return string.IsNullOrEmpty(duration) ? $"Parameter identification '{parameterIdentificationName}' finished but sensitivity calculation failed.\n\n {string.Join("\n\n", errorMessages)}" : $"Parameter identification '{parameterIdentificationName}' finished in {duration} but sensitivity calculation failed.\n\n {string.Join("\n\n", errorMessages)}";
}

public static string LinkedParametersIn(string name)
Expand Down Expand Up @@ -1316,7 +1313,7 @@ public static string SensitivityAnalysisErrorMessage(IReadOnlyList<string> error
stringBuilder.AppendLine();
stringBuilder.AppendLine();
});

return stringBuilder.ToString();
}
}
Expand Down Expand Up @@ -1407,7 +1404,7 @@ public static class GroupRowFormat
public static string Time = "Time";
public static string Observation = "Observation";
public static string DeviationLine = "Deviation Lines";
public static string Undefined = "Undefined";
public static string Undefined = "Undefined";
}

public static class DeviationLines
Expand All @@ -1416,7 +1413,6 @@ public static class DeviationLines
public static string DeviationLineDescription = "Will create two deviation lines according to the given fold value which has to be greater than 1 (foldValue >1). An x-fold deviation range includes simulated values within x-fold and 1/x-fold of observed values.";
public static string DeviationLineNameUpper(float foldValue) => $"{foldValue}-fold deviation";
public static string DeviationLineNameLower(float foldValue) => $"{foldValue}-fold deviation Lower";

}
}

Expand All @@ -1425,9 +1421,9 @@ public static class DeviationLines
private static string projectNameAndVersionAsString(string versionDisplay, int version) => $"V{versionDisplay} {numberDisplay(version)}";

public static string ProjectVersionCannotBeLoaded(
int projectVersion,
string oldestSupportedDisplayVersion,
int oldestSupportedVersion,
int projectVersion,
string oldestSupportedDisplayVersion,
int oldestSupportedVersion,
string currentSupportedDisplayVersion,
int currentSupportedVersion,
string downloadUrl)
Expand All @@ -1451,12 +1447,12 @@ public static string ProjectVersionCannotBeLoaded(
public static string LoadObjectFromSnapshot(string objectType) => $"Load {objectType.ToLowerInvariant()} from snapshot";
public static string SelectSnapshotExportFile(string objectName, string objectType) => $"Export snapshot for {objectType.ToLowerInvariant()} '{objectName}'";
public static string DoYouWantToProceed(params string[] messages) => $"WARNING:\n{messages.ToString("\n")}\n\nDo you wish to continue?";

public static readonly string SnapshotOfProjectWithChangedSimulationText = "Some simulations are in a changed state (red icon) and may not be re-imported correctly.";
public static readonly string SnapshotOfProjectWithChangedSimulation = DoYouWantToProceed(SnapshotOfProjectWithChangedSimulationText);

public static string Starting(string type, string name) => $"Starting {type.ToLower()} '{name}'...";

public static string LoadingSnapshot(string snapshotFile, string type) => $"Loading {type} from {ObjectTypes.Snapshot.ToLower()} file '{snapshotFile}'";

public static string SnapshotLoaded(string typeToLoad) => $"{typeToLoad} loaded from {ObjectTypes.Snapshot.ToLower()}";
Expand All @@ -1466,7 +1462,6 @@ public static string ProjectVersionCannotBeLoaded(
public static string StartingQualificationPlan(string qualificationPlan) => Starting(ObjectTypes.QualificationPlan, qualificationPlan);

public static string StartingQualificationStep(string qualificationStep) => Starting(ObjectTypes.QualificationStep, qualificationStep);

}

public static class Error
Expand Down Expand Up @@ -1511,13 +1506,13 @@ public static string CannotFindSimulationParameterInSnapshot(string parameterPat

public static string SnapshotDuplicateEntryByName(string name, string type) =>
$"Another {type} named '{name}' already exists in the project. Snapshot file is corrupted.";

public static string SnapshotFileMismatch(string desiredType) => $"Snapshot file cannot be used to load a {desiredType.ToLowerInvariant()}.";

public static string CannotFindParentContainerWithPath(string parentPath, string containerName, string buildingBlockName, string moduleName) =>
public static string CannotFindParentContainerWithPath(string parentPath, string containerName, string buildingBlockName, string moduleName) =>
$"Cannot find parent container '{parentPath}' defined as target of container '{containerName}' in building block '{buildingBlockName}' in module '{moduleName}'";

public static string NoUnitColumnValues(string mappingName) => $"No values for the unit were found in the excel column mapped for '{mappingName}' \n";
public static string NoUnitColumnValues(string mappingName) => $"No values for the unit were found in the excel column mapped for '{mappingName}' \n";

public static string ParseErrorMessage(string errors) => $"There were errors while parsing your data: {errors}";

Expand Down Expand Up @@ -1596,7 +1591,7 @@ public static string NameAlreadyExists(string name)

public static string NameAlreadyExistsInContainerType(string name, string containerType)
{
if(string.IsNullOrEmpty(containerType))
if (string.IsNullOrEmpty(containerType))
return NameAlreadyExists(name);

return $"'{name}' already exists in {containerType}.";
Expand Down Expand Up @@ -1738,6 +1733,7 @@ public static string MoleculeNameExistsInAnotherList(string moleculeName)
{
return $"Cannot add molecule '{moleculeName}' into both molecules to include and molecules to exclude lists";
}

public static string BuildingBlockTypeAlreadyAddedToModule(string objectName, string type) => $"BuildingBlock '{type}' for '{objectName}' was already added to module";

public const string NotImplemented = "This feature is not implemented yet";
Expand Down Expand Up @@ -1888,11 +1884,11 @@ public static string TimeArrayValuesDoesNotMatchFirstIndividual(int id, int inde

public static string UnitIsNotDefinedInDimension(string unit, string dimension) => $"Unit '{unit}' is not defined in dimension '{dimension}'.";

public static string CouldNotFindNeighborhoodBetween(string container1, string container2, string formulaName, string usingFormulaPath) =>
public static string CouldNotFindNeighborhoodBetween(string container1, string container2, string formulaName, string usingFormulaPath) =>
$"Could not find neighborhood between '{container1}' and '{container2}' referenced by formula '{formulaName}' used by '{usingFormulaPath}'";

public static string FirstNeighborNotDefinedFor(string neighborhoodName) => $"First neighbor is undefined for neighborhood '{neighborhoodName}'";

public static string SecondNeighborNotDefinedFor(string neighborhoodName) => $"Second neighbor is undefined for neighborhood '{neighborhoodName}'";

public const string InParentTagCanOnlyBeUsedWithAndOperator = "IN PARENT tag can only be used with AND operator";
Expand Down Expand Up @@ -1920,6 +1916,7 @@ public static string CouldNotFindNeighborhoodBetween(string container1, string c
public static string SimulationUsedInPlotsAreNotExported(IReadOnlyList<string> simulationNames, string project)
=> $"{ObjectTypes.Simulation.PluralizeIf(simulationNames)} {simulationNames.ToString(", ", "'")} used in plots {"is".PluralizeIf(simulationNames)} not found in the list of exported simulations for {ObjectTypes.Project} {project}";

public static string NeighborIsLogical(string neighborName, string neighborhoodName) => $"Container {neighborName} is defined as logical for neighborhood '{neighborhoodName}'";

public static class SensitivityAnalysis
{
Expand Down Expand Up @@ -1997,6 +1994,7 @@ private static string listErrorMessages(IReadOnlyList<string> runResultErrorMess
{
sb.AppendLine($"- {errorMessage}");
}

return sb.ToString();
}

Expand Down Expand Up @@ -2223,13 +2221,12 @@ public static class Warning
public static string LargeNumberOfOutputPoints(int numberOfPoints) =>
$"The selected output resolution will generate {numberOfPoints} points and may severely impact the software performance.\nAre you sure you want to run with these setting? If not, consider changing output resolution in simulations settings";

public static string NeighborhoodWasNotFoundInModel(string neighborhoodName, string buildingBlockName) => $"The neighborhood '{neighborhoodName}' from building block '{buildingBlockName}' was not added to the simulation";
public static string NeighborhoodWasNotFoundInModel(string neighborhoodName, string buildingBlockName) => $"The neighborhood '{neighborhoodName}' from building block '{buildingBlockName}' was not added to the simulation because it is not defined or at least one of the containers is logical";

public static string UnitNotFoundInDimensionForParameter(string unit, string dimension, string parameterName)
{
return $"Unit '{unit}' not found for parameter {parameterName} with dimension '{dimension}'";
}

}

public static class RibbonCategories
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OSPSuite.Core.Domain.Builder;
Expand Down Expand Up @@ -40,7 +39,7 @@ public NeighborhoodBuilderToNeighborhoodMapper(
IObjectBaseFactory objectBaseFactory,
IContainerBuilderToContainerMapper containerMapper,
IKeywordReplacerTask keywordReplacerTask,
ICloneManagerForModel cloneManagerForModel,
ICloneManagerForModel cloneManagerForModel,
IParameterBuilderToParameterMapper parameterMapper, IEntityTracker entityTracker)
{
_objectBaseFactory = objectBaseFactory;
Expand All @@ -63,8 +62,8 @@ public Neighborhood MapFrom(NeighborhoodBuilder neighborhoodBuilder, IReadOnlyLi
neighborhood.FirstNeighbor = resolveReference(model, neighborhoodBuilder.FirstNeighborPath, replacementContext);
neighborhood.SecondNeighbor = resolveReference(model, neighborhoodBuilder.SecondNeighborPath, replacementContext);

//At least one neighbor cannot be found. We are ignoring this neighborhood
if (!neighborhood.IsDefined)
//At least one neighbor cannot be found or is a logical container. We are ignoring this neighborhood
if (!neighborhood.IsDefined || !neighborhood.HasOnlyPhysicalNeighbors)
return null;

if (neighborhoodBuilder.MoleculeProperties != null)
Expand Down
2 changes: 2 additions & 0 deletions src/OSPSuite.Core/Domain/Neighborhood.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ public override void UpdatePropertiesFrom(IUpdatable source, ICloneManager clone
}

public bool IsDefined => FirstNeighbor != null && SecondNeighbor != null;

public bool HasOnlyPhysicalNeighbors => IsDefined && FirstNeighbor.Mode == ContainerMode.Physical && SecondNeighbor.Mode == ContainerMode.Physical;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ private void validateNeighborhood(Neighborhood neighborhood, IContainer root)
if (neighborhood.FirstNeighbor == null)
_result.AddMessage(NotificationType.Error, neighborhood, Error.FirstNeighborNotDefinedFor(neighborhood.Name));


if (neighborhood.SecondNeighbor == null)
_result.AddMessage(NotificationType.Error, neighborhood, Error.SecondNeighborNotDefinedFor(neighborhood.Name));

if (neighborhood.FirstNeighbor?.Mode == ContainerMode.Logical)
_result.AddMessage(NotificationType.Warning, neighborhood, Error.NeighborIsLogical(neighborhood.FirstNeighbor.Name, neighborhood.Name));

if (neighborhood.SecondNeighbor?.Mode == ContainerMode.Logical)
_result.AddMessage(NotificationType.Warning, neighborhood, Error.NeighborIsLogical(neighborhood.SecondNeighbor.Name, neighborhood.Name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,11 @@ protected override void Context()
var initialCondition = simulationBuilder.InitialConditions.First();
var physicalContainer = simulationBuilder.SpatialStructureAndMergeBehaviors.SelectMany(x => x.spatialStructure.TopContainers)
.Select(x => initialCondition.ContainerPath.TryResolve<IContainer>(x)).First(x => x != null);

physicalContainer.Mode = ContainerMode.Logical;

simulationBuilder.SpatialStructureAndMergeBehaviors.FirstOrDefault().spatialStructure.FormulaCache.Clear();
var containerWithFormula = physicalContainer.Children.FirstOrDefault(x => x.Name == "RefParam") as Parameter;
physicalContainer.RemoveChild(containerWithFormula);
}

[Observation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ internal class When_running_the_case_study_for_module_integration : concern_for_
public void should_return_a_successful_validation_with_warning()
{
_result.ValidationResult.ValidationState.ShouldBeEqualTo(ValidationState.ValidWithWarnings, _result.ValidationResult.Messages.Select(m => m.Text).ToString("\n"));
_result.ValidationResult.Messages.Single().Text.ShouldBeEqualTo(Warning.NeighborhoodWasNotFoundInModel("does_not_match_existing", "Module1 - SPATIAL STRUCTURE MODULE 1"));
_result.ValidationResult.Messages.FirstOrDefault(x => x.Text.Equals(Warning.NeighborhoodWasNotFoundInModel("does_not_match_existing", "Module1 - SPATIAL STRUCTURE MODULE 1"))).ShouldNotBeNull();
_result.ValidationResult.Messages.FirstOrDefault(x => x.Text.Equals(Warning.NeighborhoodWasNotFoundInModel("not_physical", "Module1 - SPATIAL STRUCTURE MODULE 1"))).ShouldNotBeNull();
}

[Observation]
Expand Down
5 changes: 5 additions & 0 deletions tests/OSPSuite.HelpersForTests/ModuleHelperForSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ private SpatialStructure getSpatialStructureModule1()

//ART
var art = createContainerWithName(ArterialBlood);
var logicalContainer = createContainerWithName(Plasma, ContainerMode.Logical);

var artPlasma = createContainerWithName(Plasma, ContainerMode.Physical);
artPlasma.AddTag(new Tag(ArterialBlood));
Expand Down Expand Up @@ -381,6 +382,10 @@ private SpatialStructure getSpatialStructureModule1()
neighborhood7.FirstNeighborPath = new ObjectPath("Organism", "NOPE");
spatialStructure.AddNeighborhood(neighborhood7);

var neighborhood8 = _neighborhoodFactory.CreateBetween(bonePlasma, logicalContainer).WithName("not_physical");
neighborhood8.FirstNeighborPath = new ObjectPath("Organism", "NOPE");
spatialStructure.AddNeighborhood(neighborhood8);

spatialStructure.ResolveReferencesInNeighborhoods();
return spatialStructure;
}
Expand Down
Loading