diff --git a/src/SQL2Linked/Implementations/ResourceStructuralData.cs b/src/SQL2Linked/Implementations/ResourceStructuralData.cs index 7e1b030b7e5a9f4db5c23cc2599a1cae1de6aa0d..7541a74f397dc709fb9a212bd27b14ee442847cc 100644 --- a/src/SQL2Linked/Implementations/ResourceStructuralData.cs +++ b/src/SQL2Linked/Implementations/ResourceStructuralData.cs @@ -1,15 +1,65 @@ 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 diff --git a/src/SQL2Linked/Program.cs b/src/SQL2Linked/Program.cs index b9d0aa6a150c349541fa09512110b842c5e6e833..b89ec63284fe936f5ef1d088c85ea7c1160ae36d 100644 --- a/src/SQL2Linked/Program.cs +++ b/src/SQL2Linked/Program.cs @@ -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); diff --git a/src/SQL2Linked/StructuralData.cs b/src/SQL2Linked/StructuralData.cs index 78d70e490e2d9156cc7d5989e86bca52103a5ea7..301d7a0ee7ba3c6912de4de9ba158b48e07b4894 100644 --- a/src/SQL2Linked/StructuralData.cs +++ b/src/SQL2Linked/StructuralData.cs @@ -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);