From 108c0d284b03cf3057a1655129747e07aa8e9a8d Mon Sep 17 00:00:00 2001
From: Hanna Fuehr <fuehr@itc.rwth-aachen.de>
Date: Wed, 10 Aug 2022 12:04:37 +0200
Subject: [PATCH] adding graph for licenses

---
 .../Implementations/ResourceStructuralData.cs | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/SQL2Linked/Implementations/ResourceStructuralData.cs b/src/SQL2Linked/Implementations/ResourceStructuralData.cs
index 6a4ed8f..d602978 100644
--- a/src/SQL2Linked/Implementations/ResourceStructuralData.cs
+++ b/src/SQL2Linked/Implementations/ResourceStructuralData.cs
@@ -16,16 +16,18 @@ namespace SQL2Linked.Implementations
         public readonly Uri rdf = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
         public readonly Uri cosc = new("https://purl.org/coscine/");
         private VisibilityModel VisibilityModel = new VisibilityModel();
-        private ProjectResourceModel ProjectResourceModel =new ProjectResourceModel();
+        private ProjectResourceModel ProjectResourceModel = new ProjectResourceModel();
+        private LicenseModel LicenseModel = new LicenseModel();
 
         public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<Resource> entries)
         {
             IEnumerable<Visibility> visibilities = VisibilityModel.GetAll();
             IEnumerable<ProjectResource> projectResources = ProjectResourceModel.GetAll();
+            IEnumerable<License> licenses = LicenseModel.GetAll();
 
             var graphs = new List<IGraph>();
             string resourceUrlPrefix = "https://hdl.handle.net/" + Prefix;
-            
+
             foreach (var entry in entries)
             {
                 var resourceGraphName = $"{resourceUrlPrefix}/{entry.Id}";
@@ -64,6 +66,15 @@ namespace SQL2Linked.Implementations
                     }
                 }
 
+                foreach (var license in licenses)
+                {
+                    if (entry.LicenseId == license.Id)
+                    {
+                        AssertToGraphLiteralNode(graph, resourceGraphName, dcterms + "license", license.DisplayName);
+                        Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}license {license.DisplayName}'. ");
+                    }
+                }
+
                 if (entry.Keywords.Any())
                 {
                     var listKeywords = entry.Keywords.Split(';').ToList();
@@ -83,7 +94,7 @@ namespace SQL2Linked.Implementations
                 AssertToGraphUriNode(graph, resourceGraphName, dcterms + "conformsTo", entry.ApplicationProfile);
                 Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}conformsTo {entry.ApplicationProfile}'. ");
 
-                AssertToGraphLiteralNode(graph, resourceGraphName,cosc + "terms/resource#fixedValues", entry.FixedValues);
+                AssertToGraphLiteralNode(graph, resourceGraphName, cosc + "terms/resource#fixedValues", entry.FixedValues);
                 Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#fixedValues {entry.FixedValues}'. ");
 
                 AssertToGraphUriNode(graph, resourceGraphName, dcterms + "creator", cosc + $"users/{entry.Creator}");
@@ -106,7 +117,7 @@ namespace SQL2Linked.Implementations
 
                 var resultSet = QueryEndpoint.QueryWithResultSet(cmdString.ToString());
 
-                foreach(var result in resultSet)
+                foreach (var result in resultSet)
                 {
                     AssertToGraphUriNode(graph, resourceGraphName, dcat + "catalog", result[0].ToString());
                     Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcat}catalog {result[0].ToString()}'. ");
-- 
GitLab