Skip to content

Commit

Permalink
Merge pull request #67 from Worth-NL/feature/TaskScenario_SupportAlte…
Browse files Browse the repository at this point in the history
…rnativeTaskObjectPOCO

Feature/task scenario support alternative task object poco
  • Loading branch information
Thomas-M-Krystyan authored Sep 17, 2024
2 parents 892efce + 3491f8a commit 3837187
Show file tree
Hide file tree
Showing 36 changed files with 669 additions and 203 deletions.
2 changes: 1 addition & 1 deletion Documentation/OMC - Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# **OMC** Documentation

v.1.8.14
v.1.8.15

© 2024, Worth Systems.

Expand Down
2 changes: 1 addition & 1 deletion EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ApiController
{
internal const string Route = "[controller]";

internal const string Version = "1.814";
internal const string Version = "1.815";
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal static bool IsNotCaseType(this Uri? uri)
}

/// <summary>
/// Determines whether the given <see cref="Uri"/> doesn't contain object (e.g., <see cref="TaskObject"/> or <see cref="MessageObject"/>) <see cref="Uri"/>.
/// Determines whether the given <see cref="Uri"/> doesn't contain object (e.g., <see cref="CommonTaskData"/> from Task or <see cref="MessageObject"/>) <see cref="Uri"/>.
/// </summary>
/// <param name="uri">The source URI.</param>
/// <returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

