Skip to content

Commit

Permalink
Merge pull request #44 from LBHackney-IT/remove-patches
Browse files Browse the repository at this point in the history
Remove Asset.Patches[]
  • Loading branch information
humulla authored Nov 16, 2023
2 parents fea61a7 + 8f17c34 commit 753cb45
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.11.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Hackney.Shared.PatchesAndAreas" Version="0.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
Expand Down
5 changes: 2 additions & 3 deletions Hackney.Shared.Asset/Boundary/Response/AssetResponseObject.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Hackney.Shared.Asset.Domain;
using Hackney.Shared.PatchesAndAreas.Boundary.Response;
using System;
using System.Collections.Generic;

namespace Hackney.Shared.Asset.Boundary.Response
{
public class AssetResponseObject
{
public Guid Id { get; set; }
public string AssetId { get; set; }
public Guid? AreaId { get; set; }
public Guid? PatchId { get; set; }
public AssetType AssetType { get; set; }
public RentGroup? RentGroup { get; set; }
public string RootAsset { get; set; }
Expand All @@ -20,7 +20,6 @@ public class AssetResponseObject
public AssetManagement AssetManagement { get; set; }
public AssetCharacteristicsResponse AssetCharacteristics { get; set; }
public AssetTenureResponseObject Tenure { get; set; }
public List<PatchesResponseObject?> Patches { get; set; }
public int? VersionNumber { get; set; }
}
}
5 changes: 2 additions & 3 deletions Hackney.Shared.Asset/Domain/Asset.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Hackney.Shared.PatchesAndAreas.Domain;
using System;
using System.Collections.Generic;

Expand All @@ -8,6 +7,8 @@ public class Asset
{
public Guid Id { get; set; }
public string AssetId { get; set; }
public Guid? AreaId { get; set; }
public Guid? PatchId { get; set; }
public AssetType AssetType { get; set; }
public RentGroup? RentGroup { get; set; }
public string RootAsset { get; set; }
Expand All @@ -21,8 +22,6 @@ public class Asset
public AssetCharacteristics AssetCharacteristics { get; set; }
public AssetTenure Tenure { get; set; }
public int? VersionNumber { get; set; }
public List<PatchEntity?> Patches { get; set; }

public static Asset Create(string id,
string assetId,
string assetType,
Expand Down
69 changes: 27 additions & 42 deletions Hackney.Shared.Asset/Factories/EntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

using Hackney.Shared.Asset.Domain;
using Hackney.Shared.Asset.Infrastructure;
using Hackney.Shared.PatchesAndAreas.Domain;
using Hackney.Shared.PatchesAndAreas.Factories;
using Hackney.Shared.PatchesAndAreas.Infrastructure;
using System.Collections.Generic;
using System.Linq;
using AssetDomain = Hackney.Shared.Asset.Domain.Asset;
Expand All @@ -20,6 +17,8 @@ public static AssetDomain ToDomain(this AssetDb databaseEntity)
{
Id = databaseEntity.Id,
AssetId = databaseEntity.AssetId,
AreaId = databaseEntity.AreaId,
PatchId = databaseEntity.PatchId,
AssetType = databaseEntity.AssetType,
RentGroup = databaseEntity.RentGroup,
RootAsset = databaseEntity.RootAsset,
Expand All @@ -31,8 +30,31 @@ public static AssetDomain ToDomain(this AssetDb databaseEntity)
AssetManagement = databaseEntity.AssetManagement,
AssetCharacteristics = databaseEntity.AssetCharacteristics.ToDomain(),
Tenure = databaseEntity.Tenure.ToDomain(),
VersionNumber = databaseEntity.VersionNumber,
Patches = databaseEntity.Patches?.ToDomain()
VersionNumber = databaseEntity.VersionNumber
};
}

public static AssetDb ToDatabase(this AssetDomain domain)
{
if (domain == null) return null;
return new AssetDb
{
Id = domain.Id,
AssetId = domain.AssetId,
AreaId = domain.AreaId,
PatchId = domain.PatchId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
IsActive = domain.IsActive,
ParentAssetIds = domain.ParentAssetIds,
BoilerHouseId = domain.BoilerHouseId,
AssetLocation = domain.AssetLocation,
AssetAddress = domain.AssetAddress,
AssetManagement = domain.AssetManagement,
AssetCharacteristics = domain.AssetCharacteristics.ToDatabase(),
Tenure = domain.Tenure.ToDatabase(),
VersionNumber = domain.VersionNumber,
};
}

Expand Down Expand Up @@ -143,36 +165,6 @@ public static AssetTenure ToDomain(this AssetTenureDb databaseEntity)
};
}

public static List<PatchEntity?> ToDomain(this IEnumerable<PatchesDb?> databaseEntity)
{
return databaseEntity.Select(p => p.ToDomain())
.ToList();

}

public static AssetDb ToDatabase(this AssetDomain domain)
{
if (domain == null) return null;
return new AssetDb
{
Id = domain.Id,
AssetId = domain.AssetId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
IsActive = domain.IsActive,
ParentAssetIds = domain.ParentAssetIds,
BoilerHouseId = domain.BoilerHouseId,
AssetLocation = domain.AssetLocation,
AssetAddress = domain.AssetAddress,
AssetManagement = domain.AssetManagement,
AssetCharacteristics = domain.AssetCharacteristics.ToDatabase(),
Tenure = domain.Tenure.ToDatabase(),
VersionNumber = domain.VersionNumber,
Patches = domain.Patches?.ToDatabase()
};
}

