Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-8186 : Property File Change Log Update #3995

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions source/backend/apimodels/CodeTypes/PropertyPPHStatusTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Pims.Api.Models.CodeTypes
{
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum PropertyPPHStatusTypes
{
[EnumMember(Value = "ARTERY")]
ARTERY,

[EnumMember(Value = "COMBO")]
COMBO,

[EnumMember(Value = "NONPPH")]
NONPPH,

[EnumMember(Value = "PPH")]
PPH,

[EnumMember(Value = "UNKNOWN")]
UNKNOWN,
}
}
1 change: 1 addition & 0 deletions source/backend/dal/Pims.Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<None Remove=".env" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\apimodels\Pims.Api.Models.csproj" />
<ProjectReference Include="..\entities\Pims.Dal.Entities.csproj" />
<ProjectReference Include="..\core\Pims.Core.csproj" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion source/backend/dal/Repositories/PropertyRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using LinqKit;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.CodeTypes;
using Pims.Core.Exceptions;
using Pims.Core.Extensions;
using Pims.Core.Helpers;
Expand Down Expand Up @@ -346,7 +347,8 @@ public PimsProperty Update(PimsProperty property, bool overrideLocation = false)
property.IsVisibleToOtherAgencies = existingProperty.IsVisibleToOtherAgencies;
property.IsSensitive = existingProperty.IsSensitive;

if (property.PphStatusTypeCode != existingProperty.PphStatusTypeCode)
if (property.PphStatusTypeCode != existingProperty.PphStatusTypeCode
&& (property.PphStatusTypeCode != PropertyPPHStatusTypes.UNKNOWN.ToString() && existingProperty.PphStatusTypeCode != null))
{
property.PphStatusUpdateTimestamp = DateTime.UtcNow;
property.PphStatusUpdateUserid = User.GetUsername();
Expand Down
1 change: 1 addition & 0 deletions source/backend/tests/core/PrincipalHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static ClaimsPrincipal CreateForPermission(params Permissions[] permissio
var claims = new List<Claim>
{
new Claim("idir_user_guid", Guid.NewGuid().ToString().Replace("-", string.Empty)),
new Claim("idir_username", "super-tester"),
new Claim(ClaimTypes.Email, "[email protected]"),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.Linq;
using FluentAssertions;
using Pims.Api.Models.CodeTypes;
using Pims.Core.Exceptions;
using Pims.Core.Extensions;
using Pims.Core.Test;
Expand Down Expand Up @@ -668,6 +669,60 @@ public void Update_Property_ThrowIfNull()
// Assert
act.Should().Throw<ArgumentNullException>();
}

[Fact]
public void Update_Property_DoesNOT_UPDATE_PPH_Audit()
{
// Arrange
var repository = CreateRepositoryWithPermissions(Permissions.PropertyView, Permissions.PropertyEdit);
var property = EntityHelper.CreateProperty(1);
property.PphStatusTypeCode = null;
property.PphStatusUpdateTimestamp = null;
property.PphStatusUpdateUserid = null;
property.PphStatusUpdateUserGuid = null;

_helper.AddAndSaveChanges(property);

var updateProperty = new PimsProperty();
updateProperty.PropertyId = property.PropertyId;
updateProperty.PphStatusTypeCode = PropertyPPHStatusTypes.UNKNOWN.ToString();

// Act
var result = repository.Update(updateProperty);

// Assert
Assert.Null(result.PphStatusUpdateTimestamp);
Assert.Null(result.PphStatusUpdateUserid);
Assert.Null(result.PphStatusUpdateUserGuid);
}

[Fact]
public void Update_Property_Update_PPH_Audit()
{
// Arrange
var repository = CreateRepositoryWithPermissions(Permissions.PropertyView, Permissions.PropertyEdit);
var property = EntityHelper.CreateProperty(1);
property.PphStatusTypeCode = PropertyPPHStatusTypes.UNKNOWN.ToString();
property.PphStatusUpdateTimestamp = null;
property.PphStatusUpdateUserid = null;
property.PphStatusUpdateUserGuid = null;

_helper.AddAndSaveChanges(property);

var updateProperty = new PimsProperty();
updateProperty.PropertyId = property.PropertyId;
updateProperty.PphStatusTypeCode = PropertyPPHStatusTypes.COMBO.ToString();

// Act
var result = repository.Update(updateProperty);

// Assert
Assert.Equal(PropertyPPHStatusTypes.COMBO.ToString(), result.PphStatusTypeCode);
Assert.NotNull(result.PphStatusUpdateTimestamp);
Assert.NotNull(result.PphStatusUpdateUserid);
Assert.NotNull(result.PphStatusUpdateUserGuid);
}

#endregion

#region Delete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GeoJsonProperties } from 'geojson';
import { isEmpty } from 'lodash';

import { ApiGen_CodeTypes_PropertyPPHStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_PropertyPPHStatusTypes';
import { ApiGen_Concepts_Address } from '@/models/api/generated/ApiGen_Concepts_Address';
import { ApiGen_Concepts_CodeType } from '@/models/api/generated/ApiGen_Concepts_CodeType';
import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property';
Expand Down Expand Up @@ -152,7 +153,8 @@ export class UpdatePropertyDetailsFormModel {
model.description = base.description ?? undefined;
model.isSensitive = base.isSensitive;
model.isRetired = base.isRetired;
model.pphStatusTypeCode = base.pphStatusTypeCode ?? 'UNKNOWN';
model.pphStatusTypeCode =
base.pphStatusTypeCode ?? ApiGen_CodeTypes_PropertyPPHStatusTypes.UNKNOWN.toString();
model.isRwyBeltDomPatent = base.isRwyBeltDomPatent ?? undefined;
model.pphStatusUpdateUserid = base.pphStatusUpdateUserid ?? undefined;
model.pphStatusUpdateUserGuid = base.pphStatusUpdateUserGuid ?? undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* File autogenerated by TsGenerator.
* Do not manually modify, changes made to this file will be lost when this file is regenerated.
*/
export enum ApiGen_CodeTypes_PropertyPPHStatusTypes {
ARTERY = 'ARTERY',
COMBO = 'COMBO',
NONPPH = 'NONPPH',
PPH = 'PPH',
UNKNOWN = 'UNKNOWN',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* File autogenerated by TsGenerator.
* Do not manually modify, changes made to this file will be lost when this file is regenerated.
*/
export enum ApiGen_CodeTypes_TakeTypes {
TOTAL = 'TOTAL',
PARTIAL = 'PARTIAL',
}
Loading