using EventsHandler.Constants;
using EventsHandler.Mapping.Converters;
using EventsHandler.Mapping.Models.POCOs.Objecten.Message;
using EventsHandler.Mapping.Models.POCOs.Objecten.Task;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Enums.NotificatieApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace EventsHandler.Mapping.Enums.Objecten
{
/// <summary>
/// The status of the <see cref="TaskObject"/> from "Objecten" Web API service.
/// The status of the <see cref="CommonTaskData.Status"/> from "Objecten" Web API service.
/// </summary>
[JsonConverter(typeof(SafeJsonStringEnumMemberConverter<TaskStatuses>))]
public enum TaskStatuses
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// © 2024, Worth Systems.

using EventsHandler.Constants;
using EventsHandler.Mapping.Converters;
using EventsHandler.Mapping.Models.POCOs.Objecten.Task.vNijmegen;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Enums.Objecten.vNijmegen
{
/// <summary>
/// The type of the <see cref="Coupling"/> from "Objecten" Web API service.
/// </summary>
[JsonConverter(typeof(SafeJsonStringEnumMemberConverter<Registrations>))]
public enum Registrations
{
/// <summary>
/// The default value.
/// </summary>
[JsonPropertyName(DefaultValues.Models.DefaultEnumValueName)]
Unknown = 0,

/// <summary>
/// The case type of the <see cref="Coupling"/>.
/// </summary>
[JsonPropertyName("zaak")]
Case = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal readonly PropertiesMetadata Properties(Channels channel)

#region Object properties
/// <summary>
/// The <see cref="TaskObject"/> or <see cref="MessageObject"/> type in <see cref="Uri"/> format:
/// The <see cref="CommonTaskData"/> from Task or <see cref="MessageObject"/> type in <see cref="Uri"/> format:
/// <code>
/// http(s)://Domain/ApiEndpoint/[UUID]
/// </code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EventsHandler.Mapping.Models.POCOs.Objecten
{
/// <summary>
/// The identification related to the different Data (associated with <see cref="TaskObject"/>,
/// The identification related to the different Data (associated with <see cref="CommonTaskData"/> from Task,
/// <see cref="MessageObject"/>, etc.) retrieved from "Objecten" Web API service.
/// </summary>
/// <seealso cref="IJsonSerializable"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// © 2024, Worth Systems.

using EventsHandler.Mapping.Enums.Objecten;
using EventsHandler.Mapping.Models.Interfaces;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task
{
/// <summary>
/// The data related to the Task (from vHague or vNijmegen versions) retrieved from "Objecten" Web API service.
/// </summary>
/// <remarks>
/// Common DTO for all versions of "Objecten" Web API service.
/// </remarks>
/// <seealso cref="IJsonSerializable"/>
internal readonly struct CommonTaskData : IJsonSerializable
{
/// <summary>
/// The reference to related object in <see cref="System.Uri"/> format:
/// <code>
/// http(s)://Domain/ApiEndpoint/[UUID]
/// </code>
/// </summary>
[JsonInclude]
[JsonPropertyOrder(0)]
internal Uri CaseUri { get; init; } // NOTE: Some task data might not have it (recreating of URI is necessary)

/// <summary>
/// The ID of the related object.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyOrder(1)]
internal Guid CaseId { get; init; }

/// <summary>
/// The title of the task.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyOrder(2)]
internal string Title { get; init; }

/// <summary>
/// The status of the task.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyOrder(3)]
internal TaskStatuses Status { get; init; }

/// <summary>
/// The deadline by which the task should be completed.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyOrder(4)]
internal DateTime ExpirationDate { get; init; }

/// <summary>
/// The identification details of the task.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyOrder(5)]
internal Identification Identification { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// © 2024, Worth Systems.

using EventsHandler.Extensions;
using EventsHandler.Services.Settings.Extensions;
using ConfigurationExtensions = EventsHandler.Services.Settings.Extensions.ConfigurationExtensions;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task.Converters
{
/// <summary>
/// Converts task data from different versions of "Objecten" into a unified <see cref="CommonTaskData"/>.
/// </summary>
internal static class CommonTaskDataConverter
{
/// <summary>
/// Converts <see cref="vHague.TaskObject"/> (version used by The Hague) from "Objecten" Web API service.
/// </summary>
/// <returns>
/// The unified <see cref="CommonTaskData"/> DTO model.
/// </returns>
internal static CommonTaskData ConvertToUnified(this vHague.TaskObject taskDataHague)
{
return new CommonTaskData
{
CaseUri = taskDataHague.Record.Data.CaseUri,
CaseId = taskDataHague.Record.Data.CaseUri.GetGuid(), // NOTE: URI is given, GUID needs to be extracted
Title = taskDataHague.Record.Data.Title,
Status = taskDataHague.Record.Data.Status,
ExpirationDate = taskDataHague.Record.Data.ExpirationDate,
Identification = taskDataHague.Record.Data.Identification
};
}

/// <summary>
/// Converts <see cref="vNijmegen.TaskObject"/> (version used by Nijmegen) from "Objecten" Web API service.
/// </summary>
/// <returns>
/// The unified <see cref="CommonTaskData"/> DTO model.
/// </returns>
internal static CommonTaskData ConvertToUnified(this vNijmegen.TaskObject taskNijmegen)
{
return new CommonTaskData
{
CaseUri = RecreateCaseUri(taskNijmegen.Record.Data.Coupling.Id), // NOTE: GUID is given, URI needs to be recreated
CaseId = taskNijmegen.Record.Data.Coupling.Id,
Title = taskNijmegen.Record.Data.Title,
Status = taskNijmegen.Record.Data.Status,
ExpirationDate = taskNijmegen.Record.Data.ExpirationDate,
Identification = taskNijmegen.Record.Data.Identification
};
}

#region Helper methods
private const string CaseUri = "https://{0}/zaken/api/v1/zaken/{1}";

private static Uri RecreateCaseUri(Guid caseId)
=> string.Format(CaseUri, ConfigurationExtensions.OpenZaakDomain(), caseId)
.GetValidUri();
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,49 @@
using EventsHandler.Constants;
using EventsHandler.Mapping.Enums.Objecten;
using EventsHandler.Mapping.Models.Interfaces;
using EventsHandler.Mapping.Models.POCOs.OpenZaak;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task
namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task.vHague
{
/// <summary>
/// The data related to the <see cref="Record"/> retrieved from "Objecten" Web API service.
/// </summary>
/// <remarks>
/// Version used by The Hague.
/// </remarks>
/// <seealso cref="CommonTaskData"/>
/// <seealso cref="IJsonSerializable"/>
public struct Data : IJsonSerializable
{
/// <summary>
/// The reference to <see cref="Case"/> in <see cref="Uri"/> format:
/// <code>
/// http(s)://Domain/ApiEndpoint/[UUID]
/// </code>
/// </summary>
/// <inheritdoc cref="CommonTaskData.CaseId"/>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("zaak")]
[JsonPropertyOrder(0)]
public Uri CaseUri { get; internal set; } = DefaultValues.Models.EmptyUri;

/// <summary>
/// The title of the <see cref="TaskObject"/>.
/// </summary>
/// <inheritdoc cref="CommonTaskData.Title"/>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("title")]
[JsonPropertyOrder(1)]
public string Title { get; internal set; } = string.Empty;

/// <summary>
/// The status of the <see cref="TaskObject"/>.
/// </summary>
/// <inheritdoc cref="CommonTaskData.Status"/>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("status")]
[JsonPropertyOrder(2)]
public TaskStatuses Status { get; internal set; }

/// <summary>
/// The deadline by which the <see cref="TaskObject"/> should be completed.
/// </summary>
/// <inheritdoc cref="CommonTaskData.ExpirationDate"/>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("verloopdatum")]
[JsonPropertyOrder(3)]
public DateTime ExpirationDate { get; internal set; }

/// <summary>
/// The identification details of the <see cref="TaskObject"/>.
/// </summary>
/// <inheritdoc cref="CommonTaskData.Identification"/>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("identificatie")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using EventsHandler.Mapping.Models.Interfaces;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task
namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task.vHague
{
/// <summary>
/// The record related to the <see cref="TaskObject"/> retrieved from "Objecten" Web API service.
/// </summary>
/// <remarks>
/// Version used by The Hague.
/// </remarks>
/// <seealso cref="IJsonSerializable"/>
public struct Record : IJsonSerializable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using EventsHandler.Mapping.Models.Interfaces;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task
namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task.vHague
{
/// <summary>
/// The task retrieved from "Objecten" Web API service.
/// </summary>
/// <remarks>
/// Version used by The Hague.
/// </remarks>
/// <seealso cref="IJsonSerializable"/>
public struct TaskObject : IJsonSerializable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// © 2024, Worth Systems.

using EventsHandler.Mapping.Enums.Objecten.vNijmegen;
using EventsHandler.Mapping.Models.Interfaces;
using System.Text.Json.Serialization;

namespace EventsHandler.Mapping.Models.POCOs.Objecten.Task.vNijmegen
{
/// <summary>
/// The coupling related to the <see cref="TaskObject"/> retrieved from "Objecten" Web API service.
/// </summary>
/// <seealso cref="IJsonSerializable"/>
public struct Coupling : IJsonSerializable
{
/// <summary>
/// The type of the <see cref="Coupling"/>.
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("registratie")]
[JsonPropertyOrder(0)]
public Registrations Type { get; internal set; }

/// <summary>
/// The ID of the <see cref="Coupling"/> object (e.g., case).
/// </summary>
[JsonRequired]
[JsonInclude]
[JsonPropertyName("uuid")]
[JsonPropertyOrder(1)]
public Guid Id { get; internal set; } = Guid.Empty;

/// <summary>
/// Initializes a new instance of the <see cref="Coupling"/> struct.
/// </summary>
public Coupling()
{
}
}
}
Loading

0 comments on commit 3837187

Please sign in to comment.