Skip to content
Snippets Groups Projects
Commit 667e0540 authored by Hanna Führ's avatar Hanna Führ
Browse files

WIP: first preparations (coscine/issues#2084)

parent f1f3840d
No related branches found
No related tags found
1 merge request!9New: Migrate resource structured data to linked data
Pipeline #773037 skipped
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Configuration;
using VDS.RDF;
namespace SQL2Linked.Implementations
{
public class ResourceStructuralData : StructuralData<Resource, ResourceModel>
{
public readonly Uri org = new("http://www.w3.org/ns/org#");
public readonly Uri dcat = new("http://www.w3.org/ns/dcat#");
public readonly Uri dcterms = new("http://purl.org/dc/terms/");
public readonly Uri acl = new("http://www.w3.org/ns/auth/acl#");
public readonly Uri foaf = new("http://xmlns.com/foaf/0.1/");
public readonly Uri pim = new("http://www.w3.org/ns/pim/space#");
public readonly Uri RdfType = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<Resource> entries)
{
// ToDo: Implement
throw new NotImplementedException();
var graphs = new List<IGraph>();
string ResourceUrlPrefix = "https://hdl.handle.org/" + Prefix;
foreach (var entry in entries)
{
var resourceTypeGraphName = $"{ResourceUrlPrefix}/{entry.Id}";
//var graphA = RdfStoreConnector.CreateNamedGraph(resourceTypeGraphName);
var graph = RdfStoreConnector.GetGraph(resourceTypeGraphName);
/*graph.Assert(
new Triple(
graph.CreateUriNode(new Uri(resourceTypeGraphName)),
graph.CreateUriNode(RdfType),
graph.CreateUriNode(new Uri(dcat, "Catalog"))
)
);*/
AssertToGraphUriNode(graph, resourceTypeGraphName, RdfType, new Uri(dcat + "Catalog"));
graphs.Add(graph);
}
return graphs;
}
public void AssertToGraphUriNode(IGraph graph, string graphSubject, Uri graphPredicate, Uri graphObject)
{
graph.Assert(
new Triple(
graph.CreateUriNode(new Uri(graphSubject)),
graph.CreateUriNode(graphPredicate),
graph.CreateUriNode(graphObject)
)
);
}
public void AssertToGraphLiteralNode(IGraph graph, Uri graphSubject, Uri graphPredicate, string graphObject)
{
}
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ if (dummyMode)
Console.WriteLine("\nBegin SQL 2 Linked Data migration");
var roleStructuralData = new RoleStructuralData();
/*var roleStructuralData = new RoleStructuralData();
roleStructuralData.Migrate(dummyMode);
var userStructuralData = new UserStructuralData();
......@@ -19,7 +19,7 @@ var resourceTypeStructuralData = new ResourceTypeStructuralData();
resourceTypeStructuralData.Migrate(dummyMode);
var projectStructuralData = new ProjectStructuralData();
projectStructuralData.Migrate(dummyMode);
projectStructuralData.Migrate(dummyMode);*/
var resourceStructuralData = new ResourceStructuralData();
resourceStructuralData.Migrate(dummyMode);
......
......@@ -10,12 +10,14 @@ namespace SQL2Linked
public T Model { get; init; }
public ConsulConfiguration Configuration { get; init; }
public RdfStoreConnector RdfStoreConnector { get; init; }
public static string Prefix { get; set; }
public StructuralData()
{
Configuration = new ConsulConfiguration();
RdfStoreConnector = new RdfStoreConnector(Configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
Model = new T();
Prefix = Configuration.GetStringAndWait("coscine/global/epic/prefix");
}
public abstract IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<S> entries);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment