Skip to content

Commit

Permalink
WIP #487. Also fixes #523
Browse files Browse the repository at this point in the history
  • Loading branch information
msevestre committed Mar 12, 2021
1 parent a92c1ce commit 43b641e
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 295 deletions.
9 changes: 1 addition & 8 deletions src/MoBi.Presentation/DTO/ContainerDTO.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
using System.Collections.Generic;
using OSPSuite.Core.Domain;

namespace MoBi.Presentation.DTO
{
public interface ITaggedEntityDTO
public class ContainerDTO : ObjectBaseDTO
{
IList<TagDTO> Tags { set; get; }
}

public class ContainerDTO : ObjectBaseDTO, ITaggedEntityDTO
{
public IList<TagDTO> Tags { set; get; }
public ContainerMode Mode { set; get; }
public ContainerType ContainerType { get; set; }
}
Expand Down
4 changes: 1 addition & 3 deletions src/MoBi.Presentation/DTO/ParameterDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@
using OSPSuite.Core.Domain;
using OSPSuite.Core.Domain.Formulas;
using OSPSuite.Core.Domain.UnitSystem;
using OSPSuite.Presentation.DTO;
using OSPSuite.Utility.Collections;
using OSPSuite.Utility.Extensions;
using OSPSuite.Utility.Validation;

namespace MoBi.Presentation.DTO
{
public class ParameterDTO : ObjectBaseDTO, ITaggedEntityDTO, IMoBiParameterDTO
public class ParameterDTO : ObjectBaseDTO, IMoBiParameterDTO
{
public bool HasRHS { get; set; }
public FormulaBuilderDTO RHSFormula { get; set; }
public FormulaBuilderDTO Formula { get; set; }
public IParameter Parameter { get; private set; }
public bool IsAdvancedParameter { get; set; }
public IList<TagDTO> Tags { get; set; }
public IGroup Group { get; set; }
public bool CanBeVariedInPopulation { get; set; }
public bool IsFavorite { get; set; }
Expand Down
10 changes: 3 additions & 7 deletions src/MoBi.Presentation/Mappers/ContainerToContainerDTOMapper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using OSPSuite.Utility;
using OSPSuite.Utility.Extensions;
using MoBi.Core.Repositories;
using MoBi.Core.Repositories;
using MoBi.Presentation.DTO;
using OSPSuite.Core.Domain;
using OSPSuite.Utility;

namespace MoBi.Presentation.Mappers
{
Expand All @@ -12,12 +11,10 @@ public interface IContainerToContainerDTOMapper : IMapper<IContainer, ContainerD

public class ContainerToContainerDTOMapper : ObjectBaseToObjectBaseDTOMapperBase, IContainerToContainerDTOMapper
{
private readonly ITagToTagDTOMapper _tagDTOMapper;
private readonly IIconRepository _iconRepository;

public ContainerToContainerDTOMapper(ITagToTagDTOMapper tagDTOMapper,IIconRepository iconRepository)
public ContainerToContainerDTOMapper(IIconRepository iconRepository)
{
_tagDTOMapper = tagDTOMapper;
_iconRepository = iconRepository;
}

Expand All @@ -30,7 +27,6 @@ public virtual ContainerDTO MapFrom(IContainer container)
{
MapProperties(container, dto);
dto.ContainerType = container.ContainerType;
dto.Tags = container.Tags.MapAllUsing(_tagDTOMapper).ToRichList();
dto.Mode = container.Mode;
if (string.IsNullOrEmpty(dto.Icon))
dto.Icon = _iconRepository.IconFor(container);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using OSPSuite.Utility.Extensions;
using MoBi.Core.Repositories;
using MoBi.Core.Repositories;
using MoBi.Presentation.DTO;
using OSPSuite.Core.Domain;
using OSPSuite.Utility.Extensions;

namespace MoBi.Presentation.Mappers

{
public interface INeighborhoodToDTONeighborhoodMapper : IContainerToContainerDTOMapper
{
}
class NeighborhoodToDTONeighborhoodMapper :ContainerToContainerDTOMapper, INeighborhoodToDTONeighborhoodMapper

class NeighborhoodToDTONeighborhoodMapper : ContainerToContainerDTOMapper, INeighborhoodToDTONeighborhoodMapper
{
private readonly ITransportToTransportDTOMapper _transportToTransportDTOMapper;

public NeighborhoodToDTONeighborhoodMapper(ITagToTagDTOMapper tagDTOMapper, ITransportToTransportDTOMapper transportToTransportDTOMapper, IIconRepository iconRepository)
: base(tagDTOMapper,iconRepository)
public NeighborhoodToDTONeighborhoodMapper(ITransportToTransportDTOMapper transportToTransportDTOMapper, IIconRepository iconRepository)
: base(iconRepository)
{
_transportToTransportDTOMapper = transportToTransportDTOMapper;
}
Expand All @@ -23,15 +24,9 @@ public override ContainerDTO MapFrom(IContainer input)
{
var dto = MapContainer(input, new NeighborhoodDTO());
var neighborhood = input as INeighborhood;
var tranports = neighborhood.GetAllChildren<ITransport>();
dto.Transports = tranports.MapAllUsing(_transportToTransportDTOMapper);
var transports = neighborhood.GetAllChildren<ITransport>();
dto.Transports = transports.MapAllUsing(_transportToTransportDTOMapper);
return dto;
}
}






}
13 changes: 4 additions & 9 deletions src/MoBi.Presentation/Mappers/ParameterToParameterDTOMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using OSPSuite.Core.Domain.Repositories;
using OSPSuite.Core.Domain.Services;
using OSPSuite.Presentation.DTO;
using OSPSuite.Utility.Extensions;

namespace MoBi.Presentation.Mappers
{
Expand All @@ -15,21 +14,18 @@ public interface IParameterToParameterDTOMapper : OSPSuite.Presentation.Mappers.
public class ParameterToParameterDTOMapper : ObjectBaseToObjectBaseDTOMapperBase, IParameterToParameterDTOMapper
{
private readonly IFormulaToFormulaBuilderDTOMapper _formulaToDTOFormulaBuilderMapper;
private readonly ITagToTagDTOMapper _tagMapper;
private readonly IGroupRepository _groupRepository;
private readonly IFavoriteRepository _favoriteRepository;
private readonly IEntityPathResolver _entityPathResolver;
private readonly IPathToPathElementsMapper _pathToPathElementsMapper;

public ParameterToParameterDTOMapper(IFormulaToFormulaBuilderDTOMapper formulaToDTOFormulaBuilderMapper,
ITagToTagDTOMapper tagMapper,
IGroupRepository groupRepository,
IFavoriteRepository favoriteRepository,
IEntityPathResolver entityPathResolver,
public ParameterToParameterDTOMapper(IFormulaToFormulaBuilderDTOMapper formulaToDTOFormulaBuilderMapper,
IGroupRepository groupRepository,
IFavoriteRepository favoriteRepository,
IEntityPathResolver entityPathResolver,
IPathToPathElementsMapper pathToPathElementsMapper)
{
_formulaToDTOFormulaBuilderMapper = formulaToDTOFormulaBuilderMapper;
_tagMapper = tagMapper;
_groupRepository = groupRepository;
_favoriteRepository = favoriteRepository;
_entityPathResolver = entityPathResolver;
Expand All @@ -50,7 +46,6 @@ public IParameterDTO MapFrom(IParameter parameter)
dto.IsAdvancedParameter = !parameter.Visible;
dto.CanBeVariedInPopulation = parameter.CanBeVariedInPopulation;
dto.PathElements = _pathToPathElementsMapper.MapFrom(parameter);
dto.Tags = parameter.Tags.MapAllUsing(_tagMapper).ToRichList();
var parameterPath = _entityPathResolver.ObjectPathFor(parameter);
dto.IsFavorite = _favoriteRepository.Contains(parameterPath);

Expand Down
58 changes: 24 additions & 34 deletions src/MoBi.Presentation/Presenter/EditContainerPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using MoBi.Presentation.DTO;
using MoBi.Presentation.Mappers;
using MoBi.Presentation.Presenter.BasePresenter;
using MoBi.Presentation.Tasks;
using MoBi.Presentation.Tasks.Edit;
using MoBi.Presentation.Views;
using OSPSuite.Core.Domain;
Expand All @@ -23,8 +22,6 @@ public interface IEditContainerPresenter : ICanEditPropertiesPresenter, IPresent
{
EditParameterMode EditMode { set; }
bool ReadOnly { set; }
void AddNewTag();
void RemoveTag(TagDTO tagDTO);
void SetInitialName(string initialName);
string ContainerModeDisplayFor(ContainerMode mode);
IEnumerable<ContainerMode> AllContainerModes();
Expand All @@ -39,20 +36,26 @@ public class EditContainerPresenter : AbstractEntityEditPresenter<IEditContainer
private readonly IEditTaskForContainer _editTasks;
private ContainerDTO _containerDTO;
private readonly IMoBiContext _context;
private readonly IEntityTask _entityTask;
private readonly ITagsPresenter _tagsPresenter;
private readonly IEditParametersInContainerPresenter _editParametersInContainerPresenter;

public EditContainerPresenter(IEditContainerView view, IContainerToContainerDTOMapper containerToDtoContainerMapper, IEditTaskForContainer editTasks,
IEditParametersInContainerPresenter editParametersInContainerPresenter, IMoBiContext context, IEntityTask entityTask)
public EditContainerPresenter(
IEditContainerView view,
IContainerToContainerDTOMapper containerToDtoContainerMapper,
IEditTaskForContainer editTasks,
IEditParametersInContainerPresenter editParametersInContainerPresenter,
IMoBiContext context,
ITagsPresenter tagsPresenter)
: base(view)
{
_containerToDTOContainerMapper = containerToDtoContainerMapper;
_entityTask = entityTask;
_context = context;
_tagsPresenter = tagsPresenter;
_editParametersInContainerPresenter = editParametersInContainerPresenter;
_editTasks = editTasks;
_view.SetParameterView(editParametersInContainerPresenter.BaseView);
AddSubPresenters(_editParametersInContainerPresenter);
_view.AddParameterView(editParametersInContainerPresenter.BaseView);
_view.AddTagsView(_tagsPresenter.BaseView);
AddSubPresenters(_editParametersInContainerPresenter, _tagsPresenter);
initParameterListPresenter();
}

Expand Down Expand Up @@ -105,14 +108,15 @@ public IEnumerable<ContainerType> AllContainerTypes()

public IBuildingBlock BuildingBlock
{
get { return _editParametersInContainerPresenter.BuildingBlock; }
set { _editParametersInContainerPresenter.BuildingBlock = value; }
get => _editParametersInContainerPresenter.BuildingBlock;
set
{
_editParametersInContainerPresenter.BuildingBlock = value;
_tagsPresenter.BuildingBlock = value;
}
}

public IFormulaCache FormulaCache
{
get { return BuildingBlock.FormulaCache; }
}
public IFormulaCache FormulaCache => BuildingBlock.FormulaCache;

public void SelectParameter(IParameter childParameter)
{
Expand All @@ -137,39 +141,25 @@ public override void Edit(IContainer container, IEnumerable<IObjectBase> existin
_containerDTO.AddUsedNames(_editTasks.GetForbiddenNamesWithoutSelf(container, existingObjectsInParent));
_editParametersInContainerPresenter.Edit(_container);
_view.BindTo(_containerDTO);
_tagsPresenter.Edit(container);
_view.ContainerPropertiesEditable = !container.IsMoleculeProperties();
}

public override object Subject
{
get { return _container; }
}
public override object Subject => _container;

public EditParameterMode EditMode
{
set { _editParametersInContainerPresenter.EditMode = value; }
set => _editParametersInContainerPresenter.EditMode = value;
}

public bool ReadOnly
{
set { _view.ReadOnly = value; }
}

public void AddNewTag()
{
//TODO
AddCommand(_entityTask.AddNewTagTo(_container, BuildingBlock));
}

public void RemoveTag(TagDTO tagDTO)
{
AddCommand(_entityTask.RemoveTagFrom(tagDTO, _container, BuildingBlock));
_containerDTO.Tags.Remove(tagDTO);
set => _view.ReadOnly = value;
}

public void SetInitialName(string initialName)
{
SetPropertyValueFromView(_container.PropertyName(x => x.Name), initialName, String.Empty);
SetPropertyValueFromView(_container.PropertyName(x => x.Name), initialName, string.Empty);
_containerDTO.Name = initialName;
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/MoBi.Presentation/Presenter/EditEventGroupPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class EditEventGroupPresenter : AbstractEntityEditPresenter<IEditEventG
private readonly IEventGroupBuilderToEventGroupBuilderDTOMapper _eventGroupBuilderDTOMapper;
private readonly IMoBiContext _context;
private readonly IDescriptorConditionListPresenter<IEventGroupBuilder> _descriptorConditionListPresenter;
private readonly ITagsPresenter _tagsPresenter;
private readonly IEditParametersInContainerPresenter _parametersInContainerPresenter;
private IBuildingBlock _buildingBlock;

Expand All @@ -34,17 +35,20 @@ public EditEventGroupPresenter(
IEditParametersInContainerPresenter parametersInContainerPresenter,
IEventGroupBuilderToEventGroupBuilderDTOMapper eventGroupBuilderDTOMapper,
IMoBiContext context,
IDescriptorConditionListPresenter<IEventGroupBuilder> descriptorConditionListPresenter)
IDescriptorConditionListPresenter<IEventGroupBuilder> descriptorConditionListPresenter,
ITagsPresenter tagsPresenter)
: base(view)
{
_descriptorConditionListPresenter = descriptorConditionListPresenter;
_tagsPresenter = tagsPresenter;
_context = context;
_eventGroupBuilderDTOMapper = eventGroupBuilderDTOMapper;
_parametersInContainerPresenter = parametersInContainerPresenter;
_view.AddParametersView(parametersInContainerPresenter.BaseView);
_view.AddDescriptorConditionListView(_descriptorConditionListPresenter.View);
_view.AddTagsView(_tagsPresenter.View);
_editTask = editTask;
AddSubPresenters(_parametersInContainerPresenter, _descriptorConditionListPresenter);
AddSubPresenters(_parametersInContainerPresenter, _descriptorConditionListPresenter, _tagsPresenter);
}

public override void Edit(IEventGroupBuilder eventGroupBuilder, IEnumerable<IObjectBase> existingObjectsInParent)
Expand All @@ -55,6 +59,7 @@ public override void Edit(IEventGroupBuilder eventGroupBuilder, IEnumerable<IObj
var dto = _eventGroupBuilderDTOMapper.MapFrom(_eventGroupBuilder);
dto.AddUsedNames(_editTask.GetForbiddenNamesWithoutSelf(eventGroupBuilder, existingObjectsInParent));
_view.BindTo(dto);
_tagsPresenter.Edit(eventGroupBuilder);
_descriptorConditionListPresenter.Edit(eventGroupBuilder,x => x.SourceCriteria, _buildingBlock);
}

Expand Down Expand Up @@ -89,6 +94,7 @@ public IBuildingBlock BuildingBlock
{
_buildingBlock = value;
_parametersInContainerPresenter.BuildingBlock = value;
_tagsPresenter.BuildingBlock = value;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/MoBi.Presentation/Presenter/TagsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace MoBi.Presentation.Presenter
{
//AppConstants.Captions.ContainerTags.FormatForLabel

public interface ITagsPresenter : IEditPresenter<IEntity>, IPresenter<ITagsView>
{
void AddNewTag();
Expand Down
3 changes: 2 additions & 1 deletion src/MoBi.Presentation/Views/IEditContainerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace MoBi.Presentation.Views
public interface IEditContainerView : IView<IEditContainerPresenter>, IActivatableView
{
void BindTo(ContainerDTO dto);
void SetParameterView(IView view);
void AddParameterView(IView view);
void AddTagsView(IView view);
bool ReadOnly { get; set; }
bool ContainerPropertiesEditable { get; set; }
void ShowParameters();
Expand Down
1 change: 1 addition & 0 deletions src/MoBi.Presentation/Views/IEditEventGroupView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public interface IEditEventGroupView : IView<IEditEventGroupPresenter>, IActivat
bool EnableDescriptors { get; set; }
void ShowParameters();
void AddDescriptorConditionListView(IView view);
void AddTagsView(IView view);
}
}
1 change: 1 addition & 0 deletions src/MoBi.UI/Properties/licenses.licx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v20.1, Version=20.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v20.1, Version=20.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ButtonEdit, DevExpress.XtraEditors.v20.1, Version=20.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
Loading

0 comments on commit 43b641e

Please sign in to comment.