Skip to content

Commit

Permalink
Merge pull request #2230 from Open-Systems-Pharmacology/hotfix/11.3
Browse files Browse the repository at this point in the history
Hotfix/11.3
  • Loading branch information
Yuri05 authored Apr 10, 2024
2 parents 69e1dfd + d742a99 commit 67950bb
Show file tree
Hide file tree
Showing 34 changed files with 204 additions and 851 deletions.
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ image: Visual Studio 2019
version: '{build}'

init:
- ps: Update-AppveyorBuild -Version "$($env:ospsuite_version).$($env:appveyor_build_version)"
- ps: Update-AppveyorBuild -Version "$($env:ospsuite_nightly_version).$($env:appveyor_build_version)"

dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '$(ospsuite_version).$(build_number)'
assembly_version: '$(ospsuite_version).$(build_number)'
file_version: '$(ospsuite_version).$(build_number)'
informational_version: '$(ospsuite_version).$(build_number)'
version: '$(ospsuite_nightly_version).$(build_number)'
assembly_version: '$(ospsuite_nightly_version).$(build_number)'
file_version: '$(ospsuite_nightly_version).$(build_number)'
informational_version: '$(ospsuite_nightly_version).$(build_number)'

before_build:
- nuget sources add -name bddhelper -source https://ci.appveyor.com/nuget/ospsuite-bddhelper
Expand Down Expand Up @@ -49,7 +49,7 @@ skip_commits:

branches:
only:
- develop
- hotfix/11.3

test:
assemblies:
Expand Down
1 change: 1 addition & 0 deletions src/OSPSuite.Assets/UIConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public static class Captions
public static readonly string Yes = "Yes";
public static readonly string ReallyRemoveObservedDataFromSimulation = $"Really remove {ObjectTypes.ObservedData} from the simulation?\nHint: {ObjectTypes.ObservedData} will not be deleted from the project";
public static readonly string SimulationWasCanceled = "Simulation was canceled";
public static readonly string SelectMappingToShowObservedData = "Select mapping to show observed data";

