Skip to content

Commit

Permalink
Merge branch 'PSP-9710' of https://github.com/stairaku/PSP into PSP-9710
Browse files Browse the repository at this point in the history
  • Loading branch information
stairaku committed Dec 23, 2024
2 parents 4a93957 + aaf3c43 commit 0b97e70
Show file tree
Hide file tree
Showing 299 changed files with 57,807 additions and 17,946 deletions.
4 changes: 2 additions & 2 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.7.0-95.17</Version>
<AssemblyVersion>5.7.0.95</AssemblyVersion>
<Version>5.7.0-96.3</Version>
<AssemblyVersion>5.7.0.96</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>{16BC0468-78F6-4C91-87DA-7403C919E646}</ProjectGuid>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion source/backend/api/Services/IPropertyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IPropertyService

PimsProperty PopulateNewProperty(PimsProperty property, bool isOwned = false, bool isPropertyOfInterest = true);

void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty propertyToUpdate, IEnumerable<UserOverrideCode> overrideCodes);
void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty propertyToUpdate, IEnumerable<UserOverrideCode> overrideCodes, bool allowRetired = false);

T PopulateNewFileProperty<T>(T fileProperty)
where T : IFilePropertyEntity;
Expand Down
8 changes: 4 additions & 4 deletions source/backend/api/Services/PropertyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
using Microsoft.Extensions.Logging;
using NetTopologySuite.Geometries;
using Pims.Api.Constants;
using Pims.Core.Api.Exceptions;
using Pims.Api.Models.CodeTypes;
using Pims.Api.Models.Concepts.Property;
using Pims.Core.Api.Exceptions;
using Pims.Core.Exceptions;
using Pims.Core.Extensions;
using Pims.Core.Security;
using Pims.Dal.Entities;
using Pims.Dal.Exceptions;
using Pims.Dal.Helpers;
using Pims.Dal.Helpers.Extensions;
using Pims.Dal.Repositories;
using Pims.Core.Security;

namespace Pims.Api.Services
{
Expand Down Expand Up @@ -387,7 +387,7 @@ public PimsProperty PopulateNewProperty(PimsProperty property, bool isOwned = fa
return property;
}

public void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty propertyToUpdate, IEnumerable<UserOverrideCode> overrideCodes)
public void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty propertyToUpdate, IEnumerable<UserOverrideCode> overrideCodes, bool allowRetired = false)
{
if (propertyToUpdate.Location == null || propertyToUpdate.Boundary == null)
{
Expand Down Expand Up @@ -415,7 +415,7 @@ public void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty prope

if (needsUpdate)
{
_propertyRepository.Update(propertyToUpdate, overrideLocation: true);
_propertyRepository.Update(propertyToUpdate, overrideLocation: true, allowRetired: allowRetired);
}
}
else
Expand Down
4 changes: 2 additions & 2 deletions source/backend/api/Services/ResearchFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void MatchProperties(PimsResearchFile researchFile, IEnumerable<UserOver
{
var foundProperty = _propertyRepository.GetByPid(pid, true);
researchProperty.PropertyId = foundProperty.Internal_Id;
_propertyService.UpdateLocation(researchProperty.Property, ref foundProperty, userOverrideCodes);
_propertyService.UpdateLocation(researchProperty.Property, ref foundProperty, userOverrideCodes, allowRetired: true);
researchProperty.Property = foundProperty;
}
catch (KeyNotFoundException)
Expand All @@ -225,7 +225,7 @@ private void MatchProperties(PimsResearchFile researchFile, IEnumerable<UserOver
{
var foundProperty = _propertyRepository.GetByPin(pin, true);
researchProperty.PropertyId = foundProperty.Internal_Id;
_propertyService.UpdateLocation(researchProperty.Property, ref foundProperty, userOverrideCodes);
_propertyService.UpdateLocation(researchProperty.Property, ref foundProperty, userOverrideCodes, allowRetired: true);
researchProperty.Property = foundProperty;
}
catch (KeyNotFoundException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface IPropertyRepository : IRepository<PimsProperty>

long GetAllAssociationsCountById(long id);

PimsProperty Update(PimsProperty property, bool overrideLocation = false);
PimsProperty Update(PimsProperty property, bool overrideLocation = false, bool allowRetired = false);

PimsProperty UpdatePropertyManagement(PimsProperty property);

Expand Down
4 changes: 2 additions & 2 deletions source/backend/dal/Repositories/PropertyRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public long GetAllAssociationsCountById(long id)
/// <param name="property">The property to update.</param>
/// <param name="overrideLocation">Whether to update the property spatial location with the incoming value. Defaults to false.</param>
/// <returns>The updated property.</returns>
public PimsProperty Update(PimsProperty property, bool overrideLocation = false)
public PimsProperty Update(PimsProperty property, bool overrideLocation = false, bool allowRetired = false)
{
property.ThrowIfNull(nameof(property));

Expand All @@ -320,7 +320,7 @@ public PimsProperty Update(PimsProperty property, bool overrideLocation = false)
.FirstOrDefault(p => p.PropertyId == propertyId) ?? throw new KeyNotFoundException();

// prevent editing on retired properties
if (existingProperty.IsRetired.HasValue && existingProperty.IsRetired.Value)
if (existingProperty.IsRetired.HasValue && existingProperty.IsRetired.Value && !allowRetired)
{
throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted.");
}
Expand Down
Loading

0 comments on commit 0b97e70

Please sign in to comment.