Skip to content
Snippets Groups Projects
Select Git revision
  • 284f7d337b0ba5a0fe01f4c66536a39ea63c4d2f
  • main default protected
  • gitkeep
  • dev protected
  • Issue/2914-trellisMigrator
  • Issue/2847-reporting
  • Hotfix/2776-workingNewVersion
  • Hotfix/xxxx-correctAssignments
  • Issue/2666-adminCronjobs-theSequal
  • Issue/2666-adminCronjobs
  • Issue/2518-docs
  • Hotfix/xxxx-coscineGraph
  • Issue/2304-virtuosoRoars
  • Fix/v0.1.7-dependencies
  • Hotfix/2212-fixFiles
  • Issue/2222-resourceDateCreated
  • Issue/2221-projectDateCreated
  • Hotfix/xxxx-changeUrls
  • Issue/1321-pidEnquiryOverhaul
  • Issue/1782-structualDataIntegration
  • Issue/2084-migrateResourceStructuralData
  • v0.1.24
  • v0.1.23
  • v0.1.22
  • v0.1.21
  • v0.1.20
  • v0.1.19
  • v0.1.18
  • v0.1.17
  • v0.1.16
  • v0.1.15
  • v0.1.14
  • v0.1.13
  • v0.1.12
  • v0.1.11
  • v0.1.10
  • v0.1.9
  • v0.1.7
  • v0.1.8
  • v0.1.6
  • v0.1.5
41 results

ProjectStructuralData.cs

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ProjectStructuralData.cs 10.43 KiB
    using Coscine.Database.DataModel;
    using Coscine.Database.Models;
    using Coscine.Database.Util;
    using VDS.RDF;
    
    namespace SQL2Linked.Implementations
    {
        public class ProjectStructuralData : StructuralData<Project, ProjectModel>
        {
            public readonly Uri org = new("http://www.w3.org/ns/org#");
            public readonly Uri dcat = new("http://www.w3.org/ns/dcat#");
            public readonly Uri dcterms = new("http://purl.org/dc/terms/");
            public readonly Uri foaf = new("http://xmlns.com/foaf/0.1/");
            public readonly Uri vcard = new("http://www.w3.org/2006/vcard/ns#");
            public readonly Uri rdf = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
            public readonly Uri cosc = new("https://purl.org/coscine/");
            private VisibilityModel VisibilityModel = new VisibilityModel();
            private ProjectRoleModel ProjectRoleModel = new ProjectRoleModel();
            private ProjectResourceModel ProjectResourceModel = new ProjectResourceModel();
    
            // Override to also receive deleted projects
            public override IEnumerable<Project> GetAll()
            {
                return DatabaseConnection.ConnectToDatabase((db) =>
                {
                    return
                        (from tableEntry in Model.GetITableFromDatabase(db)
                         select tableEntry).ToList();
                });
            }
    
            public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<Project> entries)
            {
                IEnumerable<Visibility> visibilities = VisibilityModel.GetAll();
                IEnumerable<ProjectRole> projectRoles = ProjectRoleModel.GetAll();
                IEnumerable<ProjectResource> projectResources = ProjectResourceModel.GetAll();
    
                var graphs = new List<IGraph>();
                var projectUrlHandlePrefix = "https://hdl.handle.net/" + Prefix;
                var projectUrlPrefix = "https://purl.org/coscine/projects";
                var resourceUrlPrefix = "https://purl.org/coscine/resources";
    
                foreach (var entry in entries)
                {
                    var projectGraphName = $"{projectUrlPrefix}/{entry.Id}";
                    var projectHandleName = $"{projectUrlHandlePrefix}/{entry.Id}";
    
                    var graph = new Graph();
                    graph.BaseUri = new Uri(projectGraphName);
    
                    AssertToGraphUriNode(graph, projectGraphName, rdf + "type", dcat + "Catalog");
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {rdf}type {dcat}Catalog'. ");
    
                    AssertToGraphUriNode(graph, projectGraphName, rdf + "type", org + "OrganizationalCollaboration");
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {rdf}type {org}OrganizationalCollaboration'. ");
    
                    AssertToGraphUriNode(graph, projectGraphName, rdf + "type", vcard + "Group");
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {rdf}type {vcard}Group'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcterms + "title", entry.ProjectName);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcterms}title {entry.ProjectName}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcterms + "description", entry.Description);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcterms}description {entry.Description}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcat + "startDate", entry.StartDate.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#dateTime"));
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}startDate {entry.StartDate}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcat + "endDate", entry.EndDate.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#dateTime"));
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}endDate {entry.EndDate}'. ");