public static AssetTenureDb ToDatabase(this AssetTenure domain)
{
if (domain == null) return null;
Expand All @@ -186,12 +178,5 @@ public static AssetTenureDb ToDatabase(this AssetTenure domain)
};
}


public static List<PatchesDb?> ToDatabase(this IEnumerable<PatchEntity?> domain)
{
return domain.Select(p => p.ToDatabase())
.ToList();

}
}
}
12 changes: 2 additions & 10 deletions Hackney.Shared.Asset/Factories/ResponseFactory.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Hackney.Shared.Asset.Boundary.Response;
using Hackney.Shared.Asset.Domain;
using Hackney.Shared.PatchesAndAreas.Boundary.Response;
using Hackney.Shared.PatchesAndAreas.Domain;
using Hackney.Shared.PatchesAndAreas.Factories;
using System.Collections.Generic;
using System.Linq;
using AssetDomain = Hackney.Shared.Asset.Domain.Asset;
Expand All @@ -18,6 +15,8 @@ public static AssetResponseObject ToResponse(this AssetDomain domain)
{
Id = domain.Id,
AssetId = domain.AssetId,
AreaId = domain.AreaId,
PatchId = domain.PatchId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
Expand All @@ -29,7 +28,6 @@ public static AssetResponseObject ToResponse(this AssetDomain domain)
AssetManagement = domain.AssetManagement,
AssetCharacteristics = domain.AssetCharacteristics.ToResponse(),
Tenure = domain.Tenure.ToResponse(),
Patches = domain.Patches?.ToResponse(),
VersionNumber = domain.VersionNumber
};
}
Expand Down Expand Up @@ -93,11 +91,5 @@ public static AssetTenureResponseObject ToResponse(this AssetTenure domain)
IsActive = domain.IsActive
};
}

public static List<PatchesResponseObject?> ToResponse(this IEnumerable<PatchEntity?> domainList)
{
if (null == domainList) return new List<PatchesResponseObject?>();
return domainList.Select(domain => domain.ToResponse()).ToList();
}
}
}
1 change: 0 additions & 1 deletion Hackney.Shared.Asset/Hackney.Shared.Asset.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<ItemGroup>
<PackageReference Include="FluentValidation" Version="10.3.3" />
<PackageReference Include="Hackney.Core.DynamoDb" Version="1.79.0" />
<PackageReference Include="Hackney.Shared.PatchesAndAreas" Version="0.11.0" />
<PackageReference Include="Hackney.Shared.Tenure" Version="0.14.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
Expand Down
114 changes: 58 additions & 56 deletions Hackney.Shared.Asset/Infrastructure/AssetDb.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@

using Amazon.DynamoDBv2.DataModel;
using Hackney.Shared.Asset.Domain;
using Hackney.Core.DynamoDb.Converters;
using System;
using Hackney.Shared.PatchesAndAreas.Infrastructure;
using System.Collections.Generic;

namespace Hackney.Shared.Asset.Infrastructure
{
[DynamoDBTable("Assets", LowerCamelCaseProperties = true)]
public class AssetDb
{
[DynamoDBHashKey]
public Guid Id { get; set; }

[DynamoDBProperty]
public string AssetId { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbEnumConverter<AssetType>))]
public AssetType AssetType { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbEnumConverter<RentGroup>))]
public RentGroup? RentGroup { get; set; }

[DynamoDBProperty]
public string RootAsset { get; set; }

[DynamoDBProperty]
public bool IsActive { get; set; }

[DynamoDBProperty]

using Amazon.DynamoDBv2.DataModel;
using Hackney.Shared.Asset.Domain;
using Hackney.Core.DynamoDb.Converters;
using System;
using System.Collections.Generic;

namespace Hackney.Shared.Asset.Infrastructure
{
[DynamoDBTable("Assets", LowerCamelCaseProperties = true)]
public class AssetDb
{
[DynamoDBHashKey]
public Guid Id { get; set; }

[DynamoDBProperty]
public string AssetId { get; set; }

[DynamoDBProperty]
public Guid? AreaId { get; set; }

[DynamoDBProperty]
public Guid? PatchId { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbEnumConverter<AssetType>))]
public AssetType AssetType { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbEnumConverter<RentGroup>))]
public RentGroup? RentGroup { get; set; }

[DynamoDBProperty]
public string RootAsset { get; set; }

[DynamoDBProperty]
public bool IsActive { get; set; }

[DynamoDBProperty]
public string ParentAssetIds { get; set; }

[DynamoDBProperty]
public string BoilerHouseId { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetLocation>))]
public AssetLocation AssetLocation { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetAddress>))]
public AssetAddress AssetAddress { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetManagement>))]
public AssetManagement AssetManagement { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetCharacteristicsDb>))]
public AssetCharacteristicsDb AssetCharacteristics { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetTenureDb>))]
public AssetTenureDb Tenure { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectListConverter<PatchesDb>))]
public List<PatchesDb?> Patches { get; set; }

[DynamoDBVersion]
public int? VersionNumber { get; set; }
}
[DynamoDBProperty]
public string BoilerHouseId { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetLocation>))]
public AssetLocation AssetLocation { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetAddress>))]
public AssetAddress AssetAddress { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetManagement>))]
public AssetManagement AssetManagement { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetCharacteristicsDb>))]
public AssetCharacteristicsDb AssetCharacteristics { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbObjectConverter<AssetTenureDb>))]
public AssetTenureDb Tenure { get; set; }

[DynamoDBVersion]
public int? VersionNumber { get; set; }
}
}

0 comments on commit 753cb45

Please sign in to comment.