Skip to content
Snippets Groups Projects
Select Git revision
  • 300ca67da780fcf6b10d8f9a343a1313fb5c8cf9
  • master default protected
  • gitkeep
  • dev protected
  • Issue/2464-invalidateMeta
  • Issue/2309-docs
  • Issue/2462-removeTraces
  • Hotfix/2459-EncodingPath
  • Hotfix/2452-linkedDeletion
  • Issue/1792-newMetadataStructure
  • Hotfix/2371-fixGitLabinRCV
  • Fix/xxxx-activateGitlab
  • Issue/2349-gitlabHttps
  • Issue/2287-guestRole
  • Issue/2102-gitLabResTypeRCV
  • Hotfix/2254-fixContentLenghtCalculation
  • Fix/xxxx-resourceVisibility
  • Issue/1951-quotaImplementation
  • Issue/2162-fixFolderResponse
  • Issue/2158-emailServicedesk
  • Hotfix/2141-fileUploadErrors
  • v3.3.4
  • v3.3.3
  • v3.3.2
  • v3.3.1
  • v3.3.0
  • v3.2.3
  • v3.2.2
  • v3.2.1
  • v3.2.0
  • v3.1.2
  • v3.1.1
  • v3.1.0
  • v3.0.6
  • v3.0.5
  • v3.0.4
  • v3.0.3
  • v3.0.2
  • v3.0.1
  • v3.0.0
  • v2.8.2
41 results

Blob.csproj

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    UserStructuralData.cs 1.89 KiB
    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 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>();
    
                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(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() || !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}'.");
                    }
                    else
                    {
                        Console.WriteLine($"Will NOT migrate user '{entry.DisplayName}' with id '{entry.Id}'.");
                    }
                }
                return graphs;
            }
        }
    }