public static string ShouldWatermarkBeUsedForChartExportToClipboard(string applicationName, string optionLocation)
{
Expand Down
2 changes: 1 addition & 1 deletion src/OSPSuite.Core/Domain/IProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OSPSuite.Core.Domain
{
public interface IProject : IObjectBase, IWithChartTemplates, IWithCreationMetaData
public interface IProject : IObjectBase, IWithChartTemplates, IWithCreationMetaData, IWithHasChanged
{
/// <summary>
/// Full path of project (empty if the project was not saved yet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OSPSuite.Core.Domain.ParameterIdentifications
{
public class ParameterIdentification : ObjectBase, IParameterAnalysable, IUsesObservedData
public class ParameterIdentification : ObjectBase, IParameterAnalysable, IUsesObservedData, IWithHasChanged
{
private readonly List<ISimulation> _allSimulations = new List<ISimulation>();
private readonly List<IdentificationParameter> _allIdentificationParameters = new List<IdentificationParameter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OSPSuite.Core.Domain.SensitivityAnalyses
{
public class SensitivityAnalysis : ObjectBase, IParameterAnalysable, IVisitor
public class SensitivityAnalysis : ObjectBase, IParameterAnalysable, IVisitor, IWithHasChanged
{
public virtual ISimulation Simulation { get; set; }
private readonly List<ISimulationAnalysis> _allSimulationAnalyses = new List<ISimulationAnalysis>();
Expand Down
11 changes: 6 additions & 5 deletions src/OSPSuite.Core/Domain/Services/CloneManagerStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ public virtual T Clone<T>(T objectToClone) where T : class, IUpdatable
if (objectToClone == null)
return null;

var repository = objectToClone as DataRepository;
if (repository != null)
if (objectToClone is DataRepository repository)
{
return cloneDataRepository(objectToClone.DowncastTo<DataRepository>()) as T;
return cloneDataRepository(repository) as T;
}

var formulaToClone = objectToClone as IFormula;
if (formulaToClone != null)
if (objectToClone is IFormula formulaToClone)
return CreateFormulaCloneFor(formulaToClone).DowncastTo<T>();

var clone = _objectBaseFactory.CreateObjectBaseFrom(objectToClone);
Expand All @@ -41,6 +39,9 @@ public virtual T Clone<T>(T objectToClone) where T : class, IUpdatable
//it is necessary to update the formula before the properties, since UpdatePropertiesFrom might use formula
clone.UpdatePropertiesFrom(objectToClone, this);

if (clone is IWithHasChanged withHasChanged)
withHasChanged.HasChanged = true;

return clone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public interface ISimpleChartPresenter : IPresenter<ISimpleChartView>
/// Refresh the display after external changes were made to the chart
/// </summary>
void Refresh();

void Clear();
}

public class SimpleChartPresenter : AbstractCommandCollectorPresenter<ISimpleChartView, ISimpleChartPresenter>, ISimpleChartPresenter
Expand All @@ -93,6 +95,8 @@ public SimpleChartPresenter(ISimpleChartView view, IChartDisplayPresenter chartD
AddSubPresenters(_chartDisplayPresenter);
}

public void Clear() => _chartDisplayPresenter.Clear();

public Action<int> HotTracked
{
set => _chartDisplayPresenter.HotTracked = value;
Expand Down Expand Up @@ -136,15 +140,12 @@ private void bindToChart()
public CurveChart Plot(DataRepository dataRepository, Scalings scale)
{
Chart = _chartFactory.CreateChartFor(dataRepository, scale);
setChartScalingForObservedData(new[] {dataRepository});
setChartScalingForObservedData(new[] { dataRepository });
bindToChart();
return Chart;
}

public CurveChart Plot(DataRepository dataRepository)
{
return Plot(dataRepository, _presentationUserSettings.DefaultChartYScaling);
}
public CurveChart Plot(DataRepository dataRepository) => Plot(dataRepository, _presentationUserSettings.DefaultChartYScaling);

public CurveChart PlotObservedData(IEnumerable<DataRepository> observedData)
{
Expand All @@ -165,20 +166,11 @@ private void setChartScalingForObservedData(IReadOnlyList<DataRepository> observ
Chart.DefaultYAxisScaling = Scalings.Linear;
}

private bool shouldUseLinearScaling(IReadOnlyList<DataRepository> observedData)
{
return observedData.Any(dataRepositoryHasFraction);
}
private bool shouldUseLinearScaling(IReadOnlyList<DataRepository> observedData) => observedData.Any(dataRepositoryHasFraction);

private bool dataRepositoryHasFraction(DataRepository dataRepository)
{
return dataRepository.AllButBaseGrid().Any(x => x.IsFraction());
}
private bool dataRepositoryHasFraction(DataRepository dataRepository) => dataRepository.AllButBaseGrid().Any(x => x.IsFraction());

public CurveChart PlotObservedData(DataRepository observedData)
{
return PlotObservedData(new[] {observedData}).WithName(observedData.Name);
}
public CurveChart PlotObservedData(DataRepository observedData) => PlotObservedData(new[] { observedData }).WithName(observedData.Name);

private void setScaleInView(CurveChart chart)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using OSPSuite.Utility.Events;
using OSPSuite.Core.Domain;
using OSPSuite.Core.Domain.ParameterIdentifications;
using OSPSuite.Core.Events;
using OSPSuite.Presentation.Views.ParameterIdentifications;
using OSPSuite.Utility.Events;

namespace OSPSuite.Presentation.Presenters.ParameterIdentifications
{
public interface IParameterIdentificationDataSelectionPresenter : IParameterIdentificationItemPresenter,
IListener<ObservedDataAddedToAnalysableEvent>,
IListener<ObservedDataRemovedFromAnalysableEvent>,
IListener<RenamedEvent>,
IListener<SimulationRemovedEvent>,
IListener<ObservedDataAddedToAnalysableEvent>,
IListener<ObservedDataRemovedFromAnalysableEvent>,
IListener<RenamedEvent>,
IListener<SimulationRemovedEvent>,
IListener<SimulationReplacedInParameterAnalyzableEvent>
{
event EventHandler<SimulationEventArgs> SimulationAdded;
Expand All @@ -22,23 +22,23 @@ public class ParameterIdentificationDataSelectionPresenter : AbstractSubPresente
{
private readonly IParameterIdentificationSimulationSelectionPresenter _simulationSelectionPresenter;
private readonly IParameterIdentificationOutputMappingPresenter _outputMappingPresenter;
private readonly IParameterIdentificationWeightedObservedDataCollectorPresenter _weightedObservedDataCollectorPresenter;
private readonly IParameterIdentificationWeightedObservedDataPresenter _weightedObservedDataPresenter;
private ParameterIdentification _parameterIdentification;
public event EventHandler<SimulationEventArgs> SimulationAdded = delegate { };
public event EventHandler<SimulationEventArgs> SimulationRemoved = delegate { };

public ParameterIdentificationDataSelectionPresenter(IParameterIdentificationDataSelectionView view,
IParameterIdentificationSimulationSelectionPresenter simulationSelectionPresenter,
IParameterIdentificationOutputMappingPresenter outputMappingPresenter,
IParameterIdentificationWeightedObservedDataCollectorPresenter weightedObservedDataCollectorPresenter) : base(view)
IParameterIdentificationWeightedObservedDataPresenter weightedObservedDataPresenter) : base(view)
{
_simulationSelectionPresenter = simulationSelectionPresenter;
_outputMappingPresenter = outputMappingPresenter;
_weightedObservedDataCollectorPresenter = weightedObservedDataCollectorPresenter;
_weightedObservedDataPresenter = weightedObservedDataPresenter;
view.AddSimulationSelectionView(_simulationSelectionPresenter.BaseView);
view.AddOutputMappingView(_outputMappingPresenter.BaseView);
view.AddWeightedObservedDataCollectorView(_weightedObservedDataCollectorPresenter.BaseView);
AddSubPresenters(_simulationSelectionPresenter, _outputMappingPresenter, _weightedObservedDataCollectorPresenter);
view.AddWeightedObservedDataCollectorView(_weightedObservedDataPresenter.BaseView);
AddSubPresenters(_simulationSelectionPresenter, _outputMappingPresenter, _weightedObservedDataPresenter);

_simulationSelectionPresenter.SimulationAdded += (o, e) => simulationAdded(e);
_simulationSelectionPresenter.SimulationRemoved += (o, e) => simulationRemoved(e);
Expand All @@ -48,20 +48,11 @@ public ParameterIdentificationDataSelectionPresenter(IParameterIdentificationDat
_outputMappingPresenter.ObservedDataSelected += (o, e) => observedDataSelected(e.WeightedObservedData);
}

private void observedDataUnmapped(WeightedObservedData weightedObservedData)
{
_weightedObservedDataCollectorPresenter.RemoveObservedData(weightedObservedData);
}
private void observedDataUnmapped(WeightedObservedData weightedObservedData) => _weightedObservedDataPresenter.Clear(weightedObservedData);

private void observedDataSelected(WeightedObservedData weightedObservedData)
{
_weightedObservedDataCollectorPresenter.SelectObservedData(weightedObservedData);
}
private void observedDataSelected(WeightedObservedData weightedObservedData) => _weightedObservedDataPresenter.Edit(weightedObservedData);

private void observedDataMapped(WeightedObservedData weightedObservedData)
{
_weightedObservedDataCollectorPresenter.AddObservedData(weightedObservedData);
}
private void observedDataMapped(WeightedObservedData weightedObservedData) => _weightedObservedDataPresenter.Edit(weightedObservedData);

private void simulationAdded(SimulationEventArgs e)
{
Expand All @@ -72,7 +63,6 @@ private void simulationAdded(SimulationEventArgs e)
private void updateOutputAndWeightsPresenters()
{
_outputMappingPresenter.Refresh();
_weightedObservedDataCollectorPresenter.Refresh();
ViewChanged();
}

Expand All @@ -87,7 +77,6 @@ public void EditParameterIdentification(ParameterIdentification parameterIdentif
_parameterIdentification = parameterIdentification;
_simulationSelectionPresenter.EditParameterIdentification(_parameterIdentification);
_outputMappingPresenter.EditParameterIdentification(_parameterIdentification);
_weightedObservedDataCollectorPresenter.EditParameterIdentification(_parameterIdentification);
}

public void Handle(ObservedDataAddedToAnalysableEvent eventToHandle)
Expand All @@ -104,10 +93,7 @@ private bool canHandle(AnalysableEvent analysableEvent)
return identificationUsesSimulation(analysableEvent.Analysable as ISimulation);
}

private bool identificationUsesSimulation(ISimulation simulation)
{
return _parameterIdentification.UsesSimulation(simulation);
}
private bool identificationUsesSimulation(ISimulation simulation) => _parameterIdentification.UsesSimulation(simulation);

public void Handle(ObservedDataRemovedFromAnalysableEvent eventToHandle)
{
Expand All @@ -124,21 +110,14 @@ public void Handle(RenamedEvent eventToHandle)
_outputMappingPresenter.Refresh();
}

private bool canHandle(RenamedEvent eventToHandle)
{
return identificationUsesSimulation(eventToHandle.RenamedObject as ISimulation);
}
private bool canHandle(RenamedEvent eventToHandle) => identificationUsesSimulation(eventToHandle.RenamedObject as ISimulation);

public void Handle(SimulationRemovedEvent eventToHandle)
{
refreshSubPresenters();
}
public void Handle(SimulationRemovedEvent eventToHandle) => refreshSubPresenters();

private void refreshSubPresenters()
{
_simulationSelectionPresenter.Refresh();
_outputMappingPresenter.Refresh();
_weightedObservedDataCollectorPresenter.Refresh();
}

public void Handle(SimulationReplacedInParameterAnalyzableEvent eventToHandle)
Expand All @@ -147,9 +126,6 @@ public void Handle(SimulationReplacedInParameterAnalyzableEvent eventToHandle)
refreshSubPresenters();
}

private bool canHandle(SimulationReplacedInParameterAnalyzableEvent eventToHandle)
{
return Equals(eventToHandle.ParameterAnalysable, _parameterIdentification);
}
private bool canHandle(SimulationReplacedInParameterAnalyzableEvent eventToHandle) => Equals(eventToHandle.ParameterAnalysable, _parameterIdentification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,12 @@ public void Refresh()
this.DoWithinLatch(() =>
{
UpdateCache();
updateOutputMapppingList();
_view.BindTo(_allOutputMappingDTOs);
updateOutputMappingList();
});
_view.BindTo(_allOutputMappingDTOs);
}

public void UpdateCache()
{
_allAvailableOutputs.Clear();
}
public void UpdateCache() => _allAvailableOutputs.Clear();

public void AddOutputMapping()
{
Expand All @@ -114,7 +111,7 @@ public void AddOutputMapping()
OnStatusChanged();
}

private void updateOutputMapppingList()
private void updateOutputMappingList()
{
_allOutputMappingDTOs.Clear();
_parameterIdentification.AllOutputMappings.Each(x => _allOutputMappingDTOs.Add(mapFrom(x)));
Expand All @@ -137,20 +134,11 @@ public IEnumerable<SimulationQuantitySelectionDTO> AllAvailableOutputs
}
}

private SimulationQuantitySelectionDTO mapFrom(ISimulation simulation, IQuantity quantity)
{
return _simulationQuantitySelectionDTOMapper.MapFrom(simulation, quantity);
}
private SimulationQuantitySelectionDTO mapFrom(ISimulation simulation, IQuantity quantity) => _simulationQuantitySelectionDTOMapper.MapFrom(simulation, quantity);

private OutputMappingDTO mapFrom(OutputMapping outputMapping)
{
return _outputMappingDTOMapper.MapFrom(outputMapping, AllAvailableOutputs);
}
private OutputMappingDTO mapFrom(OutputMapping outputMapping) => _outputMappingDTOMapper.MapFrom(outputMapping, AllAvailableOutputs);

public IEnumerable<DataRepository> AllObservedDataFor(OutputMappingDTO outputMappingDTO)
{
return allPossibleObservedDataForOutput(outputMappingDTO.Output);
}
public IEnumerable<DataRepository> AllObservedDataFor(OutputMappingDTO outputMappingDTO) => allPossibleObservedDataForOutput(outputMappingDTO.Output);

private IEnumerable<DataRepository> allPossibleObservedDataForOutput(SimulationQuantitySelectionDTO outputSelectionDTO)
{
Expand All @@ -165,7 +153,7 @@ private IEnumerable<DataRepository> allPossibleObservedDataForOutput(SimulationQ

public void ObservedDataSelectionChanged(OutputMappingDTO dto, DataRepository newObservedData, DataRepository oldObservedData)
{
var allOutputsUsingObservedData = _allOutputMappingDTOs.Where(x => Equals(x.ObservedData, newObservedData)).Except(new[] {dto}).ToList();
var allOutputsUsingObservedData = _allOutputMappingDTOs.Where(x => Equals(x.ObservedData, newObservedData)).Except(new[] { dto }).ToList();

if (observedDataAlreadySelectedForSameOutput(dto.Output, newObservedData))
{
Expand Down Expand Up @@ -197,10 +185,7 @@ public void ObservedDataSelectionChanged(OutputMappingDTO dto, DataRepository ne
return allIds.Max() + 1;
}

private bool observedDataAlreadySelectedForSameOutput(SimulationQuantitySelectionDTO outputDTO, DataRepository observedData)
{
return _allOutputMappingDTOs.Count(x => Equals(x.Output, outputDTO) && Equals(x.ObservedData, observedData)) > 1;
}
private bool observedDataAlreadySelectedForSameOutput(SimulationQuantitySelectionDTO outputDTO, DataRepository observedData) => _allOutputMappingDTOs.Count(x => Equals(x.Output, outputDTO) && Equals(x.ObservedData, observedData)) > 1;

public void OutputSelectionChanged(OutputMappingDTO dto, SimulationQuantitySelectionDTO newOutput, SimulationQuantitySelectionDTO oldOutput)
{
Expand All @@ -214,10 +199,7 @@ public void OutputSelectionChanged(OutputMappingDTO dto, SimulationQuantitySelec
dto.Scaling = _parameterIdentificationTask.DefaultScalingFor(newOutput.Quantity);
}

public void Select(OutputMappingDTO outputMappingDTO)
{
this.DoWithinLatch(() => ObservedDataSelected(this, new ObservedDataEventArgs(outputMappingDTO.WeightedObservedData)));
}
public void Select(OutputMappingDTO outputMappingDTO) => this.DoWithinLatch(() => ObservedDataSelected(this, new ObservedDataEventArgs(outputMappingDTO.WeightedObservedData)));

public void RemoveOutputMapping(OutputMappingDTO outputMappingDTO)
{
Expand All @@ -234,9 +216,6 @@ private void raiseObservedDataUnmappedFor(WeightedObservedData weightedObservedD
ObservedDataUnmapped(this, new ObservedDataEventArgs(weightedObservedData));
}

private void raiseObservedDataMappedFor(WeightedObservedData weightedObservedData)
{
ObservedDataMapped(this, new ObservedDataEventArgs(weightedObservedData));
}
private void raiseObservedDataMappedFor(WeightedObservedData weightedObservedData) => ObservedDataMapped(this, new ObservedDataEventArgs(weightedObservedData));
}
}
Loading

0 comments on commit 67950bb

Please sign in to comment.