Fix removing primitives
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public enum ConvertDirection
|
||||
{
|
||||
|
||||
@@ -11,21 +11,18 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<CurvatureCalculatorInputData, CurvatureCalculatorInputDataDTO>
|
||||
{
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IProcessLogic<IHasForcesAndPrimitives> forcesAndPrimitivesProcessLogic;
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<DeflectionFactor, DeflectionFactorDTO> deflectionConvertStrategy;
|
||||
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForcesAndPrimitivesProcessLogic => forcesAndPrimitivesProcessLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
private IConvertStrategy<DeflectionFactor, DeflectionFactorDTO> DeflectionConvertStrategy => deflectionConvertStrategy ??= new DeflectionFactorFromDTOConvertStrategy(this);
|
||||
public CurvatureCalculatorInputDataFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
private IHasPrimitivesProcessLogic PrimitivesProcessLogic => primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IHasForceActionsProcessLogic ActionsProcessLogic => actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
private IConvertStrategy<DeflectionFactor, DeflectionFactorDTO> DeflectionConvertStrategy => deflectionConvertStrategy ??= new DeflectionFactorFromDTOConvertStrategy(this);
|
||||
public override CurvatureCalculatorInputData GetNewItem(CurvatureCalculatorInputDataDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
if (source.DeflectionFactor is not DeflectionFactorDTO deflectionFactorDTO)
|
||||
@@ -33,22 +30,16 @@ namespace DataAccess.DTOs
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.DeflectionFactor) + ": deflection factor");
|
||||
}
|
||||
NewItem.DeflectionFactor = DeflectionConvertStrategy.Convert(deflectionFactorDTO);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
ProcessForcesAndPrimitives(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
|
||||
private void ProcessForcesAndPrimitives(IHasForcesAndPrimitives source)
|
||||
{
|
||||
PrimitivesProcessLogic.Source = source;
|
||||
PrimitivesProcessLogic.Target = NewItem;
|
||||
PrimitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
ActionsProcessLogic.Source = source;
|
||||
ActionsProcessLogic.Target = NewItem;
|
||||
ActionsProcessLogic.Process();
|
||||
ForcesAndPrimitivesProcessLogic.Source = source;
|
||||
ForcesAndPrimitivesProcessLogic.Target = NewItem;
|
||||
ForcesAndPrimitivesProcessLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,11 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<CurvatureCalculatorInputDataDTO, ICurvatureCalculatorInputData>
|
||||
{
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IProcessLogic<IHasForcesAndPrimitives> actionsProcessLogic;
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<DeflectionFactorDTO, IDeflectionFactor> deflectionConvertStrategy;
|
||||
|
||||
private IHasPrimitivesProcessLogic PrimitivesProcessLogic => primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
private IHasForceActionsProcessLogic ActionsProcessLogic => actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForceAndPrimitivesLogic => actionsProcessLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorInputDataUpdateStrategy() { UpdateChildren = false};
|
||||
private IConvertStrategy<DeflectionFactorDTO, IDeflectionFactor> DeflectionConvertStrategy => deflectionConvertStrategy ??= new DeflectionFactorToDTOConvertStrategy(this);
|
||||
|
||||
@@ -23,25 +21,19 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override CurvatureCalculatorInputDataDTO GetNewItem(ICurvatureCalculatorInputData source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
NewItem.DeflectionFactor = DeflectionConvertStrategy.Convert(source.DeflectionFactor);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
private void ProcessActions(IHasForcesAndPrimitives source)
|
||||
{
|
||||
PrimitivesProcessLogic.Source = source;
|
||||
PrimitivesProcessLogic.Target = NewItem;
|
||||
PrimitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
ActionsProcessLogic.Source = source;
|
||||
ActionsProcessLogic.Target = NewItem;
|
||||
ActionsProcessLogic.Process();
|
||||
ForceAndPrimitivesLogic.Source = source;
|
||||
ForceAndPrimitivesLogic.Target = NewItem;
|
||||
ForceAndPrimitivesLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForcesAndPrimitivesProcessLogic : IProcessLogic<IHasForcesAndPrimitives>
|
||||
{
|
||||
private ConvertDirection convertDirection;
|
||||
private IProcessLogic<IHasForceActions> forcesLogic;
|
||||
private IProcessLogic<IHasPrimitives> primitivesLogic;
|
||||
private IProcessLogic<IHasForceActions> ForcesLogic => forcesLogic ??= new HasForceActionsProcessLogic(convertDirection) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
private IProcessLogic<IHasPrimitives> PrimitivesLogic => primitivesLogic ??=new HasPrimitivesProcessLogic(convertDirection) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IHasForcesAndPrimitives Source { get; set; }
|
||||
public IHasForcesAndPrimitives Target { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HasForcesAndPrimitivesProcessLogic(ConvertDirection convertDirection)
|
||||
{
|
||||
this.convertDirection = convertDirection;
|
||||
}
|
||||
|
||||
public HasForcesAndPrimitivesProcessLogic(
|
||||
ConvertDirection convertDirection,
|
||||
IProcessLogic<IHasForceActions> forcesLogic,
|
||||
IProcessLogic<IHasPrimitives> primitivesLogic)
|
||||
{
|
||||
this.convertDirection = convertDirection;
|
||||
this.forcesLogic = forcesLogic;
|
||||
this.primitivesLogic = primitivesLogic;
|
||||
}
|
||||
|
||||
public void Process()
|
||||
{
|
||||
Check();
|
||||
ProcessForces();
|
||||
ProcessPrimitives();
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
CheckObject.ThrowIfNull(ReferenceDictionary, ": reference dictionary");
|
||||
CheckObject.ThrowIfNull(Source, ": source object");
|
||||
CheckObject.ThrowIfNull(Target, ": target object");
|
||||
}
|
||||
|
||||
private void ProcessPrimitives()
|
||||
{
|
||||
PrimitivesLogic.Source = Source;
|
||||
PrimitivesLogic.Target = Target;
|
||||
PrimitivesLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessForces()
|
||||
{
|
||||
ForcesLogic.Source = Source;
|
||||
ForcesLogic.Target = Target;
|
||||
ForcesLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
@@ -6,12 +7,7 @@ namespace DataAccess.DTOs
|
||||
/// <summary>
|
||||
/// Logic for antities which have force actions
|
||||
/// </summary>
|
||||
public interface IHasForceActionsProcessLogic
|
||||
public interface IHasForceActionsProcessLogic : IProcessLogic<IHasForceActions>
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IHasForceActions Source { get; set; }
|
||||
IHasForceActions Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public interface IHasPrimitivesProcessLogic
|
||||
public interface IHasPrimitivesProcessLogic : IProcessLogic<IHasPrimitives>
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IHasPrimitives Source { get; set; }
|
||||
IHasPrimitives Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
17
DataAccess/DTOs/Converters/IProcessLogic.cs
Normal file
17
DataAccess/DTOs/Converters/IProcessLogic.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IProcessLogic<T>
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
T Source { get; set; }
|
||||
T Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,9 @@ using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -22,9 +14,12 @@ namespace DataAccess.DTOs
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished successfully";
|
||||
private CrossSectionRepository newRepository;
|
||||
private ICheckEntityLogic<ICrossSectionRepository> checkEntityLogic;
|
||||
private ICheckEntityLogic<ICrossSectionRepository> CheckEntityLogic => checkEntityLogic ??= new CrossSectionRepositoryCheckLogic() {Entity = oldRepository};
|
||||
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic(ConvertDirection.FromDTO);
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic(ConvertDirection.FromDTO);
|
||||
private IProcessLogic<IHasForcesAndPrimitives> forcesAndPrimitivesLogic;
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForcesAndPrimitivesLogic => forcesAndPrimitivesLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
private ICrossSectionRepository oldRepository;
|
||||
|
||||
public CrossSectionRepositoryFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
@@ -32,11 +27,17 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override CrossSectionRepository GetNewItem(ICrossSectionRepository source)
|
||||
{
|
||||
oldRepository = source;
|
||||
if (CheckEntityLogic.Check() == false)
|
||||
{
|
||||
TraceLogger.AddMessage(CheckEntityLogic.CheckResult, TraceLogStatuses.Error);
|
||||
TraceLogger.AddMessage("All calculators will be removed", TraceLogStatuses.Error);
|
||||
oldRepository.Calculators.Clear();
|
||||
}
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertStarted);
|
||||
newRepository = new(source.Id);
|
||||
ProcessMaterials(source);
|
||||
ProcessActions(source);
|
||||
ProcessPrimitives(source);
|
||||
ProcessForcesAndPrimitives(source);
|
||||
ProcessCalculators(source);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertFinished);
|
||||
return newRepository;
|
||||
@@ -56,22 +57,12 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage("Calculators" + convertFinished);
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = newRepository;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
private void ProcessForcesAndPrimitives(IHasForcesAndPrimitives source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = newRepository;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
ForcesAndPrimitivesLogic.Source = source;
|
||||
ForcesAndPrimitivesLogic.Target = newRepository;
|
||||
ForcesAndPrimitivesLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessMaterials(IHasHeadMaterials source)
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace DataAccess.DTOs
|
||||
public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
|
||||
{
|
||||
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
|
||||
private ICheckEntityLogic<ICrossSectionRepository> checkEntityLogic;
|
||||
private ICrossSectionRepository oldRepository;
|
||||
|
||||
private ICheckEntityLogic<ICrossSectionRepository> CheckEntityLogic => checkEntityLogic ??= new CrossSectionRepositoryCheckLogic() { Entity = oldRepository };
|
||||
|
||||
|
||||
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
|
||||
@@ -30,6 +34,13 @@ namespace DataAccess.DTOs
|
||||
|
||||
public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source)
|
||||
{
|
||||
oldRepository = source;
|
||||
if (CheckEntityLogic.Check() == false)
|
||||
{
|
||||
TraceLogger.AddMessage(CheckEntityLogic.CheckResult, TraceLogStatuses.Error);
|
||||
TraceLogger.AddMessage("All calculators will be removed", TraceLogStatuses.Error);
|
||||
oldRepository.Calculators.Clear();
|
||||
}
|
||||
Check();
|
||||
InitializeStrategies();
|
||||
try
|
||||
|
||||
@@ -11,22 +11,35 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagramCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<ValueDiagramEntity, ValueDiagramEntityDTO> diagramConvertStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IProcessLogic<IHasForcesAndPrimitives> forcesAndPrimitivesLogic;
|
||||
private IConvertStrategy<Accuracy, AccuracyDTO> accuracyConvertStrategy;
|
||||
private IUpdateStrategy<IValueDiagramCalculatorInputData> UpdateStrategy => updateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
private IConvertStrategy<ValueDiagramEntity, ValueDiagramEntityDTO> DiagramConvertStrategy => diagramConvertStrategy ??= new ValueDiagramEntityFromDTOConvertStrategy(this);
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForcesAndPrimitivesLogic => forcesAndPrimitivesLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IConvertStrategy<Accuracy, AccuracyDTO> AccuracyConvertStrategy => accuracyConvertStrategy ??= new AccuracyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
|
||||
public ValueDiagramCalculatorInputDataFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public ValueDiagramCalculatorInputDataFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IValueDiagramCalculatorInputData> updateStrategy,
|
||||
IConvertStrategy<ValueDiagramEntity, ValueDiagramEntityDTO> diagramConvertStrategy,
|
||||
IProcessLogic<IHasForcesAndPrimitives> forcesAndPrimitivesLogic,
|
||||
IConvertStrategy<Accuracy, AccuracyDTO> accuracyConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.diagramConvertStrategy = diagramConvertStrategy;
|
||||
this.forcesAndPrimitivesLogic = forcesAndPrimitivesLogic;
|
||||
this.accuracyConvertStrategy = accuracyConvertStrategy;
|
||||
}
|
||||
|
||||
public override ValueDiagramCalculatorInputData GetNewItem(ValueDiagramCalculatorInputDataDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
InitializeStrategies();
|
||||
updateStrategy.Update(NewItem, source);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
ProcessForcesAndPrimitives(source);
|
||||
NewItem.Diagrams.Clear();
|
||||
foreach (var diagram in source.Diagrams)
|
||||
{
|
||||
@@ -34,35 +47,16 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(diagram));
|
||||
}
|
||||
NewItem.Diagrams.Add(diagramConvertStrategy.Convert(diagramDTO));
|
||||
NewItem.Diagrams.Add(DiagramConvertStrategy.Convert(diagramDTO));
|
||||
}
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
private void ProcessForcesAndPrimitives(IHasForcesAndPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
diagramConvertStrategy ??= new ValueDiagramEntityFromDTOConvertStrategy(this);
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
accuracyConvertStrategy ??= new AccuracyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
ForcesAndPrimitivesLogic.Source = source;
|
||||
ForcesAndPrimitivesLogic.Target = NewItem;
|
||||
ForcesAndPrimitivesLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagramCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<ValueDiagramEntityDTO, IValueDiagramEntity> diagramConvertStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IConvertStrategy<ValueDiagramEntityDTO, IValueDiagramEntity> DiagramConvertStrategy => diagramConvertStrategy ??= new ValueDiagramEntityToDTOConvertStrategy(this);
|
||||
private IProcessLogic<IHasForcesAndPrimitives> actionsProcessLogic;
|
||||
private IUpdateStrategy<IValueDiagramCalculatorInputData> UpdateStrategy => updateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ActionsProcessLogic => actionsProcessLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
|
||||
public ValueDiagramCalculatorInputDataToDTOConvertStrategy() : base()
|
||||
{
|
||||
@@ -24,41 +26,21 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
InitializeStrategies();
|
||||
updateStrategy.Update(NewItem, source);
|
||||
ProcessPrimitives(source);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
ProcessActions(source);
|
||||
NewItem.Diagrams.Clear();
|
||||
foreach (var diagram in source.Diagrams)
|
||||
{
|
||||
NewItem.Diagrams.Add(diagramConvertStrategy.Convert(diagram));
|
||||
NewItem.Diagrams.Add(DiagramConvertStrategy.Convert(diagram));
|
||||
}
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
private void ProcessActions(IHasForcesAndPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ValueDiagramCalculatorInputDataUpdateStrategy() { UpdateChildren = false};
|
||||
diagramConvertStrategy ??= new ValueDiagramEntityToDTOConvertStrategy(this);
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
ActionsProcessLogic.Source = source;
|
||||
ActionsProcessLogic.Target = NewItem;
|
||||
ActionsProcessLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user