Skip to content
Snippets Groups Projects
Commit 55f0274d authored by Sandra Westerhoff's avatar Sandra Westerhoff
Browse files

Merge branch 'Hotfix/2776-workingNewVersion' into 'main'

Fix: Working new version

See merge request !29
parents 4a6ff285 92f89078
No related branches found
No related tags found
1 merge request!29Fix: Working new version
Pipeline #1223624 passed
...@@ -33,7 +33,7 @@ public class ProjectStructuralData : StructuralData<ProjectAdminDto> ...@@ -33,7 +33,7 @@ public class ProjectStructuralData : StructuralData<ProjectAdminDto>
public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ProjectAdminDto> entries) public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ProjectAdminDto> entries)
{ {
var graphs = new List<IGraph>(); var graphs = new List<IGraph>();
var coscineHandlePrefix = UriHelper.TryCombineUri(RdfUris.HandlePrefix, _pidConfiguration.Prefix) var coscineHandlePrefix = UriHelper.TryCombinePath(RdfUris.HandlePrefix, _pidConfiguration.Prefix)
?? throw new Exception("Could not combine handle prefix with PID prefix"); ?? throw new Exception("Could not combine handle prefix with PID prefix");
var coscineGraph = new Graph var coscineGraph = new Graph
......
...@@ -3,6 +3,7 @@ using Coscine.ApiClient.Core.Model; ...@@ -3,6 +3,7 @@ using Coscine.ApiClient.Core.Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using SQL2Linked.Utils; using SQL2Linked.Utils;
using VDS.RDF; using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations; namespace SQL2Linked.Implementations;
...@@ -34,7 +35,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto> ...@@ -34,7 +35,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ResourceAdminDto> entries) public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ResourceAdminDto> entries)
{ {
var graphs = new List<IGraph>(); var graphs = new List<IGraph>();
var coscineHandlePrefix = UriHelper.TryCombineUri(RdfUris.HandlePrefix, _pidConfiguration.Prefix) var coscineHandlePrefix = UriHelper.TryCombinePath(RdfUris.HandlePrefix, _pidConfiguration.Prefix)
?? throw new Exception("Could not combine handle prefix with PID prefix"); ?? throw new Exception("Could not combine handle prefix with PID prefix");
foreach (var entry in entries) foreach (var entry in entries)
...@@ -120,7 +121,32 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto> ...@@ -120,7 +121,32 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.FoafHomepage} {resourceGraphName}'. "); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.FoafHomepage} {resourceGraphName}'. ");
AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.CoscineTermsResourceDeleted, entry.Deleted.ToString().ToLower(), new Uri("http://www.w3.org/2001/XMLSchema#boolean")); AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.CoscineTermsResourceDeleted, entry.Deleted.ToString().ToLower(), new Uri("http://www.w3.org/2001/XMLSchema#boolean"));
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.CoscineTermsResourceDeleted} {entry.Deleted}'. "); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.CoscineTermsResourceDeleted} {entry.Deleted}'. ");
// Reinstate the catalog assignments
var oldResourceGraphResponse = await _adminApi.GetMetadataGraphAsync(
resourceGraphName.AbsoluteUri,
RdfFormat.TextTurtle
);
if (oldResourceGraphResponse is not null)
{
var oldResourceGraph = new Graph();
var ttlparser = new TurtleParser();
ttlparser.Load(oldResourceGraph, new StringReader(oldResourceGraphResponse.Data.Content));
foreach (var result in oldResourceGraph.GetTriplesWithPredicate(RdfUris.DcatCatalog))
{
if (result.Object.NodeType == NodeType.Uri)
{
var catalogedUri = result.Object as IUriNode;
if (catalogedUri is not null)
{
AssertToGraphUriNode(graph, resourceGraphName, RdfUris.DcatCatalog, catalogedUri.Uri);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcatCatalog} {catalogedUri.Uri}'. ");
}
}
}
}
foreach (var projectResource in entry.ProjectResources) foreach (var projectResource in entry.ProjectResources)
{ {
...@@ -151,7 +177,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto> ...@@ -151,7 +177,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
if (entry.DateCreated is not null && entry.DateCreated.HasValue) if (entry.DateCreated is not null && entry.DateCreated.HasValue)
{ {
AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.DcTermsCreated, entry.DateCreated.Value.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#dateTime")); AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.DcTermsCreated, entry.DateCreated.Value.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#dateTime"));
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcTermsCreated} {entry.DateCreated}'. "); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcTermsCreated} {entry.DateCreated}'. ");
} }
graphs.Add(graph); graphs.Add(graph);
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Coscine.ApiClient" Version="1.3.0" /> <PackageReference Include="Coscine.ApiClient" Version="1.3.1" />
<PackageReference Include="dotNetRdf" Version="3.1.1" /> <PackageReference Include="dotNetRdf" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
......
...@@ -5,6 +5,30 @@ ...@@ -5,6 +5,30 @@
/// </summary> /// </summary>
public static class UriHelper public static class UriHelper
{ {
/// <summary>
///
/// </summary>
/// <param name="baseUri"></param>
/// <param name="relativePath"></param>
/// <returns></returns>
public static Uri? TryCombinePath(Uri baseUri, string relativePath)
{
Uri.TryCreate(baseUri, relativePath + "/", out Uri? result);
return result;
}
/// <summary>
///
/// </summary>
/// <param name="baseUri"></param>
/// <param name="relativePath"></param>
/// <returns></returns>
public static Uri? TryCombinePath(Uri baseUri, Guid relativePath)
{
Uri.TryCreate(baseUri, relativePath.ToString() + "/", out Uri? result);
return result;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment