Skip to content

Commit

Permalink
Fixes #547 bidirectional (#549)
Browse files Browse the repository at this point in the history
Fixes #515
  • Loading branch information
msevestre authored Apr 2, 2021
1 parent e6eda39 commit 033758e
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 322 deletions.
3 changes: 1 addition & 2 deletions src/MoBi.Assets/AppConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,13 +1894,12 @@ public static string NameIsAlreadyUsedInThisContainer(string containerPath, stri
}
}

public static readonly string TimeColumName = "Simulationtime";
public static readonly string TimeColumnName = "Simulationtime";

public static readonly string ResultName = "Results ";
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<string> DefaultObservedDataCategories = new[] {ObservedData.MOLECULE, ObservedData.COMPARTMENT, ObservedData.ORGAN};

public static string PathType(string pathTypeAsString)
{
Expand Down
6 changes: 3 additions & 3 deletions src/MoBi.Assets/MoBi.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="10.0.94" />
<PackageReference Include="OSPSuite.Assets.Images" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Assets" Version="10.0.122" />
<PackageReference Include="OSPSuite.Assets.Images" Version="10.0.122" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MoBi.BatchTool/MoBi.BatchTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
<PackageReference Include="OSPSuite.DevExpress" Version="20.1.6" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.50" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.42" GeneratePathProperty="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/MoBi.Core/Domain/Services/DataNamingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DataNamingService(IMoBiContext context)

public string GetTimeName()
{
return AppConstants.TimeColumName;
return AppConstants.TimeColumnName;
}

public string GetNewRepositoryName()
Expand Down
14 changes: 7 additions & 7 deletions src/MoBi.Core/MoBi.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
<PackageReference Include="FluentNHibernate" Version="2.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Assets" Version="10.0.94" />
<PackageReference Include="OSPSuite.Assets.Images" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
<PackageReference Include="OSPSuite.Assets" Version="10.0.122" />
<PackageReference Include="OSPSuite.Assets.Images" Version="10.0.122" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="10.0.122" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="10.0.122" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="10.0.122" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="10.0.122" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/MoBi.Engine/MoBi.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Assets" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
<PackageReference Include="OSPSuite.Assets" Version="10.0.122" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/MoBi.Presentation/MoBi.Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

<ItemGroup>
<PackageReference Include="Northwoods.GoWin" Version="5.2.0" />
<PackageReference Include="OSPSuite.Presentation" Version="10.0.94" />
<PackageReference Include="OSPSuite.Presentation" Version="10.0.122" />
<PackageReference Include="OSPSuite.Presentation.Importer" Version="10.0.92" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="10.0.94" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="10.0.122" />
<PackageReference Include="OSPSuite.TeXReporting" Version="3.0.0.4" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE">
Expand Down
104 changes: 48 additions & 56 deletions src/MoBi.Presentation/Tasks/ObservedDataTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@
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 ColumnInfo = OSPSuite.Infrastructure.Import.Core.ColumnInfo;
using OSPSuite.Core.Services;
using OSPSuite.Infrastructure.Import.Services;
using OSPSuite.Utility.Extensions;
using Command = OSPSuite.Assets.Command;
using CoreConstants = OSPSuite.Core.Domain.Constants;
using DataImporterSettings = OSPSuite.Infrastructure.Import.Core.DataImporterSettings;
using DimensionInfo = OSPSuite.Infrastructure.Import.Core;
using IDataImporter = OSPSuite.Infrastructure.Import.Services.IDataImporter;
using MetaDataCategory = OSPSuite.Infrastructure.Import.Core.MetaDataCategory;
using NullValuesHandlingType = OSPSuite.Infrastructure.Import.Core.NullValuesHandlingType;

namespace MoBi.Presentation.Tasks
{
Expand All @@ -50,13 +45,13 @@ public class ObservedDataTask : OSPSuite.Core.Domain.Services.ObservedDataTask,
private readonly IDialogCreator _mobiDialogCreator;

public ObservedDataTask(
IDataImporter dataImporter,
IDimensionFactory dimensionFactory,
IDataImporter dataImporter,
IDimensionFactory dimensionFactory,
IMoBiContext context,
IDialogCreator dialogCreator,
IInteractionTask interactionTask,
IDataRepositoryExportTask dataRepositoryTask,
IContainerTask containerTask,
IDialogCreator dialogCreator,
IInteractionTask interactionTask,
IDataRepositoryExportTask dataRepositoryTask,
IContainerTask containerTask,
IObjectTypeResolver objectTypeResolver) : base(dialogCreator, context, dataRepositoryTask, containerTask, objectTypeResolver)
{
_dataImporter = dataImporter;
Expand Down Expand Up @@ -95,7 +90,7 @@ private void adjustRepositoryPaths(DataRepository repository)

public void LoadObservedDataIntoProject()
{
string filename = _interactionTask.AskForFileToOpen(AppConstants.Dialog.Load(ObjectTypes.ObservedData), CoreConstants.Filter.PKML_FILE_FILTER, CoreConstants.DirectoryKey.MODEL_PART);
string filename = _interactionTask.AskForFileToOpen(AppConstants.Dialog.Load(ObjectTypes.ObservedData), Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART);
if (filename.IsNullOrEmpty())
return;

Expand Down Expand Up @@ -149,9 +144,9 @@ private static MoBiMacroCommand deleteAllResultsFromSimulationCommand(IMoBiSimul
return macroCommand;
}

private DataImporterSettings createDataImportSettings()
private DimensionInfo.DataImporterSettings createDataImportSettings()
{
var settings = new DataImporterSettings
var settings = new DimensionInfo.DataImporterSettings
{
IconName = ApplicationIcons.MoBi.IconName,
Caption = $"{AppConstants.PRODUCT_NAME} - {AppConstants.Captions.ImportObservedData}"
Expand Down Expand Up @@ -210,10 +205,7 @@ public void RemoveResultsFromSimulations(IReadOnlyList<DataRepository> resultsTo
CommandType = AppConstants.Commands.DeleteCommand
};

resultsToRemove.Each(result =>
{
macroCommand.Add(removeResultFromSimulationCommand(result));
});
resultsToRemove.Each(result => { macroCommand.Add(removeResultFromSimulationCommand(result)); });

_context.AddToHistory(macroCommand.Run(_context));
}
Expand Down Expand Up @@ -245,45 +237,45 @@ private static RemoveHistoricResultFromSimulationCommand removeHistoricResultFro
return new RemoveHistoricResultFromSimulationCommand(parentSimulation, repository);
}

private IEnumerable<ColumnInfo> createColumnInfos()
private IEnumerable<DimensionInfo.ColumnInfo> createColumnInfos()
{
var timeDimension = _dimensionFactory.Dimension(CoreConstants.Dimension.TIME);
var timeColumn = new ColumnInfo
var timeDimension = _dimensionFactory.Dimension(Constants.Dimension.TIME);
var timeColumn = new DimensionInfo.ColumnInfo
{
DefaultDimension = timeDimension,
Name = "Time",
Description = "Time",
DisplayName = "Time",
IsMandatory = true,
NullValuesHandling = NullValuesHandlingType.DeleteRow,
NullValuesHandling = DimensionInfo.NullValuesHandlingType.DeleteRow,
};

timeColumn.DimensionInfos.Add(new DimensionInfo.DimensionInfo {Dimension = timeDimension, IsMainDimension = true});
yield return timeColumn;

var mainDimension = _dimensionFactory.Dimension(CoreConstants.Dimension.MOLAR_CONCENTRATION);
var measurementInfo = new ColumnInfo
var mainDimension = _dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION);
var measurementInfo = new DimensionInfo.ColumnInfo
{
DefaultDimension = mainDimension,
Name = "Measurement",
Description = "Measurement",
DisplayName = "Measurement",
IsMandatory = true,
NullValuesHandling = NullValuesHandlingType.DeleteRow,
NullValuesHandling = DimensionInfo.NullValuesHandlingType.DeleteRow,
BaseGridName = timeColumn.Name
};

addDimensionsTo(measurementInfo, mainDimension);
yield return measurementInfo;

var errorInfo = new ColumnInfo
var errorInfo = new DimensionInfo.ColumnInfo
{
DefaultDimension = mainDimension,
Name = "Error",
Description = "Error",
DisplayName = "Error",
IsMandatory = false,
NullValuesHandling = NullValuesHandlingType.Allowed,
NullValuesHandling = DimensionInfo.NullValuesHandlingType.Allowed,
BaseGridName = timeColumn.Name,
RelatedColumnOf = measurementInfo.Name
};
Expand All @@ -292,9 +284,9 @@ private IEnumerable<ColumnInfo> createColumnInfos()
yield return errorInfo;
}

private void addDimensionsTo(ColumnInfo columnInfo, IDimension mainDimension)
private void addDimensionsTo(DimensionInfo.ColumnInfo columnInfo, IDimension mainDimension)
{
var timeDimension = _dimensionFactory.Dimension(CoreConstants.Dimension.TIME);
var timeDimension = _dimensionFactory.Dimension(Constants.Dimension.TIME);

foreach (var dimension in _dimensionFactory.DimensionsSortedByName.Where(x => x != timeDimension))
{
Expand All @@ -306,9 +298,9 @@ private void addDimensionsTo(ColumnInfo columnInfo, IDimension mainDimension)
}
}

private IEnumerable<MetaDataCategory> createMetaData()
private IEnumerable<DimensionInfo.MetaDataCategory> createMetaData()
{
yield return new MetaDataCategory
yield return new DimensionInfo.MetaDataCategory
{
Name = AppConstants.Parameters.MOLECULAR_WEIGHT,
DisplayName = $"{AppConstants.Parameters.MOLECULAR_WEIGHT} [{_molWeightDimension.DefaultUnit}]",
Expand All @@ -319,50 +311,47 @@ private IEnumerable<MetaDataCategory> createMetaData()
MinValueAllowed = false
};

yield return createMetaDataCategory<string>(ObservedData.ORGAN,
yield return createMetaDataCategory<string>(Constants.ObservedData.ORGAN,
isMandatory: false,
isListOfValuesFixed: true,
fixedValuesRetriever: addPredefinedOrganValues,
description: ObservedData.ObservedDataOrganDescription);

yield return createMetaDataCategory<string>(ObservedData.COMPARTMENT,
yield return createMetaDataCategory<string>(Constants.ObservedData.COMPARTMENT,
isMandatory: false,
isListOfValuesFixed: true,
fixedValuesRetriever: addPredefinedCompartmentValues,
description: ObservedData.ObservedDataCompartmentDescription);

yield return createMetaDataCategory<string>(ObservedData.MOLECULE,
yield return createMetaDataCategory<string>(Constants.ObservedData.MOLECULE,
isMandatory: false, isListOfValuesFixed: true,
fixedValuesRetriever: addPredefinedMoleculeNames,
description: ObservedData.ObservedDataMoleculeDescription);
}

private void addPredefinedMoleculeNames(MetaDataCategory metaDataCategory)
private void addPredefinedMoleculeNames(DimensionInfo.MetaDataCategory metaDataCategory)
{
addUndefinedValueTo(metaDataCategory);
allMolecules().OrderBy(molecule => molecule.Name).Each(molecule => addInfoToCategory(metaDataCategory, molecule));
}

private IEnumerable<IContainer> 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)
private static void addUndefinedValueTo(DimensionInfo.MetaDataCategory metaDataCategory)
{
metaDataCategory.ListOfValues.Add(AppConstants.Undefined, AppConstants.Undefined);
}

private void addPredefinedOrganValues(MetaDataCategory metaDataCategory)
private void addPredefinedOrganValues(DimensionInfo.MetaDataCategory metaDataCategory)
{
addUndefinedValueTo(metaDataCategory);
allOrgans().OrderBy(org => org.Name).Each(organ => addInfoToCategory(metaDataCategory, organ));
}

private void addPredefinedCompartmentValues(MetaDataCategory metaDataCategory)
private void addPredefinedCompartmentValues(DimensionInfo.MetaDataCategory metaDataCategory)
{
addUndefinedValueTo(metaDataCategory);
allCompartments().OrderBy(comp => comp.Name).Each(compartment => addInfoToCategory(metaDataCategory, compartment));
Expand Down Expand Up @@ -392,7 +381,7 @@ private IEnumerable<IContainer> allSubContainers(IContainer container)
}
}

private void addInfoToCategory(MetaDataCategory metaDataCategory, IContainer container)
private void addInfoToCategory(DimensionInfo.MetaDataCategory metaDataCategory, IContainer container)
{
metaDataCategory.ListOfValues.Add(container.Name, container.Name);

Expand All @@ -401,9 +390,9 @@ private void addInfoToCategory(MetaDataCategory metaDataCategory, IContainer con
metaDataCategory.ListOfImages.Add(container.Name, icon.IconName);
}

private MetaDataCategory createMetaDataCategory<T>(string categoryName, bool isMandatory = false, bool isListOfValuesFixed = false, Action<MetaDataCategory> fixedValuesRetriever = null, string description = null)
private DimensionInfo.MetaDataCategory createMetaDataCategory<T>(string categoryName, bool isMandatory = false, bool isListOfValuesFixed = false, Action<DimensionInfo.MetaDataCategory> fixedValuesRetriever = null, string description = null)
{
var category = new MetaDataCategory
var category = new DimensionInfo.MetaDataCategory
{
Name = categoryName,
DisplayName = categoryName,
Expand All @@ -420,26 +409,29 @@ private MetaDataCategory createMetaDataCategory<T>(string categoryName, bool isM

public IEnumerable<string> 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<string>();
}

private IEnumerable<string> predefinedValuesForCategory(Action<MetaDataCategory> action)
private IEnumerable<string> predefinedValuesForCategory(Action<DimensionInfo.MetaDataCategory> action)
{
var category = new MetaDataCategory();
var category = new DimensionInfo.MetaDataCategory();
action(category);
return category.ListOfValues.Values;
}

public IReadOnlyList<string> DefaultMetaDataCategories => AppConstants.DefaultObservedDataCategories;
public IReadOnlyList<string> DefaultMetaDataCategories => new[]
{
Constants.ObservedData.MOLECULE, Constants.ObservedData.COMPARTMENT, Constants.ObservedData.ORGAN
};

public IReadOnlyList<string> ReadOnlyMetaDataCategories => new List<string>();

Expand Down
10 changes: 5 additions & 5 deletions src/MoBi.UI/MoBi.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
<PackageReference Include="OSPSuite.DataBinding" Version="3.0.0.4" />
<PackageReference Include="OSPSuite.DataBinding.DevExpress" Version="5.0.0.1" />
<PackageReference Include="OSPSuite.DevExpress" Version="20.1.6" />
<PackageReference Include="OSPSuite.Infrastructure" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="10.0.94" />
<PackageReference Include="OSPSuite.Presentation" Version="10.0.94" />
<PackageReference Include="OSPSuite.UI" Version="10.0.94" />
<PackageReference Include="OSPSuite.Infrastructure" Version="10.0.122" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="10.0.122" />
<PackageReference Include="OSPSuite.Presentation" Version="10.0.122" />
<PackageReference Include="OSPSuite.UI" Version="10.0.122" />
<PackageReference Include="OSPSuite.UI.Importer" Version="10.0.92" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="10.0.94" />
<PackageReference Include="OSPSuite.Core" Version="10.0.122" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE">
Expand Down
Loading

0 comments on commit 033758e

Please sign in to comment.