Add converting beam shear analysis from DTOs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
|
||||
@@ -7,6 +8,11 @@ namespace DataAccess.DTOs
|
||||
public class FactoredCombinationPropertyFromDTOConvertStrategy : ConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
|
||||
|
||||
public FactoredCombinationPropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override FactoredCombinationProperty GetNewItem(FactoredCombinationPropertyDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FactoredForceTupleFromDTOConvertStrategy : ConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO>
|
||||
{
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> tupleConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationConvertStrategy;
|
||||
|
||||
public FactoredForceTupleFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy)
|
||||
: base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override FactoredForceTuple GetNewItem(FactoredForceTupleDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
CheckObjects(source);
|
||||
InitializeStrategies();
|
||||
return GetNewFactoredTuple(source);
|
||||
}
|
||||
|
||||
private FactoredForceTuple GetNewFactoredTuple(FactoredForceTupleDTO source)
|
||||
{
|
||||
if (source.ForceTuple is not ForceTupleDTO forceTupleDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ForceTuple));
|
||||
}
|
||||
if (source.CombinationProperty is not FactoredCombinationPropertyDTO combinationPropertyDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ForceTuple));
|
||||
}
|
||||
NewItem = new(source.Id)
|
||||
{
|
||||
ForceTuple = tupleConvertStrategy.Convert(forceTupleDTO),
|
||||
CombinationProperty = combinationConvertStrategy.Convert(combinationPropertyDTO)
|
||||
};
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private static void CheckObjects(FactoredForceTupleDTO source)
|
||||
{
|
||||
CheckObject.IsNull(source);
|
||||
CheckObject.IsNull(source.ForceTuple);
|
||||
CheckObject.IsNull(source.CombinationProperty);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>
|
||||
(this, new ForceTupleFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
|
||||
(this, new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
|
||||
pointConvertStrategy = new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace DataAccess.DTOs
|
||||
updateStrategy ??= new ForceFactoredListUpdateStrategy();
|
||||
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceTupleFromDTOConvertStrategy : ConvertStrategy<ForceTuple, ForceTupleDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
private IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy(IUpdateStrategy<IForceTuple> updateStrategy)
|
||||
public ForceTupleFromDTOConvertStrategy()
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
public ForceTupleFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ForceTuple GetNewItem(ForceTupleDTO source)
|
||||
{
|
||||
updateStrategy ??= new ForceTupleUpdateStrategy();
|
||||
ForceTuple newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
|
||||
Reference in New Issue
Block a user