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

5.3 updates from dev #3983

Merged
merged 22 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b54cc38
Bump DEV version - IS79 (#3974)
asanchezr Apr 26, 2024
4d9a3ce
CI: Bump version to v5.2.0-79.1
github-actions[bot] Apr 26, 2024
39533ad
psp-7999 close button styling (#3973)
devinleighsmith Apr 26, 2024
dd0291a
CI: Bump version to v5.2.0-79.2
github-actions[bot] Apr 26, 2024
d8305b2
IS-79.00 Database Schema (#3969)
dfilteau Apr 26, 2024
d63cd44
CI: Bump version to v5.2.0-79.3
github-actions[bot] Apr 26, 2024
9c75187
Scaffold/s79 (#3975)
FuriousLlama Apr 26, 2024
5971154
CI: Bump version to v5.2.0-79.4
github-actions[bot] Apr 26, 2024
4095466
PSP-8182: Automation update based on last changes on TST Environment …
stairaku Apr 26, 2024
76d2bf5
CI: Bump version to v5.2.0-79.5
github-actions[bot] Apr 26, 2024
788e77e
snapshot updates. (#3977)
devinleighsmith Apr 29, 2024
415021e
CI: Bump version to v5.2.0-79.6
github-actions[bot] Apr 29, 2024
649aa4e
vitest corrections (#3978)
devinleighsmith Apr 30, 2024
97d2a0d
CI: Bump version to v5.2.0-79.7
github-actions[bot] Apr 30, 2024
e414d58
PSP-8022 : Disposition file states - Hold (#3979)
eddherrera May 1, 2024
11d9656
CI: Bump version to v5.2.0-79.8
github-actions[bot] May 1, 2024
5a15dcd
psp-7909 take ui refactor. (#3980)
devinleighsmith May 1, 2024
9d8186f
CI: Bump version to v5.2.0-79.9
github-actions[bot] May 1, 2024
7246ebd
unit test stability corrections (#3982)
devinleighsmith May 1, 2024
40d8a14
CI: Bump version to v5.2.0-79.10
github-actions[bot] May 1, 2024
174e177
Merge remote-tracking branch 'upstream/dev' into 5.3
devinleighsmith May 1, 2024
8ecbfdd
snapshots
devinleighsmith May 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/app-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- run: npm run build --if-present
working-directory: ${{env.working-directory}}

- run: npm run coverage -- --maxWorkers=2
- run: npm run coverage -- --bail 1 --maxWorkers 2 --minWorkers 2
working-directory: ${{env.working-directory}}
env:
REACT_APP_TENANT: MOTI
Expand Down
115 changes: 108 additions & 7 deletions source/backend/api/Areas/Takes/Controllers/TakeController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Helpers.Exceptions;
using Pims.Api.Models.Concepts.Take;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Dal.Entities;
using Pims.Dal.Exceptions;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

Expand Down Expand Up @@ -104,28 +107,98 @@ public IActionResult GetTakesByPropertyId([FromRoute] long fileId, [FromRoute] l
}

/// <summary>
/// Update the list of takes associated to a property within an acquisition file.
/// Add the passed take to the acquisition property with the given id.
/// </summary>
/// <returns></returns>
[HttpPut("acquisition/property/{acquisitionFilePropertyId:long}")]
[HttpPost("acquisition/property/{acquisitionFilePropertyId:long}/takes")]
[HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<TakeModel>), 200)]
[ProducesResponseType(typeof(TakeModel), 201)]
[SwaggerOperation(Tags = new[] { "take" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult AddAcquisitionPropertyTake(long acquisitionFilePropertyId, [FromBody] TakeModel take)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(TakeController),
nameof(AddAcquisitionPropertyTake),
User.GetUsername(),
DateTime.Now);

if (acquisitionFilePropertyId != take.PropertyAcquisitionFileId)
{
throw new BadRequestException("Invalid acquisition file property id.");
}

_logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());

var addedTake = _takeService.AddAcquisitionPropertyTake(acquisitionFilePropertyId, _mapper.Map<PimsTake>(take));
return new JsonResult(_mapper.Map<TakeModel>(addedTake));
}

/// <summary>
/// Update a take with the given take and acquisition file property id with the passed take.
/// </summary>
/// <returns></returns>
[HttpPut("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
[HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(TakeModel), 200)]
[SwaggerOperation(Tags = new[] { "take" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, [FromBody] IEnumerable<TakeModel> takes)
public IActionResult UpdateAcquisitionPropertyTake(long acquisitionFilePropertyId, long takeId, [FromBody] TakeModel take)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(TakeController),
nameof(UpdateAcquisitionPropertyTakes),
nameof(UpdateAcquisitionPropertyTake),
User.GetUsername(),
DateTime.Now);

if (acquisitionFilePropertyId != take.PropertyAcquisitionFileId)
{
throw new BadRequestException("Invalid acquisition file property id.");
}
else if (takeId != take.Id)
{
throw new BadRequestException("Invalid take id.");
}

_logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());

var updatedTakes = _takeService.UpdateAcquisitionPropertyTakes(acquisitionFilePropertyId, _mapper.Map<IEnumerable<PimsTake>>(takes));
return new JsonResult(_mapper.Map<IEnumerable<TakeModel>>(updatedTakes));
var updatedTake = _takeService.UpdateAcquisitionPropertyTake(acquisitionFilePropertyId, _mapper.Map<PimsTake>(take));
return new JsonResult(_mapper.Map<TakeModel>(updatedTake));
}

/// <summary>
/// Delete a take with the given take id and acquisition file property id.
/// </summary>
[HttpDelete("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
[HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(void), 200)]
[SwaggerOperation(Tags = new[] { "take" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public void DeleteAcquisitionPropertyTake(long acquisitionFilePropertyId, long takeId, [FromQuery] string[] userOverrideCodes)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(TakeController),
nameof(DeleteAcquisitionPropertyTake),
User.GetUsername(),
DateTime.Now);

_logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());
var existingTake = _takeService.GetById(takeId);
if (existingTake.PropertyAcquisitionFileId != acquisitionFilePropertyId)
{
throw new BadRequestException("Invalid acquisition file property id.");
}
var deleted = _takeService.DeleteAcquisitionPropertyTake(takeId, userOverrideCodes.Select(oc => UserOverrideCode.Parse(oc)));
if (!deleted)
{
throw new InvalidOperationException($"Failed to delete take {takeId}.");
}
}

/// <summary>
Expand All @@ -152,6 +225,34 @@ public IActionResult GetTakesCountByPropertyId([FromRoute] long propertyId)
return new JsonResult(count);
}

/// <summary>
/// GGet a take by id.
/// </summary>
/// <returns></returns>
[HttpGet("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
[HasPermission(Permissions.AcquisitionFileView, Permissions.PropertyView)]
[Produces("application/json")]
[ProducesResponseType(typeof(int), 200)]
[SwaggerOperation(Tags = new[] { "take" })]
public IActionResult GetTakeByPropertyFileId(long acquisitionFilePropertyId, long takeId)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(TakeController),
nameof(GetTakesCountByPropertyId),
User.GetUsername(),
DateTime.Now);

_logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());

var take = _takeService.GetById(takeId);
if(take.PropertyAcquisitionFileId != acquisitionFilePropertyId)
{
throw new BadRequestException("Invalid acquisition file property id.");
}
return new JsonResult(_mapper.Map<TakeModel>(take));
}

#endregion
}
}
25 changes: 0 additions & 25 deletions source/backend/api/Constants/EnumDispositionFileStatusTypeCode.cs

This file was deleted.

6 changes: 3 additions & 3 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.2.0-78.19</Version>
<Version>5.2.0-78.19</Version>
<AssemblyVersion>5.2.0.78</AssemblyVersion>
<Version>5.2.0-79.10</Version>
<Version>5.2.0-79.10</Version>
<AssemblyVersion>5.2.0.79</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>16BC0468-78F6-4C91-87DA-7403C919E646</ProjectGuid>
<TargetFramework>net8.0</TargetFramework>
Expand Down
12 changes: 6 additions & 6 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public List<AcquisitionFileExportModel> GetAcquisitionFileExport(AcquisitionFilt
FileFunding = fileProperty.file.AcquisitionFundingTypeCodeNavigation is not null ? fileProperty.file.AcquisitionFundingTypeCodeNavigation.Description : string.Empty,
FileAssignedDate = fileProperty.file.AssignedDate.HasValue ? fileProperty.file.AssignedDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
FileDeliveryDate = fileProperty.file.DeliveryDate.HasValue ? fileProperty.file.DeliveryDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
FileAcquisitionCompleted = fileProperty.file.CompletionDate.HasValue ? fileProperty.file.CompletionDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
//FileAcquisitionCompleted = fileProperty.file.CompletionDate.HasValue ? fileProperty.file.CompletionDate.Value.ToString("dd-MMM-yyyy") : string.Empty, TODO: Fix mappings
FilePhysicalStatus = fileProperty.file.AcqPhysFileStatusTypeCodeNavigation is not null ? fileProperty.file.AcqPhysFileStatusTypeCodeNavigation.Description : string.Empty,
FileAcquisitionType = fileProperty.file.AcquisitionTypeCodeNavigation is not null ? fileProperty.file.AcquisitionTypeCodeNavigation.Description : string.Empty,
FileAcquisitionTeam = string.Join(", ", fileProperty.file.PimsAcquisitionFileTeams.Select(x => x.PersonId.HasValue ? x.Person.GetFullName(true) : x.Organization.Name)),
Expand Down Expand Up @@ -255,7 +255,7 @@ public PimsAcquisitionFile Update(PimsAcquisitionFile acquisitionFile, IEnumerab

if (!_statusSolver.CanEditDetails(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

if (!userOverrides.Contains(UserOverrideCode.UpdateRegion))
Expand Down Expand Up @@ -301,7 +301,7 @@ public PimsAcquisitionFile UpdateProperties(PimsAcquisitionFile acquisitionFile,
AcquisitionStatusTypes? currentAcquisitionStatus = GetCurrentAcquisitionStatus(acquisitionFile.Internal_Id);
if (!_statusSolver.CanEditProperties(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

// Get the current properties in the research file
Expand Down Expand Up @@ -368,7 +368,7 @@ public PimsAcquisitionFile UpdateChecklistItems(IList<PimsAcquisitionChecklistIt
var currentAcquisitionStatus = GetCurrentAcquisitionStatus(acquisitionFileId);
if (!_statusSolver.CanEditChecklists(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

// Get the current checklist items for this acquisition file.
Expand Down Expand Up @@ -490,7 +490,7 @@ public IEnumerable<PimsInterestHolder> UpdateInterestHolders(long acquisitionFil
var currentAcquisitionStatus = GetCurrentAcquisitionStatus(acquisitionFileId);
if (!_statusSolver.CanEditStakeholders(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

var currentInterestHolders = _interestHolderRepository.GetInterestHoldersByAcquisitionFile(acquisitionFileId);
Expand Down Expand Up @@ -735,7 +735,7 @@ private void ValidateAcquisitionFileStatus(long acquisitionFileId, string agreem

if (!_statusSolver.CanEditOrDeleteAgreement(currentAcquisitionStatus, agreementStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/backend/api/Services/CompensationRequisitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public PimsCompensationRequisition Update(PimsCompensationRequisition compensati

if (!_statusSolver.CanEditOrDeleteCompensation(currentAcquisitionStatus, currentCompensation.IsDraft) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

CheckTotalAllowableCompensation(currentAcquisitionFile, compensationRequisition);
Expand Down Expand Up @@ -106,7 +106,7 @@ public bool DeleteCompensation(long compensationId)

if (!_statusSolver.CanEditOrDeleteCompensation(currentAcquisitionStatus, currentCompensation.IsDraft) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}

var fileFormToDelete = _compensationRequisitionRepository.TryDelete(compensationId);
Expand Down
Loading