From 0458329ce437b0cc374415bb9055944573443449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Tue, 30 Mar 2021 08:29:27 +0200 Subject: [PATCH 1/9] Linking to new version of Core --- src/MoBi.Assets/AppConstants.cs | 2 +- src/MoBi.Assets/MoBi.Assets.csproj | 6 ++-- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.Core/MoBi.Core.csproj | 14 ++++----- src/MoBi.Engine/MoBi.Engine.csproj | 4 +-- .../MoBi.Presentation.csproj | 6 ++-- .../Tasks/ObservedDataTask.cs | 30 +++++-------------- src/MoBi.UI/MoBi.UI.csproj | 10 +++---- src/MoBi/MoBi.csproj | 4 +-- tests/MoBi.Tests/MoBi.Tests.csproj | 8 ++--- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 +-- 11 files changed, 38 insertions(+), 52 deletions(-) diff --git a/src/MoBi.Assets/AppConstants.cs b/src/MoBi.Assets/AppConstants.cs index a572187ba..b90a10428 100644 --- a/src/MoBi.Assets/AppConstants.cs +++ b/src/MoBi.Assets/AppConstants.cs @@ -1900,7 +1900,7 @@ public static string NameIsAlreadyUsedInThisContainer(string containerPath, stri public static readonly string BrowseForFile = "Select File"; public static readonly string Undefined = "Undefined"; public static readonly string PleaseSelectCurveInChartEditor = "Please select a curve from the chart editor to be displayed in the chart"; - public static readonly IReadOnlyList DefaultObservedDataCategories = new[] {ObservedData.MOLECULE, ObservedData.COMPARTMENT, ObservedData.ORGAN}; + public static readonly IReadOnlyList DefaultObservedDataCategories = new[] { Constants.ObservedData.MOLECULE, Constants.ObservedData.COMPARTMENT, Constants.ObservedData.ORGAN}; public static string PathType(string pathTypeAsString) { diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 7937009ee..9347c6eab 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 8358e686b..7f3645d91 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -60,7 +60,7 @@ - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 0b57e745b..66af38f73 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 470d71d13..bf4f97792 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -32,8 +32,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index edf093aaf..c2888e3b9 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -26,12 +26,12 @@ - + - + - + diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index c2084948e..c2dd70b57 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -73,7 +73,6 @@ public void AddObservedDataToProject() var data = _dataImporter.ImportDataSets(createMetaData().ToList(), createColumnInfos().ToList(), createDataImportSettings()); foreach (var repository in data.DataRepositories) { - adjustMolWeight(repository); AddObservedDataToProject(repository); adjustRepositoryPaths(repository); } @@ -157,23 +156,10 @@ private DataImporterSettings createDataImportSettings() Caption = $"{AppConstants.PRODUCT_NAME} - {AppConstants.Captions.ImportObservedData}" }; settings.AddNamingPatternMetaData(Constants.FILE); + settings.NameOfMetaDataHoldingMolecularWeightInformation = AppConstants.Parameters.MOLECULAR_WEIGHT; return settings; } - private void adjustMolWeight(DataRepository observedData) - { - if (!observedData.ExtendedProperties.Contains(AppConstants.Parameters.MOLECULAR_WEIGHT)) - return; - - // molweight is provided in default unit should be saved in core unit - var molWeightExtendedProperty = observedData.ExtendedProperties[AppConstants.Parameters.MOLECULAR_WEIGHT].DowncastTo>(); - var molWeight = _molWeightDimension.UnitValueToBaseUnitValue(_molWeightDimension.DefaultUnit, molWeightExtendedProperty.Value); - observedData.AllButBaseGrid().Each(x => x.DataInfo.MolWeight = molWeight); - - //Remove Molweight extended properties - observedData.ExtendedProperties.Remove(AppConstants.Parameters.MOLECULAR_WEIGHT); - } - public override void Rename(DataRepository dataRepository) { var newName = _mobiDialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(dataRepository.Name), @@ -319,19 +305,19 @@ private IEnumerable createMetaData() MinValueAllowed = false }; - yield return createMetaDataCategory(ObservedData.ORGAN, + yield return createMetaDataCategory(Constants.ObservedData.ORGAN, isMandatory: false, isListOfValuesFixed: true, fixedValuesRetriever: addPredefinedOrganValues, description: ObservedData.ObservedDataOrganDescription); - yield return createMetaDataCategory(ObservedData.COMPARTMENT, + yield return createMetaDataCategory(Constants.ObservedData.COMPARTMENT, isMandatory: false, isListOfValuesFixed: true, fixedValuesRetriever: addPredefinedCompartmentValues, description: ObservedData.ObservedDataCompartmentDescription); - yield return createMetaDataCategory(ObservedData.MOLECULE, + yield return createMetaDataCategory(Constants.ObservedData.MOLECULE, isMandatory: false, isListOfValuesFixed: true, fixedValuesRetriever: addPredefinedMoleculeNames, description: ObservedData.ObservedDataMoleculeDescription); @@ -339,7 +325,7 @@ private IEnumerable createMetaData() private void addPredefinedMoleculeNames(MetaDataCategory metaDataCategory) { - addUndefinedValueTo(metaDataCategory); + metaDataCategory.ShouldListOfValuesBeIncluded = true; allMolecules().OrderBy(molecule => molecule.Name).Each(molecule => addInfoToCategory(metaDataCategory, molecule)); } @@ -420,13 +406,13 @@ private MetaDataCategory createMetaDataCategory(string categoryName, bool isM public IEnumerable PredefinedValuesFor(string name) { - if (string.Equals(name, ObservedData.ORGAN)) + if (string.Equals(name, Constants.ObservedData.ORGAN)) return predefinedValuesForCategory(addPredefinedOrganValues); - if (string.Equals(name, ObservedData.COMPARTMENT)) + if (string.Equals(name, Constants.ObservedData.COMPARTMENT)) return predefinedValuesForCategory(addPredefinedCompartmentValues); - if (string.Equals(name, ObservedData.MOLECULE)) + if (string.Equals(name, Constants.ObservedData.MOLECULE)) return predefinedValuesForCategory(addPredefinedMoleculeNames); return Enumerable.Empty(); diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index 56380abee..e8eeb36d0 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,13 +26,13 @@ - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index f04cf3563..33962cfc8 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -68,13 +68,13 @@ - + - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index 2363c815d..464420bee 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 351790f12..688a97c4c 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -17,8 +17,8 @@ - - + + From 42c55b317fa104da628d5b05b970266dbea0f667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Tue, 30 Mar 2021 10:09:35 +0200 Subject: [PATCH 2/9] Updating core to most recent --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +++--- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.Core/MoBi.Core.csproj | 14 +++++++------- src/MoBi.Engine/MoBi.Engine.csproj | 4 ++-- src/MoBi.Presentation/MoBi.Presentation.csproj | 6 +++--- src/MoBi.UI/MoBi.UI.csproj | 10 +++++----- src/MoBi/MoBi.csproj | 4 ++-- tests/MoBi.Tests/MoBi.Tests.csproj | 8 ++++---- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 9347c6eab..73a735111 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 7f3645d91..68fabb261 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -60,7 +60,7 @@ - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 66af38f73..839bf812e 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index bf4f97792..41b15c886 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -32,8 +32,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index c2888e3b9..f7af23769 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -26,12 +26,12 @@ - + - + - + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index e8eeb36d0..49bb72ba6 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,13 +26,13 @@ - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 33962cfc8..66c63c087 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -68,13 +68,13 @@ - + - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index 464420bee..43fa0166a 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 688a97c4c..432a7591d 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -17,8 +17,8 @@ - - + + From 3bfffc193d9dbc00ac0ae74fb74259abde5eec91 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Tue, 30 Mar 2021 14:07:24 +0200 Subject: [PATCH 3/9] reload plugged in --- src/MoBi.Assets/AppConstants.cs | 1 + .../Services/ModelPartsToExcelExporterTask.cs | 10 +-- .../ContextMenuForDataRepository.cs | 9 +++ .../Tasks/ObservedDataTask.cs | 73 ++++++++++++++++++- .../UICommand/ReloadAllObservedDataCommand.cs | 39 ++++++++++ 5 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs diff --git a/src/MoBi.Assets/AppConstants.cs b/src/MoBi.Assets/AppConstants.cs index b90a10428..064ca5171 100644 --- a/src/MoBi.Assets/AppConstants.cs +++ b/src/MoBi.Assets/AppConstants.cs @@ -1059,6 +1059,7 @@ public static class MenuNames public static readonly string ModelParts = "Model Parts"; public static readonly string ImportSBML = "Open SBML Model..."; public static readonly string SaveAsPKML = "Save As PKML..."; + public static readonly string ReloadAll = "Reload all under same settings..."; public static string AddNew(string objectTypeName) => $"Create {objectTypeName}..."; diff --git a/src/MoBi.Core/Services/ModelPartsToExcelExporterTask.cs b/src/MoBi.Core/Services/ModelPartsToExcelExporterTask.cs index ed3c9e00c..365727139 100644 --- a/src/MoBi.Core/Services/ModelPartsToExcelExporterTask.cs +++ b/src/MoBi.Core/Services/ModelPartsToExcelExporterTask.cs @@ -42,15 +42,7 @@ public void ExportModelPartsToExcelFile(string excelFileName, IMoBiSimulation si var moleculeParameterDataTable = _moleculeStartValuesBuildingBlockToParameterDataTableMapper.MapFrom(simulation.MoBiBuildConfiguration.MoleculeStartValues.Where(msv => msv.IsPresent), simulation.MoBiBuildConfiguration.Molecules); var dataTables = new List {reactionDataTable, simulationParameterDataTable, moleculeParameterDataTable}; - //TODO: have to fix the export here - /* - ExportToExcelTask.ExportDataTablesToExcel(dataTables, excelFileName, openExcel: openExcel, workbookConfiguration: (wb, dt) => - { - wb.setSelection(0, 0, 0, dt.Columns.Count); - var rangeStyle = wb.getRangeStyle(); - rangeStyle.FontBold = true; - wb.setRangeStyle(rangeStyle); - });*/ + ExportToExcelTask.ExportDataTablesToExcel(dataTables, excelFileName, openExcel: openExcel); } } } \ No newline at end of file diff --git a/src/MoBi.Presentation/MenusAndBars/ContextMenus/ContextMenuForDataRepository.cs b/src/MoBi.Presentation/MenusAndBars/ContextMenus/ContextMenuForDataRepository.cs index c43abde8d..5db085e73 100644 --- a/src/MoBi.Presentation/MenusAndBars/ContextMenus/ContextMenuForDataRepository.cs +++ b/src/MoBi.Presentation/MenusAndBars/ContextMenus/ContextMenuForDataRepository.cs @@ -53,6 +53,7 @@ public IContextMenu InitializeWith(DataRepository dataRepository) editMenuItemFor(dataRepository), renameMenuItemFor(dataRepository), createSaveItemFor(dataRepository), + createReloadItemFor(dataRepository), deleteMenuItemFor(dataRepository), exportToExcel(dataRepository), reportMenuItemFor(dataRepository), @@ -95,6 +96,14 @@ private static IMenuBarButton deleteMenuItemFor(DataRepository dataRepository) .WithIcon(ApplicationIcons.Delete); } + private IMenuBarItem createReloadItemFor(DataRepository dataRepository) + { + return CreateMenuButton.WithCaption(AppConstants.MenuNames.ReloadAll) //ToDo: move to Core, also from PK-Sim + .WithCommandFor(dataRepository) + .AsDisabledIf(string.IsNullOrEmpty(dataRepository.ConfigurationId)) + .WithIcon(ApplicationIcons.Excel); + } + private IMenuBarItem createSaveItemFor(DataRepository dataRepository) { return CreateMenuButton.WithCaption(AppConstants.MenuNames.SaveAsPKML) diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index c2dd70b57..b288d05b8 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -16,6 +16,7 @@ using OSPSuite.Core.Domain.Services; using OSPSuite.Core.Domain.UnitSystem; using OSPSuite.Assets; +using OSPSuite.Core.Import; using ColumnInfo = OSPSuite.Infrastructure.Import.Core.ColumnInfo; using Command = OSPSuite.Assets.Command; using CoreConstants = OSPSuite.Core.Domain.Constants; @@ -38,6 +39,8 @@ public interface IObservedDataTask : OSPSuite.Core.Domain.Services.IObservedData /// Removes selected from their respective simulations /// void RemoveResultsFromSimulations(IReadOnlyList resultsToRemove); + + void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, IEnumerable observedDataFromSameFile); } public class ObservedDataTask : OSPSuite.Core.Domain.Services.ObservedDataTask, IObservedDataTask @@ -49,6 +52,7 @@ public class ObservedDataTask : OSPSuite.Core.Domain.Services.ObservedDataTask, private readonly IDimension _molWeightDimension; private readonly IDialogCreator _mobiDialogCreator; + public ObservedDataTask( IDataImporter dataImporter, IDimensionFactory dimensionFactory, @@ -56,7 +60,7 @@ public ObservedDataTask( IDialogCreator dialogCreator, IInteractionTask interactionTask, IDataRepositoryExportTask dataRepositoryTask, - IContainerTask containerTask, + IContainerTask containerTask, IObjectTypeResolver objectTypeResolver) : base(dialogCreator, context, dataRepositoryTask, containerTask, objectTypeResolver) { _dataImporter = dataImporter; @@ -76,6 +80,7 @@ public void AddObservedDataToProject() AddObservedDataToProject(repository); adjustRepositoryPaths(repository); } + AddImporterConfigurationToProject(data.Configuration); } private void adjustRepositoryPaths(DataRepository repository) @@ -204,6 +209,72 @@ public void RemoveResultsFromSimulations(IReadOnlyList resultsTo _context.AddToHistory(macroCommand.Run(_context)); } + public void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, IEnumerable observedDataFromSameFile) + { + + var importedObservedData = getObservedDataFromImporter(configuration); + var reloadDataSets = _dataImporter.CalculateReloadDataSetsFromConfiguration(importedObservedData.ToList(), observedDataFromSameFile.ToList()); + + foreach (var dataSet in reloadDataSets.NewDataSets) + { + AddObservedDataToProject(dataSet); + adjustRepositoryPaths(dataSet); + } + + foreach (var dataSet in reloadDataSets.DataSetsToBeDeleted.ToArray()) //toDo it should be checked if to array solves the deleting problem + { + Delete(dataSet); + } + + foreach (var dataSet in reloadDataSets.OverwrittenDataSets) + { + //TODO this here should be tested + var existingDataSet = findDataRepositoryInList(observedDataFromSameFile, dataSet); + + foreach (var column in dataSet.Columns) + { + var datacolumn = new DataColumn(column.Id, column.Name, column.Dimension, column.BaseGrid) + { + QuantityInfo = column.QuantityInfo, + DataInfo = column.DataInfo, + IsInternal = column.IsInternal, + Values = column.Values + }; + + if (column.IsBaseGrid()) + { + existingDataSet.BaseGrid.Values = datacolumn.Values; + } + else + { + var existingColumn = existingDataSet.FirstOrDefault(x => x.Name == column.Name); + if (existingColumn == null) + existingDataSet.Add(column); + else + existingColumn.Values = column.Values; + } + } + } + } + + private DataRepository findDataRepositoryInList(IEnumerable dataRepositoryList, DataRepository targetDataRepository) + { + return (from dataRepo in dataRepositoryList let result = targetDataRepository.ExtendedProperties.KeyValues.All(keyValuePair => dataRepo.ExtendedProperties[keyValuePair.Key].ValueAsObject.ToString() == keyValuePair.Value.ValueAsObject.ToString()) where result select dataRepo).FirstOrDefault(); + } + + private IEnumerable getObservedDataFromImporter(ImporterConfiguration configuration) + { + var metaDataCategories = _dataImporter.DefaultMetaDataCategories(); + var dataImporterSettings = createDataImportSettings(); + + //do we really need this in MoBi???? + dataImporterSettings.NameOfMetaDataHoldingMoleculeInformation = Constants.ObservedData.MOLECULE; + var colInfos = createColumnInfos().ToList(); + + var importedObservedData = _dataImporter.ImportFromConfiguration(configuration, (IReadOnlyList)metaDataCategories, colInfos, dataImporterSettings); + return importedObservedData; + } + private ICommand removeResultFromSimulationCommand(DataRepository dataRepository) { var parentSimulation = getSimulationWithHistoricResult(dataRepository); diff --git a/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs b/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs new file mode 100644 index 000000000..422bdbae3 --- /dev/null +++ b/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs @@ -0,0 +1,39 @@ +using System.Linq; +using MoBi.Core.Domain.Model; +using MoBi.Presentation.Tasks; +using OSPSuite.Core.Domain.Data; +using OSPSuite.Presentation.UICommands; + +namespace MoBi.Presentation.UICommand +{ + public class ReloadAllObservedDataCommand : ObjectUICommand + { + private readonly IMoBiContext _executionContext; + private readonly IObservedDataTask _observedDataTask; + + public ReloadAllObservedDataCommand( + IMoBiContext executionContext, + IObservedDataTask observedDataTask + ) + { + _executionContext = executionContext; + _observedDataTask = observedDataTask; + } + + protected override void PerformExecute() + { + if (string.IsNullOrEmpty(Subject.ConfigurationId)) + return; + + var project = _executionContext.Project; + var configurationId = Subject.ConfigurationId; + + //we should check this + var observedDataFromSameFile = + project.AllObservedData.Where(r => !string.IsNullOrEmpty(r.ConfigurationId) && r.ConfigurationId == configurationId); //actually the question here is: configID means they come from the same file right? + + var configuration = project.ImporterConfigurationBy(configurationId); + _observedDataTask.AddAndReplaceObservedDataFromConfigurationToProject(configuration, observedDataFromSameFile); + } + } +} \ No newline at end of file From 1bbf679d310de4d0f182fb17838ba7358bfd2838 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Wed, 21 Apr 2021 09:32:51 +0200 Subject: [PATCH 4/9] lists of predefined values implemented --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.Core/MoBi.Core.csproj | 14 +-- src/MoBi.Engine/MoBi.Engine.csproj | 4 +- .../MoBi.Presentation.csproj | 6 +- .../Tasks/ObservedDataTask.cs | 110 ++++++++++++------ src/MoBi.UI/MoBi.UI.csproj | 10 +- src/MoBi/MoBi.csproj | 4 +- tests/MoBi.Tests/MoBi.Tests.csproj | 8 +- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 +- 10 files changed, 103 insertions(+), 65 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 73a735111..1c4835bf1 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 68fabb261..043764b0a 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -60,7 +60,7 @@ - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 839bf812e..3e454e19f 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 41b15c886..7bf336095 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -32,8 +32,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index f7af23769..9e6a36eac 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -26,12 +26,12 @@ - + - + - + diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index b288d05b8..fec21ff8e 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -1,22 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; using MoBi.Assets; -using OSPSuite.Core.Commands.Core; -using OSPSuite.Core.Services; -using OSPSuite.Utility.Extensions; using MoBi.Core.Commands; using MoBi.Core.Domain.Model; using MoBi.Core.Helper; -using MoBi.Core.Services; using MoBi.Presentation.Tasks.Interaction; +using OSPSuite.Assets; using OSPSuite.Core.Commands; +using OSPSuite.Core.Commands.Core; using OSPSuite.Core.Domain; using OSPSuite.Core.Domain.Data; using OSPSuite.Core.Domain.Services; using OSPSuite.Core.Domain.UnitSystem; -using OSPSuite.Assets; using OSPSuite.Core.Import; +using OSPSuite.Core.Services; +using OSPSuite.Utility.Extensions; +using System; +using System.Collections.Generic; +using System.Linq; using ColumnInfo = OSPSuite.Infrastructure.Import.Core.ColumnInfo; using Command = OSPSuite.Assets.Command; using CoreConstants = OSPSuite.Core.Domain.Constants; @@ -54,12 +53,12 @@ public class ObservedDataTask : OSPSuite.Core.Domain.Services.ObservedDataTask, public ObservedDataTask( - IDataImporter dataImporter, - IDimensionFactory dimensionFactory, + IDataImporter dataImporter, + IDimensionFactory dimensionFactory, IMoBiContext context, - IDialogCreator dialogCreator, - IInteractionTask interactionTask, - IDataRepositoryExportTask dataRepositoryTask, + IDialogCreator dialogCreator, + IInteractionTask interactionTask, + IDataRepositoryExportTask dataRepositoryTask, IContainerTask containerTask, IObjectTypeResolver objectTypeResolver) : base(dialogCreator, context, dataRepositoryTask, containerTask, objectTypeResolver) { @@ -73,8 +72,10 @@ public ObservedDataTask( public void AddObservedDataToProject() { - //maybe the formats are not being registered var data = _dataImporter.ImportDataSets(createMetaData().ToList(), createColumnInfos().ToList(), createDataImportSettings()); + + if (data.DataRepositories == null || data.Configuration == null) return; + foreach (var repository in data.DataRepositories) { AddObservedDataToProject(repository); @@ -87,12 +88,12 @@ private void adjustRepositoryPaths(DataRepository repository) { var baseGrid = repository.BaseGrid; var baseGridName = baseGrid.Name.Replace(ObjectPath.PATH_DELIMITER, "\\"); - baseGrid.QuantityInfo = new QuantityInfo(baseGrid.Name, new[] {repository.Name, baseGridName}, QuantityType.Time); + baseGrid.QuantityInfo = new QuantityInfo(baseGrid.Name, new[] { repository.Name, baseGridName }, QuantityType.Time); foreach (var col in repository.AllButBaseGrid()) { var colName = col.Name.Replace(ObjectPath.PATH_DELIMITER, "\\"); - var quantityInfo = new QuantityInfo(col.Name, new[] {repository.Name, colName}, QuantityType.Undefined); + var quantityInfo = new QuantityInfo(col.Name, new[] { repository.Name, colName }, QuantityType.Undefined); col.QuantityInfo = quantityInfo; } } @@ -160,7 +161,7 @@ private DataImporterSettings createDataImportSettings() IconName = ApplicationIcons.MoBi.IconName, Caption = $"{AppConstants.PRODUCT_NAME} - {AppConstants.Captions.ImportObservedData}" }; - settings.AddNamingPatternMetaData(Constants.FILE); + addNamingPatterns(settings); settings.NameOfMetaDataHoldingMolecularWeightInformation = AppConstants.Parameters.MOLECULAR_WEIGHT; return settings; } @@ -201,19 +202,17 @@ public void RemoveResultsFromSimulations(IReadOnlyList resultsTo CommandType = AppConstants.Commands.DeleteCommand }; - resultsToRemove.Each(result => - { - macroCommand.Add(removeResultFromSimulationCommand(result)); - }); + resultsToRemove.Each(result => { macroCommand.Add(removeResultFromSimulationCommand(result)); }); _context.AddToHistory(macroCommand.Run(_context)); } - public void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, IEnumerable observedDataFromSameFile) + public void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, + IEnumerable observedDataFromSameFile) { - var importedObservedData = getObservedDataFromImporter(configuration); - var reloadDataSets = _dataImporter.CalculateReloadDataSetsFromConfiguration(importedObservedData.ToList(), observedDataFromSameFile.ToList()); + var reloadDataSets = + _dataImporter.CalculateReloadDataSetsFromConfiguration(importedObservedData.ToList(), observedDataFromSameFile.ToList()); foreach (var dataSet in reloadDataSets.NewDataSets) { @@ -259,19 +258,23 @@ public void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfigur private DataRepository findDataRepositoryInList(IEnumerable dataRepositoryList, DataRepository targetDataRepository) { - return (from dataRepo in dataRepositoryList let result = targetDataRepository.ExtendedProperties.KeyValues.All(keyValuePair => dataRepo.ExtendedProperties[keyValuePair.Key].ValueAsObject.ToString() == keyValuePair.Value.ValueAsObject.ToString()) where result select dataRepo).FirstOrDefault(); + return (from dataRepo in dataRepositoryList + let result = targetDataRepository.ExtendedProperties.KeyValues.All(keyValuePair => + dataRepo.ExtendedProperties[keyValuePair.Key].ValueAsObject.ToString() == keyValuePair.Value.ValueAsObject.ToString()) + where result + select dataRepo).FirstOrDefault(); } private IEnumerable getObservedDataFromImporter(ImporterConfiguration configuration) { - var metaDataCategories = _dataImporter.DefaultMetaDataCategories(); var dataImporterSettings = createDataImportSettings(); //do we really need this in MoBi???? dataImporterSettings.NameOfMetaDataHoldingMoleculeInformation = Constants.ObservedData.MOLECULE; var colInfos = createColumnInfos().ToList(); - var importedObservedData = _dataImporter.ImportFromConfiguration(configuration, (IReadOnlyList)metaDataCategories, colInfos, dataImporterSettings); + var importedObservedData = _dataImporter.ImportFromConfiguration(configuration, createMetaData().ToList(), + colInfos, dataImporterSettings); return importedObservedData; } @@ -297,7 +300,8 @@ private static ClearResultsCommand clearResultsCommand(IMoBiSimulation parentSim return new ClearResultsCommand(parentSimulation); } - private static RemoveHistoricResultFromSimulationCommand removeHistoricResultFromSimulationCommand(DataRepository repository, IMoBiSimulation parentSimulation) + private static RemoveHistoricResultFromSimulationCommand removeHistoricResultFromSimulationCommand(DataRepository repository, + IMoBiSimulation parentSimulation) { return new RemoveHistoricResultFromSimulationCommand(parentSimulation, repository); } @@ -315,7 +319,7 @@ private IEnumerable createColumnInfos() NullValuesHandling = NullValuesHandlingType.DeleteRow, }; - timeColumn.DimensionInfos.Add(new DimensionInfo.DimensionInfo {Dimension = timeDimension, IsMainDimension = true}); + timeColumn.DimensionInfos.Add(new DimensionInfo.DimensionInfo { Dimension = timeDimension, IsMainDimension = true }); yield return timeColumn; var mainDimension = _dimensionFactory.Dimension(CoreConstants.Dimension.MOLAR_CONCENTRATION); @@ -402,10 +406,8 @@ private void addPredefinedMoleculeNames(MetaDataCategory metaDataCategory) private IEnumerable allMolecules() { - return _context.CurrentProject.MoleculeBlockCollection.SelectMany(buildingBlock => - { - return buildingBlock.Select(builder => builder); - }).DistinctBy(builder => builder.Name); + return _context.CurrentProject.MoleculeBlockCollection.SelectMany(buildingBlock => { return buildingBlock.Select(builder => builder); }) + .DistinctBy(builder => builder.Name); } private static void addUndefinedValueTo(MetaDataCategory metaDataCategory) @@ -416,23 +418,58 @@ private static void addUndefinedValueTo(MetaDataCategory metaDataCategory) private void addPredefinedOrganValues(MetaDataCategory metaDataCategory) { addUndefinedValueTo(metaDataCategory); + metaDataCategory.ShouldListOfValuesBeIncluded = true; allOrgans().OrderBy(org => org.Name).Each(organ => addInfoToCategory(metaDataCategory, organ)); } + private void addNamingPatterns(DataImporterSettings dataImporterSettings) + { + dataImporterSettings.AddNamingPatternMetaData( + Constants.FILE + ); + + dataImporterSettings.AddNamingPatternMetaData( + Constants.FILE, + Constants.SHEET + ); + + dataImporterSettings.AddNamingPatternMetaData( + Constants.ObservedData.MOLECULE, + Constants.ObservedData.SPECIES, + Constants.ObservedData.ORGAN, + Constants.ObservedData.COMPARTMENT + ); + + dataImporterSettings.AddNamingPatternMetaData( + Constants.ObservedData.MOLECULE, + Constants.ObservedData.SPECIES, + Constants.ObservedData.ORGAN, + Constants.ObservedData.COMPARTMENT, + Constants.ObservedData.STUDY_ID, + Constants.ObservedData.GENDER, + Constants.ObservedData.DOSE, + Constants.ObservedData.ROUTE, + Constants.ObservedData.PATIENT_ID + ); + } + private void addPredefinedCompartmentValues(MetaDataCategory metaDataCategory) { addUndefinedValueTo(metaDataCategory); + metaDataCategory.ShouldListOfValuesBeIncluded = true; allCompartments().OrderBy(comp => comp.Name).Each(compartment => addInfoToCategory(metaDataCategory, compartment)); } private IEnumerable allOrgans() { - return allTopContainers().SelectMany(allSubContainers).Where(container => container.ContainerType == ContainerType.Organ).DistinctBy(x => x.Name); + return allTopContainers().SelectMany(allSubContainers).Where(container => container.ContainerType == ContainerType.Organ) + .DistinctBy(x => x.Name); } private IEnumerable allCompartments() { - return allTopContainers().SelectMany(allSubContainers).Where(container => container.ContainerType == ContainerType.Compartment).DistinctBy(x => x.Name); + return allTopContainers().SelectMany(allSubContainers).Where(container => container.ContainerType == ContainerType.Compartment) + .DistinctBy(x => x.Name); } private IEnumerable allTopContainers() @@ -458,7 +495,8 @@ private void addInfoToCategory(MetaDataCategory metaDataCategory, IContainer con metaDataCategory.ListOfImages.Add(container.Name, icon.IconName); } - private MetaDataCategory createMetaDataCategory(string categoryName, bool isMandatory = false, bool isListOfValuesFixed = false, Action fixedValuesRetriever = null, string description = null) + private MetaDataCategory createMetaDataCategory(string categoryName, bool isMandatory = false, bool isListOfValuesFixed = false, + Action fixedValuesRetriever = null, string description = null) { var category = new MetaDataCategory { diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index 49bb72ba6..1c7a7b26c 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,13 +26,13 @@ - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 66c63c087..0b76494fe 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -68,13 +68,13 @@ - + - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index 43fa0166a..ac86bd033 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 432a7591d..119077f9d 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -17,8 +17,8 @@ - - + + From 731ea0b15aba09b44eb405d961d89578cab2b243 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Wed, 21 Apr 2021 09:59:37 +0200 Subject: [PATCH 5/9] apply configuration fixed --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +++--- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.Core/MoBi.Core.csproj | 14 +++++++------- src/MoBi.Engine/MoBi.Engine.csproj | 4 ++-- src/MoBi.Presentation/MoBi.Presentation.csproj | 6 +++--- src/MoBi.UI/MoBi.UI.csproj | 10 +++++----- src/MoBi/MoBi.csproj | 4 ++-- tests/MoBi.Tests/MoBi.Tests.csproj | 8 ++++---- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 1c4835bf1..d54397f96 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 043764b0a..f9361302a 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -60,7 +60,7 @@ - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 3e454e19f..294c061e2 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 7bf336095..c3b9693fb 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -32,8 +32,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index 9e6a36eac..1482b6578 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -26,12 +26,12 @@ - + - + - + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index 1c7a7b26c..9f77cfad1 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,13 +26,13 @@ - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 0b76494fe..8cb14058f 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -68,13 +68,13 @@ - + - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index ac86bd033..8b8382cc0 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 119077f9d..ef6514494 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -17,8 +17,8 @@ - - + + From 713232cb266e032cba1fc43d1a23df9be37ad926 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Wed, 21 Apr 2021 10:25:45 +0200 Subject: [PATCH 6/9] solution builds --- src/MoBi.Presentation/Tasks/ObservedDataTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index cdc031a89..d6d0263fe 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -418,7 +418,7 @@ private void addPredefinedOrganValues(DimensionInfo.MetaDataCategory metaDataCat allOrgans().OrderBy(org => org.Name).Each(organ => addInfoToCategory(metaDataCategory, organ)); } - private void addNamingPatterns(DataImporterSettings dataImporterSettings) + private void addNamingPatterns(DimensionInfo.DataImporterSettings dataImporterSettings) { dataImporterSettings.AddNamingPatternMetaData( Constants.FILE From 434281d085db140de7404ff9bb5b5767fadc3809 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Thu, 22 Apr 2021 10:45:53 +0200 Subject: [PATCH 7/9] nuget package version corrected --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +++--- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.Core/MoBi.Core.csproj | 14 +++++++------- src/MoBi.Engine/MoBi.Engine.csproj | 4 ++-- src/MoBi.Presentation/MoBi.Presentation.csproj | 6 +++--- src/MoBi.UI/MoBi.UI.csproj | 10 +++++----- src/MoBi/MoBi.csproj | 4 ++-- tests/MoBi.Tests/MoBi.Tests.csproj | 8 ++++---- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 593ba8251..853ed073a 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -29,9 +29,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 31b477c40..def24df3c 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -61,7 +61,7 @@ - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 2ce1edb6a..46aea72e0 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -38,13 +38,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index d31058591..6ab945c1e 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -34,8 +34,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index 2751d6b80..bb60f9ff9 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -32,12 +32,12 @@ - + - + - + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index a5add6e0e..e05d315da 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -33,13 +33,13 @@ - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 61e03bb0a..8be319939 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -69,14 +69,14 @@ - + - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index 7b0b2a128..1bdcd21f3 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -49,10 +49,10 @@ - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 2a54fae55..cf0d1fe66 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -19,8 +19,8 @@ - - + + From 13c5c1490cd8a2938d4a6b62ecca2eb6028cca17 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Tue, 27 Apr 2021 12:53:29 +0200 Subject: [PATCH 8/9] code review fixes --- src/MoBi.Assets/MoBi.Assets.csproj | 9 +++----- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 3 +-- src/MoBi.Core/MoBi.Core.csproj | 21 +++++++------------ src/MoBi.Engine/MoBi.Engine.csproj | 6 ++---- .../MoBi.Presentation.csproj | 9 +++----- .../Tasks/ObservedDataTask.cs | 19 +++++++++++++++-- .../UICommand/ReloadAllObservedDataCommand.cs | 2 +- src/MoBi.UI/MoBi.UI.csproj | 15 +++++-------- src/MoBi/MoBi.csproj | 6 ++---- tests/MoBi.Tests/MoBi.Tests.csproj | 12 ++++------- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 6 ++---- 11 files changed, 47 insertions(+), 61 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 853ed073a..0348f5acf 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -26,12 +26,9 @@ - - - - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index def24df3c..cefa78d09 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -60,8 +60,7 @@ - - + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 46aea72e0..67d0920d4 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,20 +31,13 @@ - - - - - - - - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 6ab945c1e..a47988cd5 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -32,10 +32,8 @@ - - - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index bb60f9ff9..4f8d500b9 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -26,18 +26,15 @@ - - - - + - + - + diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index d6d0263fe..5d91bd0ca 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -36,7 +36,7 @@ public interface IObservedDataTask : OSPSuite.Core.Domain.Services.IObservedData /// void RemoveResultsFromSimulations(IReadOnlyList resultsToRemove); - void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, IEnumerable observedDataFromSameFile); + void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, IReadOnlyList observedDataFromSameFile); } public class ObservedDataTask : OSPSuite.Core.Domain.Services.ObservedDataTask, IObservedDataTask @@ -75,6 +75,7 @@ public void AddObservedDataToProject() foreach (var repository in data.DataRepositories) { + adjustMolWeightUnit(repository); AddObservedDataToProject(repository); adjustRepositoryPaths(repository); } @@ -163,6 +164,20 @@ private DimensionInfo.DataImporterSettings createDataImportSettings() return settings; } + private void adjustMolWeightUnit(DataRepository observedData) + { + if (!observedData.ExtendedProperties.Contains(AppConstants.Parameters.MOLECULAR_WEIGHT)) + return; + + // molweight is provided in default unit should be saved in core unit + var molWeightExtendedProperty = observedData.ExtendedProperties[AppConstants.Parameters.MOLECULAR_WEIGHT].DowncastTo>(); + var molWeight = _molWeightDimension.UnitValueToBaseUnitValue(_molWeightDimension.DefaultUnit, molWeightExtendedProperty.Value); + observedData.AllButBaseGrid().Each(x => x.DataInfo.MolWeight = molWeight); + + //Remove Molweight extended properties + observedData.ExtendedProperties.Remove(AppConstants.Parameters.MOLECULAR_WEIGHT); + } + public override void Rename(DataRepository dataRepository) { var newName = _mobiDialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(dataRepository.Name), @@ -205,7 +220,7 @@ public void RemoveResultsFromSimulations(IReadOnlyList resultsTo } public void AddAndReplaceObservedDataFromConfigurationToProject(ImporterConfiguration configuration, - IEnumerable observedDataFromSameFile) + IReadOnlyList observedDataFromSameFile) { var importedObservedData = getObservedDataFromImporter(configuration); var reloadDataSets = diff --git a/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs b/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs index 422bdbae3..7eef8c9cd 100644 --- a/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs +++ b/src/MoBi.Presentation/UICommand/ReloadAllObservedDataCommand.cs @@ -33,7 +33,7 @@ protected override void PerformExecute() project.AllObservedData.Where(r => !string.IsNullOrEmpty(r.ConfigurationId) && r.ConfigurationId == configurationId); //actually the question here is: configID means they come from the same file right? var configuration = project.ImporterConfigurationBy(configurationId); - _observedDataTask.AddAndReplaceObservedDataFromConfigurationToProject(configuration, observedDataFromSameFile); + _observedDataTask.AddAndReplaceObservedDataFromConfigurationToProject(configuration, observedDataFromSameFile.ToList()); } } } \ No newline at end of file diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index e05d315da..61c23364c 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,20 +26,15 @@ - - - - - - - - - + + + + - + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 8be319939..df0a98da5 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -68,15 +68,13 @@ - - + - - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index 1bdcd21f3..381a8cb8a 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -45,14 +45,10 @@ - - - - - - - - + + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index cf0d1fe66..78068835a 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -17,10 +17,8 @@ - - - - + + From eec3982dd82273a559f26a9c182d18214f013933 Mon Sep 17 00:00:00 2001 From: georgeDaskalakis Date: Thu, 29 Apr 2021 12:58:00 +0200 Subject: [PATCH 9/9] removing unnecessary function --- src/MoBi.Presentation/Tasks/ObservedDataTask.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs index 5d91bd0ca..86b77acaa 100644 --- a/src/MoBi.Presentation/Tasks/ObservedDataTask.cs +++ b/src/MoBi.Presentation/Tasks/ObservedDataTask.cs @@ -75,7 +75,6 @@ public void AddObservedDataToProject() foreach (var repository in data.DataRepositories) { - adjustMolWeightUnit(repository); AddObservedDataToProject(repository); adjustRepositoryPaths(repository); } @@ -164,20 +163,6 @@ private DimensionInfo.DataImporterSettings createDataImportSettings() return settings; } - private void adjustMolWeightUnit(DataRepository observedData) - { - if (!observedData.ExtendedProperties.Contains(AppConstants.Parameters.MOLECULAR_WEIGHT)) - return; - - // molweight is provided in default unit should be saved in core unit - var molWeightExtendedProperty = observedData.ExtendedProperties[AppConstants.Parameters.MOLECULAR_WEIGHT].DowncastTo>(); - var molWeight = _molWeightDimension.UnitValueToBaseUnitValue(_molWeightDimension.DefaultUnit, molWeightExtendedProperty.Value); - observedData.AllButBaseGrid().Each(x => x.DataInfo.MolWeight = molWeight); - - //Remove Molweight extended properties - observedData.ExtendedProperties.Remove(AppConstants.Parameters.MOLECULAR_WEIGHT); - } - public override void Rename(DataRepository dataRepository) { var newName = _mobiDialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(dataRepository.Name),