Skip to content

Commit

Permalink
Fix name conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mlqn committed Jan 16, 2025
1 parent d360473 commit 9c6dbb9
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 41 deletions.
8 changes: 4 additions & 4 deletions backend/src/Designer/Controllers/ResourceAdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public async Task<ActionResult<List<AvailableService>>> GetAltinn2LinkServices(s
foreach (ServiceResource resource in allResources)
{
if (resource?.HasCompetentAuthority.Orgcode != null
&& resource.ResourceReferences != null && resource.ResourceReferences.Exists(r => r.ReferenceType != null && r.ReferenceType.Equals(ReferenceType.ServiceCode))
&& resource.ResourceReferences != null && resource.ResourceReferences.Exists(r => r.ReferenceType != null && r.ReferenceType.Equals(ResourceReferenceType.ServiceCode))
&& resource.ResourceType == ResourceType.Altinn2Service)
{
AvailableService service = new AvailableService();
Expand All @@ -496,8 +496,8 @@ public async Task<ActionResult<List<AvailableService>>> GetAltinn2LinkServices(s
service.ServiceName = resource.Title["nb"];
}

service.ExternalServiceCode = resource.ResourceReferences.First(r => r.ReferenceType.Equals(ReferenceType.ServiceCode)).Reference;
service.ExternalServiceEditionCode = Convert.ToInt32(resource.ResourceReferences.First(r => r.ReferenceType.Equals(ReferenceType.ServiceEditionCode)).Reference);
service.ExternalServiceCode = resource.ResourceReferences.First(r => r.ReferenceType.Equals(ResourceReferenceType.ServiceCode)).Reference;
service.ExternalServiceEditionCode = Convert.ToInt32(resource.ResourceReferences.First(r => r.ReferenceType.Equals(ResourceReferenceType.ServiceEditionCode)).Reference);
service.ServiceOwnerCode = resource.HasCompetentAuthority.Orgcode;
unfiltered.Add(service);
}
Expand Down Expand Up @@ -551,7 +551,7 @@ private ValidationProblemDetails ValidateResource(ServiceResource resource)

if (resource.ResourceType == ResourceType.MaskinportenSchema)
{
if (resource.ResourceReferences == null || !resource.ResourceReferences.Any((x) => x.ReferenceType == ReferenceType.MaskinportenScope))
if (resource.ResourceReferences == null || !resource.ResourceReferences.Any((x) => x.ReferenceType == ResourceReferenceType.MaskinportenScope))
{
ModelState.AddModelError($"{resource.Identifier}.resourceReferences", "resourceerror.missingmaskinportenscope");
}
Expand Down
28 changes: 3 additions & 25 deletions backend/src/Designer/Enums/ReferenceType.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
using System.Runtime.Serialization;

namespace Altinn.Studio.Designer.Enums
{
/// <summary>
/// Enum for reference types of resources in the resource registry
/// </summary>
public enum ReferenceType
{
[EnumMember(Value = "Default")]
Default = 0,

[EnumMember(Value = "Uri")]
Uri = 1,

[EnumMember(Value = "DelegationSchemeId")]
DelegationSchemeId = 2,

[EnumMember(Value = "MaskinportenScope")]
MaskinportenScope = 3,

[EnumMember(Value = "ServiceCode")]
ServiceCode = 4,

[EnumMember(Value = "ServiceEditionCode")]
ServiceEditionCode = 5,

[EnumMember(Value = "ApplicationId")]
ApplicationId = 6,
LayoutSet,
Layout,
Component
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Altinn.Studio.Designer.Enums
/// <summary>
/// Enum for the different reference sources for resources in the resource registry
/// </summary>
public enum ReferenceSource
public enum ResourceReferenceSource
{
[EnumMember(Value = "Default")]
Default = 0,
Expand Down
31 changes: 31 additions & 0 deletions backend/src/Designer/Enums/ResourceReferenceType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Runtime.Serialization;

namespace Altinn.Studio.Designer.Enums
{
/// <summary>
/// Enum for reference types of resources in the resource registry
/// </summary>
public enum ResourceReferenceType
{
[EnumMember(Value = "Default")]
Default = 0,

[EnumMember(Value = "Uri")]
Uri = 1,

[EnumMember(Value = "DelegationSchemeId")]
DelegationSchemeId = 2,

[EnumMember(Value = "MaskinportenScope")]
MaskinportenScope = 3,

[EnumMember(Value = "ServiceCode")]
ServiceCode = 4,

[EnumMember(Value = "ServiceEditionCode")]
ServiceEditionCode = 5,

[EnumMember(Value = "ApplicationId")]
ApplicationId = 6,
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
Expand Down
9 changes: 3 additions & 6 deletions backend/src/Designer/Models/Reference.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
namespace Altinn.Studio.Designer.Models;

public record Reference(ReferenceType Type, string LayoutSetName, string Id, string NewId = null);
using Altinn.Studio.Designer.Enums;

public enum ReferenceType
namespace Altinn.Studio.Designer.Models
{
LayoutSet,
Layout,
Component
public record Reference(ReferenceType Type, string LayoutSetName, string Id, string NewId = null);
}
4 changes: 2 additions & 2 deletions backend/src/Designer/Models/ResourceReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ResourceReference
/// The source the reference identifier points to
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public ReferenceSource? ReferenceSource { get; set; }
public ResourceReferenceSource? ReferenceSource { get; set; }

/// <summary>
/// The reference identifier
Expand All @@ -24,6 +24,6 @@ public class ResourceReference
/// The reference type
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public ReferenceType? ReferenceType { get; set; }
public ResourceReferenceType? ReferenceType { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Altinn.App.Core.Internal.Process.Elements;
using Altinn.App.Core.Models;
using Altinn.Studio.DataModeling.Metamodel;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Exceptions.AppDevelopment;
using Altinn.Studio.Designer.Helpers;
using Altinn.Studio.Designer.Infrastructure.GitRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Collections.Generic;
using Altinn.Studio.Designer.Configuration;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using Altinn.Studio.Designer.TypedHttpClients.Altinn2Metadata;
using Designer.Tests.Controllers.ApiTests;
using Designer.Tests.Mocks;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Moq;
Expand Down Expand Up @@ -38,7 +36,7 @@ protected static List<ResourceReference> GetTestResourceReferences()
{
List<ResourceReference> resourceReferences = new List<ResourceReference>
{
new ResourceReference { Reference = string.Empty, ReferenceSource = ReferenceSource.Default, ReferenceType = ReferenceType.Default }
new ResourceReference { Reference = string.Empty, ReferenceSource = ResourceReferenceSource.Default, ReferenceType = ResourceReferenceType.Default }
};

return resourceReferences;
Expand Down

0 comments on commit 9c6dbb9

Please sign in to comment.