Skip to content

Commit

Permalink
Merge pull request #2084 from bcgov/release/is35_master
Browse files Browse the repository at this point in the history
TEST -> UAT - IS35 Release
  • Loading branch information
devinleighsmith authored Sep 15, 2022
2 parents 59eb8b8 + 34ebfc2 commit 042eb74
Show file tree
Hide file tree
Showing 633 changed files with 105,794 additions and 6,218 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: SonarScanner for .NET 6 with pull request decoration support
id: scan
uses: highbyte/[email protected]
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'bcgov/PSP' }}
if: ${{ github.event_name == 'push' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd-pims-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
namespace: ${{ env.OPENSHIFT_TOOLS_NAMESPACE }}
- name: call script to tag frontend and api images with version number
run: |
./openshift/4.0/scripts/oc-tag.sh $OC_JOB_NAME
./openshift/4.0/scripts/oc-tag.sh $DESTINATION
deploy:
name: Deploy frontend and api to OpenShift
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ db-upgrade: ## Upgrade an existing database to the TARGET_VERSION (if passed) or

db-scaffold: ## Requires local install of sqlcmd
@echo "$(P) regenerate ef core entities from database"
@cd backend/entities; eval $(grep -v '^#' .env | xargs) dotnet ef dbcontext scaffold Name=PIMS Microsoft.EntityFrameworkCore.SqlServer -o ../entities/ef --schema dbo --context PimsBaseContext --context-namespace Pims.Dal --context-dir . --no-onconfiguring --namespace Pims.Dal.Entities --data-annotations -v -f
@cd backend/entities; eval $(grep -v '^#' .env | xargs) dotnet ef dbcontext scaffold Name=PIMS Microsoft.EntityFrameworkCore.SqlServer -o ../entities/ef --schema dbo --context PimsBaseContext --context-namespace Pims.Dal --context-dir . --no-onconfiguring --namespace Pims.Dal.Entities --data-annotations -v -f --startup-project ../api

keycloak-sync: ## Syncs accounts with Keycloak and PIMS
@echo "$(P) Syncing keycloak with PIMS..."
Expand Down
4 changes: 2 additions & 2 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ dotnet_diagnostic.S1128.severity = warning
dotnet_diagnostic.S3358.severity = warning
# SA1617 Void return value should not be documented
dotnet_diagnostic.SA1617.severity = error
# SA1122 Use string.Empty for empty strings
dotnet_diagnostic.SA1122.severity = error

# StyleCop
# SA1600 Elements should be documented
Expand Down Expand Up @@ -161,8 +163,6 @@ dotnet_diagnostic.SA1516.severity = warning
dotnet_diagnostic.SA1208.severity = warning
# SA1507 Code should not contain multiple blank lines in a row
dotnet_diagnostic.SA1507.severity = warning
# SA1122 Use string.Empty for empty strings
dotnet_diagnostic.SA1122.severity = warning
# SA1629 Documentation text should end with a period
dotnet_diagnostic.SA1629.severity = warning
# SA1121 Use built-in type alias
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Extensions;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

Expand All @@ -23,6 +26,7 @@ public class AcquisitionFileController : ControllerBase
#region Variables
private readonly IAcquisitionFileService _acquisitionService;
private readonly IMapper _mapper;
private readonly ILogger _logger;
#endregion

#region Constructors
Expand All @@ -32,11 +36,13 @@ public class AcquisitionFileController : ControllerBase
/// </summary>
/// <param name="acquisitionService"></param>
/// <param name="mapper"></param>
/// <param name="logger"></param>
///
public AcquisitionFileController(IAcquisitionFileService acquisitionService, IMapper mapper)
public AcquisitionFileController(IAcquisitionFileService acquisitionService, IMapper mapper, ILogger<AcquisitionFileController> logger)
{
_acquisitionService = acquisitionService;
_mapper = mapper;
_logger = logger;
}
#endregion

Expand All @@ -53,6 +59,16 @@ public AcquisitionFileController(IAcquisitionFileService acquisitionService, IMa
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
public IActionResult GetAcquisitionFile(long id)
{
// RECOMMENDED - Add valuable metadata to logs
_logger.LogInformation("Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(AcquisitionFileController),
nameof(GetAcquisitionFile),
User.GetUsername(),
DateTime.Now);

// RECOMMENDED - Log communications between components
_logger.LogInformation("Dispatching to service: {Service}", _acquisitionService.GetType());

var acqFile = _acquisitionService.GetById(id);
return new JsonResult(_mapper.Map<AcquisitionFileModel>(acqFile));
}
Expand Down
17 changes: 16 additions & 1 deletion backend/api/Areas/Acquisition/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ namespace Pims.Api.Areas.Acquisition.Controllers
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.Acquisition.Models.Search;
using Pims.Api.Helpers.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Extensions;
using Pims.Dal.Entities.Models;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;
Expand All @@ -30,6 +32,7 @@ public class SearchController : ControllerBase
#region Variables
private readonly IAcquisitionFileService acquisitionService;
private readonly IMapper mapper;
private readonly ILogger _logger;
#endregion

#region Constructors
Expand All @@ -39,11 +42,13 @@ public class SearchController : ControllerBase
/// </summary>
/// <param name="acquisitionService"></param>
/// <param name="mapper"></param>
/// <param name="logger"></param>
///
public SearchController(IAcquisitionFileService acquisitionService, IMapper mapper)
public SearchController(IAcquisitionFileService acquisitionService, IMapper mapper, ILogger<SearchController> logger)
{
this.acquisitionService = acquisitionService;
this.mapper = mapper;
this._logger = logger;
}
#endregion

Expand Down Expand Up @@ -79,12 +84,22 @@ public IActionResult GetAcquisitionFiles()
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
public IActionResult GetAcquisitionFiles([FromBody] AcquisitionFilterModel filter)
{
// RECOMMENDED - Add valuable metadata to logs
_logger.LogInformation("Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(SearchController),
nameof(GetAcquisitionFiles),
User.GetUsername(),
DateTime.Now);

filter.ThrowBadRequestIfNull($"The request must include a filter.");
if (!filter.IsValid())
{
throw new BadRequestException("Acquisition filter must contain valid values.");
}

// RECOMMENDED - Log communications between components
_logger.LogInformation("Dispatching to service: {Service}", acquisitionService.GetType());

var acquisitionFiles = acquisitionService.GetPage((AcquisitionFilter)filter);
return new JsonResult(mapper.Map<Api.Models.PageModel<AcquisitionFileModel>>(acquisitionFiles));
}
Expand Down
114 changes: 114 additions & 0 deletions backend/api/Areas/Activities/Controllers/ActivityController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

namespace Pims.Api.Areas.Activities.Controllers
{
/// <summary>
/// ActivityController class, provides endpoints for interacting with activities.
/// </summary>
[Authorize]
[ApiController]
[ApiVersion("1.0")]
[Area("activities")]
[Route("v{version:apiVersion}/[area]")]
[Route("[area]")]
public class ActivityController : ControllerBase
{
#region Variables
private readonly IActivityService _activityService;
private readonly IMapper _mapper;
#endregion

#region Constructors

/// <summary>
/// Creates a new instance of a ActivityController class, initializes it with the specified arguments.
/// </summary>
/// <param name="activityService"></param>
/// <param name="mapper"></param>
///
public ActivityController(IActivityService activityService, IMapper mapper)
{
_activityService = activityService;
_mapper = mapper;
}
#endregion

#region Endpoints

/// <summary>
/// Add the specified activity.
/// </summary>
/// <param name="activityModel">The activity to add.</param>
/// <returns></returns>
[HttpPost]
[HasPermission(Permissions.ActivityAdd)]
[Produces("application/json")]
[ProducesResponseType(typeof(ActivityInstanceModel), 200)]
[SwaggerOperation(Tags = new[] { "activity" })]
public IActionResult AddActivity([FromBody] ActivityInstanceModel activityModel)
{
var activityInstance = _mapper.Map<PimsActivityInstance>(activityModel);
var createdActivity = _activityService.Add(activityInstance);
return new JsonResult(_mapper.Map<ActivityInstanceModel>(createdActivity));
}

/// <summary>
/// Retrieves the activity with the specified id.
/// </summary>
/// <param name="activityId">Used to identify the activity.</param>
/// <returns></returns>
[HttpGet("{activityId:long}")]
[Produces("application/json")]
[HasPermission(Permissions.ActivityView)]
[ProducesResponseType(typeof(ActivityInstanceModel), 200)]
[SwaggerOperation(Tags = new[] { "activity" })]
public IActionResult GetActivityById(long activityId)
{
var activity = _activityService.GetById(activityId);
return new JsonResult(_mapper.Map<ActivityInstanceModel>(activity));
}

/// <summary>
/// Updates the activity with the specified id.
/// </summary>
/// <param name="activityId">Used to identify the activity.</param>
/// <param name="activityModel">The updated activity values.</param>
/// <returns></returns>
[HttpPut("{activityId:long}")]
[Produces("application/json")]
[HasPermission(Permissions.ActivityEdit)]
[ProducesResponseType(typeof(ActivityInstanceModel), 200)]
[SwaggerOperation(Tags = new[] { "activity" })]
public IActionResult UpdateActivity(long activityId, [FromBody] ActivityInstanceModel activityModel)
{
var activityInstance = _mapper.Map<PimsActivityInstance>(activityModel);
var updatedActivity = _activityService.Update(activityInstance);
return new JsonResult(_mapper.Map<ActivityInstanceModel>(updatedActivity));
}

/// <summary>
/// Deletes the activity for the specified type.
/// </summary>
/// <param name="activityId">Used to identify the activity and delete it.</param>
/// <returns></returns>
[HttpDelete("{activityId:long}")]
[Produces("application/json")]
[HasPermission(Permissions.ActivityDelete)]
[ProducesResponseType(typeof(bool), 200)]
[SwaggerOperation(Tags = new[] { "activity" })]
public IActionResult DeleteActivity(long activityId)
{
_activityService.Delete(activityId);
return new JsonResult(true);
}
#endregion
}
}
27 changes: 27 additions & 0 deletions backend/api/Areas/Documents/DocumentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ public async Task<IActionResult> UploadDocumentWithParent(
}
}

/// <summary>
/// Updates document metadata and status.
/// </summary>
/// <param name="relationshipType">Used to identify document type.</param>
/// <param name="documentId">Used to identify document.</param>
/// <param name="updateRequest">Contains information about the document metadata.</param>
/// <returns></returns>
[HttpPut("{documentId}/relationship/{relationshipType}/metadata")]
[Produces("application/json")]
[HasPermission(Permissions.DocumentEdit)]
[ProducesResponseType(typeof(DocumentUpdateResponse), 200)]
[SwaggerOperation(Tags = new[] { "documents" })]
public async Task<IActionResult> UpdateDocumentMetadata(
long documentId,
DocumentRelationType relationshipType,
[FromBody] DocumentUpdateRequest updateRequest)
{
switch (relationshipType)
{
case DocumentRelationType.Activities:
var response = await _documentService.UpdateActivityDocumentMetadataAsync(documentId, updateRequest);
return new JsonResult(response);
default:
throw new BadRequestException("Relationship type not valid.");
}
}

/// <summary>
/// Deletes the specific document relationship for the given type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Pims.Dal.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Pims.Dal.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Pims.Api.Models;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Pims.Dal.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Pims.Api.Models;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Pims.Dal.Services;
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Areas/Leases/Mapping/Lease/PropertyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Address, src => src.Property.Address)
.Map(dest => dest.IsSensitive, src => src.Property.IsSensitive)
.Map(dest => dest.Description, src => src.Property.Description)
.Map(dest => dest.SurplusDeclaration, src => src)
.Map(dest => dest.SurplusDeclaration, src => src.Property)
.Map(dest => dest.RowVersion, src => src.ConcurrencyControlNumber)
.Map(dest => dest.LandArea, src => src.LeaseArea);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Exceptions;
using Pims.Dal;
using Pims.Dal.Security;
Expand Down
1 change: 1 addition & 0 deletions backend/api/Areas/Persons/Controllers/PersonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Exceptions;
using Pims.Dal;
using Pims.Dal.Security;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Areas.Property.Models.Property;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal;
using Pims.Dal.Security;
using Pims.Dal.Services;
Expand Down
1 change: 1 addition & 0 deletions backend/api/Areas/Reports/Controllers/LeaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Pims.Api.Helpers.Extensions;
using Pims.Api.Helpers.Reporting;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Dal;
using Pims.Dal.Entities;
using Pims.Dal.Entities.Models;
Expand Down
Loading

0 comments on commit 042eb74

Please sign in to comment.