Skip to content
Snippets Groups Projects
Commit 92f89078 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs Committed by Sandra Westerhoff
Browse files

Fix: Working new version

parent 4a6ff285
No related branches found
No related tags found
1 merge request!29Fix: Working new version
......@@ -33,7 +33,7 @@ public class ProjectStructuralData : StructuralData<ProjectAdminDto>
public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ProjectAdminDto> entries)
{
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");
var coscineGraph = new Graph
......
......@@ -3,6 +3,7 @@ using Coscine.ApiClient.Core.Model;
using Newtonsoft.Json;
using SQL2Linked.Utils;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations;
......@@ -34,7 +35,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
public override async Task<IEnumerable<IGraph>> ConvertToLinkedDataAsync(IEnumerable<ResourceAdminDto> entries)
{
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");
foreach (var entry in entries)
......@@ -120,7 +121,32 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
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"));
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)
{
......@@ -151,7 +177,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
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"));
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);
......
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
......@@ -16,7 +16,7 @@
</PropertyGroup>
<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="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
......
......@@ -5,6 +5,30 @@
/// </summary>
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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment