Skip to content
Snippets Groups Projects

Fix: Migrate resourceType structured data to linked data - fixes

Merged Hanna Führ requested to merge Issue/2083-migrateResourceTypeStructuralData into dev
1 file
+ 44
2
Compare changes
  • Side-by-side
  • Inline
@@ -6,10 +6,52 @@ namespace SQL2Linked.Implementations
@@ -6,10 +6,52 @@ namespace SQL2Linked.Implementations
{
{
public class ResourceTypeStructuralData : StructuralData<ResourceType, ResourceTypeModel>
public class ResourceTypeStructuralData : StructuralData<ResourceType, ResourceTypeModel>
{
{
 
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 DcatDataService = new ("http://www.w3.org/ns/dcat#DataService");
 
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<ResourceType> entries)
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<ResourceType> entries)
{
{
// ToDo: Implement
throw new NotImplementedException();
var graphs = new List<IGraph>();
 
 
foreach (var entry in entries)
 
{
 
var resourceTypeGraphName = $"{ResourceTypeUrlPrefix}/{entry.Id}";
 
var graph = RdfStoreConnector.GetGraph(resourceTypeGraphName);
 
 
// check if a triple with a dcat:DataService already exists in the resourcetype graph
 
var getTriples = graph.GetTriplesWithObject(DcatDataService);
 
 
if (!getTriples.Any())
 
{
 
// check if a resourcetype graph already exists
 
var exists = RdfStoreConnector.HasGraph(resourceTypeGraphName);
 
 
if (!exists)
 
{
 
RdfStoreConnector.CreateNamedGraph(resourceTypeGraphName);
 
}
 
 
graph.Assert(
 
new Triple(
 
graph.CreateBlankNode(),
 
graph.CreateUriNode(RdfType),
 
graph.CreateUriNode(DcatDataService)
 
)
 
);
 
 
graphs.Add(graph);
 
 
Console.WriteLine($"Will migrate resource type '{entry.DisplayName}' with id '{entry.Id}'.");
 
}
 
else
 
{
 
Console.WriteLine($"Will NOT migrate resource type '{entry.DisplayName}' with id '{entry.Id}'.");
 
}
 
}
 
return graphs;
}
}
}
}
 
}
}
 
\ No newline at end of file
Loading