From 2b0d6c166fc56b580b8dd52500554db60a31db02 Mon Sep 17 00:00:00 2001
From: Heinrichs <Heinrichs@itc.rwth-aachen.de>
Date: Mon, 22 Aug 2022 14:41:28 +0200
Subject: [PATCH] Fix: Only migrate users which have the TOS accepted
 (coscine/issues#1782)

---
 src/SQL2Linked/Implementations/UserStructuralData.cs | 6 ++++++
 src/SQL2Linked/StructuralData.cs                     | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/SQL2Linked/Implementations/UserStructuralData.cs b/src/SQL2Linked/Implementations/UserStructuralData.cs
index 29f8111..59a6999 100644
--- a/src/SQL2Linked/Implementations/UserStructuralData.cs
+++ b/src/SQL2Linked/Implementations/UserStructuralData.cs
@@ -11,6 +11,12 @@ namespace SQL2Linked.Implementations
         public readonly Uri rdf = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
         public readonly Uri foaf = new("http://xmlns.com/foaf/0.1/");
 
+        // Override to only transform users which have accepted the TOS
+        public override IEnumerable<User> GetAll()
+        {
+            return Model.GetAllWhere((user) => user.Tosaccepteds.Any());
+        }
+
         public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<User> entries)
         {
             var graphs = new List<IGraph>();
diff --git a/src/SQL2Linked/StructuralData.cs b/src/SQL2Linked/StructuralData.cs
index 4d2e231..9f9f113 100644
--- a/src/SQL2Linked/StructuralData.cs
+++ b/src/SQL2Linked/StructuralData.cs
@@ -25,11 +25,16 @@ namespace SQL2Linked
 
         public abstract IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<S> entries);
 
+        public virtual IEnumerable<S> GetAll()
+        {
+            return Model.GetAll();
+        }
+
         public void Migrate(bool dummyMode)
         {
             var spacer = new string('-', 35);
             Console.WriteLine($"\n{spacer}\n{typeof(T).Name}\n{spacer}");
-            var graphs = ConvertToLinkedData(Model.GetAll());
+            var graphs = ConvertToLinkedData(GetAll());
             if (!dummyMode)
             {
                 StoreGraphs(graphs);
@@ -56,6 +61,7 @@ namespace SQL2Linked
                 Console.WriteLine();
             }
         }
+
         public void AssertToGraphUriNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject)
         {
             graph.Assert(
@@ -66,6 +72,7 @@ namespace SQL2Linked
                 )
             );
         }
+
         public void AssertToGraphLiteralNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject, Uri? objectType = null)
         {
             graph.Assert(
-- 
GitLab