Skip to content
Snippets Groups Projects
Commit 28df7884 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Merge branch 'Issue/2083-migrateResourceTypeStructuralData' into 'dev'

Fix: Migrate resourceType structured data to linked data - fixes

See merge request !7
parents e380f0fd 6e4b27aa
No related branches found
No related tags found
2 merge requests!8Release: Sprint/2022 12 :robot:,!7Fix: Migrate resourceType structured data to linked data - fixes
Pipeline #751386 passed
...@@ -9,6 +9,7 @@ namespace SQL2Linked.Implementations ...@@ -9,6 +9,7 @@ namespace SQL2Linked.Implementations
public readonly string ResourceTypeUrlPrefix = "https://purl.org/coscine/resourcetype"; public readonly string ResourceTypeUrlPrefix = "https://purl.org/coscine/resourcetype";
public readonly Uri RdfType = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); public readonly Uri RdfType = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
public readonly Uri DcatDataService = new ("http://www.w3.org/ns/dcat#DataService"); public readonly Uri DcatDataService = new ("http://www.w3.org/ns/dcat#DataService");
public readonly Uri dctermsTitle = new("http://purl.org/dc/terms/title");
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<ResourceType> entries) public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<ResourceType> entries)
{ {
...@@ -21,25 +22,47 @@ namespace SQL2Linked.Implementations ...@@ -21,25 +22,47 @@ namespace SQL2Linked.Implementations
var graph = RdfStoreConnector.GetGraph(resourceTypeGraphName); var graph = RdfStoreConnector.GetGraph(resourceTypeGraphName);
// check if a triple with a dcat:DataService already exists in the resourcetype graph // check if a triple with a dcat:DataService already exists in the resourcetype graph
var getTriples = graph.GetTriplesWithObject(DcatDataService); var getTriplesDcatDataService = graph.GetTriplesWithObject(DcatDataService);
if (!getTriples.Any()) if (!getTriplesDcatDataService.Any())
{ {
graph.Assert( graph.Assert(
new Triple( new Triple(
graph.CreateBlankNode(), graph.CreateUriNode(new Uri(resourceTypeGraphName)),
graph.CreateUriNode(RdfType), graph.CreateUriNode(RdfType),
graph.CreateUriNode(DcatDataService) graph.CreateUriNode(DcatDataService)
) )
); );
graphs.Add(graph); Console.WriteLine($"For resource type '{entry.DisplayName}' will migrate triple '{graph.BaseUri}' a dcat:DataService. ");
}
else
{
Console.WriteLine($"For resource type '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri}' a dcat:DataService. ");
}
// check if a triple with dcterms:title '{entry.DisplayName}' already exists in the role graph
var getTriplesDctermsTitle = graph.GetTriplesWithPredicate(dctermsTitle);
Console.WriteLine($"Will migrate resource type '{entry.DisplayName}' with id '{entry.Id}'."); if (!getTriplesDctermsTitle.Any())
{
graph.Assert(
new Triple(
graph.CreateUriNode(new Uri(resourceTypeGraphName)),
graph.CreateUriNode(dctermsTitle),
graph.CreateLiteralNode(entry.DisplayName)
)
);
Console.WriteLine($"For resource type '{entry.DisplayName}' will migrate triple '{graph.BaseUri}' dcterms:title '{entry.DisplayName}'. ");
} }
else else
{ {
Console.WriteLine($"Will NOT migrate resource type '{entry.DisplayName}' with id '{entry.Id}'."); Console.WriteLine($"For resource type '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri}' dcterms:title '{entry.DisplayName}'. ");
}
if (!getTriplesDcatDataService.Any() || !getTriplesDctermsTitle.Any())
{
graphs.Add(graph);
} }
} }
return graphs; return graphs;
......
...@@ -27,7 +27,7 @@ namespace SQL2Linked.Implementations ...@@ -27,7 +27,7 @@ namespace SQL2Linked.Implementations
{ {
graph.Assert( graph.Assert(
new Triple( new Triple(
graph.CreateBlankNode(), graph.CreateUriNode(new Uri(userGraphName)),
graph.CreateUriNode(RdfType), graph.CreateUriNode(RdfType),
graph.CreateUriNode(FoafPerson) graph.CreateUriNode(FoafPerson)
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment