Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BeamOS.Common.Application.Interfaces;

public interface ICommandHandler<TCommand, TResponse>
{
Task<TResponse> ExecuteAsync(TCommand command, CancellationToken ct = default);
}
16 changes: 16 additions & 0 deletions BeamOS.Common/BeamOS.Common.Domain/ValueObjects/GuidBasedId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using BeamOS.Common.Domain.Models;

namespace BeamOS.Common.Domain.ValueObjects;
public abstract class GuidBasedId(Guid? value) : BeamOSValueObject
{
public Guid Value { get; } = value ?? Guid.NewGuid();

protected override IEnumerable<object> GetEqualityComponents()
{
yield return this.Value;
}
public override string ToString()
{
return this.Value.ToString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ public Restraints(
bool canTranslateAlongX,
bool canTranslateAlongY,
bool canTranslateAlongZ,
bool canRotationAboutX,
bool canRotationAboutY,
bool canRotationAboutZ) : base(
bool canRotateAboutX,
bool canRotateAboutY,
bool canRotateAboutZ) : base(
canTranslateAlongX,
canTranslateAlongY,
canTranslateAlongZ,
canRotationAboutX,
canRotationAboutY,
canRotationAboutZ)
canRotateAboutX,
canRotateAboutY,
canRotateAboutZ)
{
}

public bool CanTranslateAlongX => this.AlongX;
public bool CanTranslateAlongY => this.AlongY;
public bool CanTranslateAlongZ => this.AlongZ;
public bool CanRotationAboutX => this.AboutX;
public bool CanRotationAboutY => this.AboutY;
public bool CanRotationAboutZ => this.AboutZ;
public bool CanRotateAboutX => this.AboutX;
public bool CanRotateAboutY => this.AboutY;
public bool CanRotateAboutZ => this.AboutZ;
public static Restraints Free { get; } = new(true, true, true, true, true, true);
public static Restraints Fixed { get; } = new(false, false, false, false, false, false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="5.19.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BeamOS.DirectStiffnessMethod.Application\BeamOS.DirectStiffnessMethod.Application.csproj" />
<ProjectReference Include="..\BeamOS.DirectStiffnessMethod.Contracts\BeamOS.DirectStiffnessMethod.Contracts.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BeamOS.DirectStiffnessMethod.Domain\BeamOS.DirectStiffnessMethod.Domain.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Commands\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BeamOS.DirectStiffnessMethod.Contracts;

public class Class1
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class AnalyticalModel : BeamOSEntity<AnalyticalModelId>
public AnalyticalModel(
AnalyticalModelId id,
UnitSettings unitSettings
//List<AnalyticalNodeId> nodeIds,
//List<Element1DId> element1DIds
) : base(id)
{
this.UnitSettings = unitSettings;
Expand All @@ -20,8 +18,6 @@ UnitSettings unitSettings

public static AnalyticalModel Create(
UnitSettings unitSettings
//List<AnalyticalNodeId> nodeIds,
//List<Element1DId> element1DIds
)
{
//return new(AnalyticalModelId.CreateUnique(), unitSettings, nodeIds, element1DIds);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using BeamOS.Common.Domain.Enums;
using BeamOS.Common.Domain.Models;
using BeamOS.Common.Domain.ValueObjects;
using BeamOS.DirectStiffnessMethod.Domain.AnalyticalModelAggregate.ValueObjects;
using BeamOS.DirectStiffnessMethod.Domain.AnalyticalNodeAggregate.ValueObjects;
using BeamOS.DirectStiffnessMethod.Domain.Common.ValueObjects;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using UnitsNet;
using UnitsNet.Units;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\BeamOS.Common\BeamOS.Common.ValueObjects\BeamOS.Common.Domain.csproj" />
<ProjectReference Include="..\..\BeamOS.Common\BeamOS.Common.Domain\BeamOS.Common.Domain.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="5.19.1" />
<PackageReference Include="Riok.Mapperly" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BeamOS.PhysicalModel.Application\BeamOS.PhysicalModel.Application.csproj" />
<ProjectReference Include="..\BeamOS.PhysicalModel.Contracts\BeamOS.PhysicalModel.Contracts.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using BeamOS.PhysicalModel.Api.Mappers;
using BeamOS.PhysicalModel.Application.Models.Commands;
using BeamOS.PhysicalModel.Contracts;
using BeamOS.PhysicalModel.Domain.AnalyticalModelAggregate;
using FastEndpoints;

namespace BeamOS.PhysicalModel.Api.Endpoints;

public class CreateModelEndpoint(CreateModelCommandHandler createModelCommandHandler) : Endpoint<CreateModelRequest, ModelResponse>
{
public override void Configure()
{
this.Post("model");
this.AllowAnonymous();
}

public override async Task HandleAsync(CreateModelRequest req, CancellationToken ct)
{
CreateModelCommand command = req.ToCommand();

AnalyticalModel model = await createModelCommandHandler.ExecuteAsync(command, ct);

ModelResponse response = model.ToResponse();

await this.SendAsync(response, cancellation: ct);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using BeamOS.PhysicalModel.Api.Mappers;
using BeamOS.PhysicalModel.Application.Models.Commands;
using BeamOS.PhysicalModel.Application.Nodes.Commands;
using BeamOS.PhysicalModel.Contracts.Nodes;
using BeamOS.PhysicalModel.Domain.AnalyticalNodeAggregate;
using FastEndpoints;

namespace BeamOS.PhysicalModel.Api.Endpoints;

public class CreateNodeEndpoint(CreateNodeCommandHandler createNodeCommandHandler) : Endpoint<CreateNodeRequest, NodeResponse>
{
public override void Configure()
{
this.Post("node");
this.AllowAnonymous();
this.Summary(s => s.ExampleRequest = new CreateNodeRequest(
"00000000-0000-0000-0000-000000000000",
0.0,
0.0,
10.0,
"Foot",
new RestraintsRequest(
false,
false,
false,
false,
false,
false)));
}

public override async Task HandleAsync(CreateNodeRequest req, CancellationToken ct)
{
CreateNodeCommand command = req.ToCommand();

AnalyticalNode node = await createNodeCommandHandler.ExecuteAsync(command, ct);

NodeResponse response = node.ToResponse();
await this.SendAsync(response, cancellation: ct);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BeamOS.PhysicalModel.Contracts;
using Riok.Mapperly.Abstractions;

namespace BeamOS.PhysicalModel.Application.Models.Commands;

[Mapper]
public static partial class CreateModelCommandMapper
{
public static partial CreateModelCommand ToCommand(this CreateModelRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BeamOS.PhysicalModel.Application.Nodes.Commands;
using BeamOS.PhysicalModel.Contracts.Nodes;
using Riok.Mapperly.Abstractions;

namespace BeamOS.PhysicalModel.Application.Models.Commands;

[Mapper]
public static partial class CreateNodeCommandMapper
{
public static partial CreateNodeCommand ToCommand(this CreateNodeRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BeamOS.PhysicalModel.Contracts;
using BeamOS.PhysicalModel.Domain.AnalyticalModelAggregate;
using Riok.Mapperly.Abstractions;

namespace BeamOS.PhysicalModel.Api.Mappers;
[Mapper]
public static partial class ModelResponseMapper
{
public static partial ModelResponse ToResponse(this AnalyticalModel model);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BeamOS.PhysicalModel.Contracts.Nodes;
using BeamOS.PhysicalModel.Domain.AnalyticalNodeAggregate;
using Riok.Mapperly.Abstractions;

namespace BeamOS.PhysicalModel.Api.Mappers;
[Mapper]
public static partial class NodeResponseMapper
{
public static partial NodeResponse ToResponse(this AnalyticalNode model);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Folder Include="Models\Common\" />
<Folder Include="Models\Queries\" />
<Folder Include="Nodes\Common\" />
<Folder Include="Nodes\Queries\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints.Messaging.Core" Version="5.19.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Riok.Mapperly" Version="3.2.0" />
<PackageReference Include="UnitsNet" Version="5.35.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\BeamOS.Common\BeamOS.Common.Application\BeamOS.Common.Application.csproj" />
<ProjectReference Include="..\BeamOS.PhysicalModel.Domain\BeamOS.PhysicalModel.Domain.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using BeamOS.PhysicalModel.Application.Models.Commands;
using BeamOS.PhysicalModel.Application.Nodes.Commands;
using Microsoft.Extensions.DependencyInjection;

namespace BeamOS.PhysicalModel.Application;
public static class DependencyInjection
{
public static IServiceCollection AddPhysicalModelApplication(this IServiceCollection services)
{
_ = services.AddTransient<CreateModelCommandHandler>();
_ = services.AddTransient<CreateNodeCommandHandler>();
return services;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using UnitsNet.Units;

namespace BeamOS.PhysicalModel.Application.Models.Commands;

public record CreateModelCommand(
string Name,
string Description,
AnalyticalModelSettingsCommand Settings);

public record AnalyticalModelSettingsCommand(
UnitSettingsCommand UnitSettings);

public record UnitSettingsCommand(
LengthUnit LengthUnit,
AreaUnit AreaUnit,
VolumeUnit VolumeUnit,
ForceUnit ForceUnit,
ForcePerLengthUnit ForcePerLengthUnit,
TorqueUnit TorqueUnit);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BeamOS.Common.Application.Interfaces;
using BeamOS.PhysicalModel.Domain.AnalyticalModelAggregate;
using Riok.Mapperly.Abstractions;

namespace BeamOS.PhysicalModel.Application.Models.Commands;

public class CreateModelCommandHandler : ICommandHandler<CreateModelCommand, AnalyticalModel>
{
public async Task<AnalyticalModel> ExecuteAsync(CreateModelCommand command, CancellationToken ct = default)
{
await Task.CompletedTask;

AnalyticalModel model = command.ToDomainObject();

// TODO : persist model

return model;
}
}

[Mapper]
public static partial class CreateModelCommandMapper
{
public static partial AnalyticalModel ToDomainObject(this CreateModelCommand command);
}
Loading