Skip to content
Snippets Groups Projects
Commit b6e5604e authored by Sandra Westerhoff's avatar Sandra Westerhoff
Browse files

Merge branch 'Issue/1782-structualDataIntegration' into 'dev'

Fix: Only migrate users which have the TOS accepted

See merge request !12
parents c8a5ef4c b7c86433
No related branches found
No related tags found
2 merge requests!14Release: Sprint/2022 17 :robot:,!12Fix: Only migrate users which have the TOS accepted
Pipeline #792553 passed
using Coscine.Database.DataModel;
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using VDS.RDF;
using VDS.RDF.Query;
......@@ -92,6 +92,12 @@ namespace SQL2Linked.Implementations
AssertToGraphLiteralNode(graph, resourceGraphName, dcterms + "description", entry.Description);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}description {entry.Description}'. ");
// Skipping broken resources
if (string.IsNullOrWhiteSpace(entry.ApplicationProfile))
{
continue;
}
AssertToGraphUriNode(graph, resourceGraphName, dcterms + "conformsTo", entry.ApplicationProfile);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}conformsTo {entry.ApplicationProfile}'. ");
......@@ -139,6 +145,9 @@ namespace SQL2Linked.Implementations
AssertToGraphBlankAndUriNode(graph, blankNode, acl + "accessTo", resourceGraphName);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {resourceGraphName}'. ");
AssertToGraphBlankAndUriNode(graph, blankNode, acl + "default", resourceGraphName);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}default {resourceGraphName}'. ");
AssertToGraphBlankAndUriNode(graph, blankNode, acl + "mode", acl + "Control");
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {acl}Control'. ");
}
......
......@@ -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>();
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment