Skip to content
Snippets Groups Projects
Commit ff44aefc authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Add User Displayname

parent 108c0d28
No related branches found
No related tags found
1 merge request!9New: Migrate resource structured data to linked data
Pipeline #778638 skipped
......@@ -10,6 +10,7 @@ namespace SQL2Linked.Implementations
public readonly string UserUrlPrefix = "https://purl.org/coscine/users";
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/");
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<User> entries)
{
var graphs = new List<IGraph>();
......@@ -21,11 +22,16 @@ namespace SQL2Linked.Implementations
// check if a triple with a foaf:Person already exists in the user graph
var getTriples = graph.GetTriplesWithObject(new Uri(foaf + "Person"));
// check if the current display name is already applied in the user graph
var getTriplesName = graph.GetTriplesWithPredicate(new Uri(foaf + "name"));
if (!getTriples.Any())
if (!getTriples.Any() || !getTriplesName.Any((triple) => triple.Object.ToString() == entry.DisplayName))
{
AssertToGraphUriNode(graph, userGraphName, rdf + "type", foaf + "Person");
graph.Retract(getTriplesName);
AssertToGraphLiteralNode(graph, userGraphName, foaf + "name", entry.DisplayName);
graphs.Add(graph);
Console.WriteLine($"Will migrate user '{entry.DisplayName}' with id '{entry.Id}'.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment