Skip to content
Snippets Groups Projects
Commit 98e3995e authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Merge branch 'dev' into 'main'

Release: Sprint/2022 12 :robot:

See merge request !4
parents 04bf9e9d 665e08ea
No related branches found
No related tags found
1 merge request!4Release: Sprint/2022 12 :robot:
Pipeline #749503 passed
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Metadata;
using VDS.RDF;
namespace SQL2Linked.Implementations
{
public class UserStructuralData : StructuralData<User, UserModel>
{
public readonly string UserUrlPrefix = "https://purl.org/coscine/users";
public readonly Uri RdfType = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
public readonly Uri FoafPerson = new("http://xmlns.com/foaf/0.1/Person");
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<User> entries)
{
// ToDo: Implement
throw new NotImplementedException();
var graphs = new List<IGraph>();
foreach (var entry in entries)
{
var userGraphName = $"{UserUrlPrefix}/{entry.Id}";
var graph = RdfStoreConnector.GetGraph(userGraphName);
// check if a triple with a foaf:Person already exists in the user graph
var getTriples = graph.GetTriplesWithObject(FoafPerson);
if (!getTriples.Any())
{
// check if a user graph already exists
var exists = RdfStoreConnector.HasGraph(userGraphName);
if (!exists)
{
RdfStoreConnector.CreateNamedGraph(userGraphName);
}
graph.Assert(
new Triple(
graph.CreateBlankNode(),
graph.CreateUriNode(RdfType),
graph.CreateUriNode(FoafPerson)
)
);
graphs.Add(graph);
Console.WriteLine($"Will migrate user '{entry.DisplayName}' with id '{entry.Id}'.");
}
else
{
Console.WriteLine($"Will NOT migrate user '{entry.DisplayName}' with id '{entry.Id}'.");
}
}
return graphs;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment