Skip to content
Snippets Groups Projects
Select Git revision
  • 744269395b0f781832bcd495f5b0405fe21ab1b4
  • master default protected
  • dev_2022
  • patch-1
  • develop
  • 50-use-ubuntus-libhidapi
  • issue-highLevelDispatch
  • issue-highLevelDesign
  • issue-motorStartBug
  • issue-commandLayerDesign
  • v1.0
  • v0.4-rc.13
  • v0.4-rc.12
  • v0.4-rc.11
  • v0.4-rc.10
  • v0.4-rc.9
  • v0.3-rc.8
  • v0.3-rc.7
  • v0.3-rc.6
  • v0.3-rc.5
  • v0.3-rc.4
  • v0.3-rc.3
  • v0.3-rc.2
  • v0.3-rc.1
  • v0.3-rc
  • v0.2
  • v0.1.1
  • v0.1
28 results

COMGetSubCodes.m

Blame
    • Tim Stadtmann's avatar
      912bb027
      Merge branch 'feature-display' · 912bb027
      Tim Stadtmann authored
      Implements overriden display-function and adapts comments to MATLAB's
      doc and help function in order to deliver a cleaner interface.
      Also, for some reason, all file-access modes in /source are marked as
      changed.
      912bb027
      History
      Merge branch 'feature-display'
      Tim Stadtmann authored
      Implements overriden display-function and adapts comments to MATLAB's
      doc and help function in order to deliver a cleaner interface.
      Also, for some reason, all file-access modes in /source are marked as
      changed.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ProjectStructuralData.cs 8.89 KiB
    using Coscine.Database.DataModel;
    using Coscine.Database.Models;
    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();
    
            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>();
                string projectUrlPrefix = "https://hdl.handle.net/" + Prefix;
    
                foreach (var entry in entries)
                {
                    var projectGraphName = $"{projectUrlPrefix}/{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());
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}startDate {entry.StartDate}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcat + "endDate", entry.EndDate.ToString());
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}endDate {entry.EndDate}'. ");
    
                    if (!string.IsNullOrWhiteSpace(entry.Keywords))
                    {
                        var listKeywords = entry.Keywords.Split(';').ToList();
                        foreach (var keyword in listKeywords)
                        {
                            AssertToGraphLiteralNode(graph, projectGraphName, dcterms + "subject", keyword);
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcterms}subject {keyword}'. ");
                        }
                    }
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcterms + "alternative", entry.DisplayName);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcterms}alternative {entry.DisplayName}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, dcterms + "rightsHolder", entry.PrincipleInvestigators);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcterms}rightsHolder {entry.PrincipleInvestigators}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, "https://schema.org/funding", entry.GrantId);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} https://schema.org/funding {entry.GrantId}'. ");
    
                    foreach (var visibility in visibilities)
                    {
                        if (entry.VisibilityId == visibility.Id && visibility.DisplayName.Contains("Public"))
                        {
                            AssertToGraphUriNode(graph, projectGraphName, cosc + "terms/project#visibility", cosc + $"terms/visibility#public");
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {cosc}terms/project#visibility {cosc}terms/visibility#public'. ");
                            break;
                        }
                        else if (entry.VisibilityId == visibility.Id && visibility.DisplayName.Contains("Project Members"))
                        {
                            AssertToGraphUriNode(graph, projectGraphName, cosc + "terms/project#visibility", cosc + $"terms/visibility#projectMember");
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {cosc}terms/project#visibility {cosc}terms/visibility#projectMember'. ");
                            break;
                        }
                    }
    
                    AssertToGraphLiteralNode(graph, projectGraphName, cosc + "terms/project#deleted", entry.Deleted.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#boolean"));
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {cosc}terms/project#deleted {entry.Deleted}'. ");
    
                    AssertToGraphLiteralNode(graph, projectGraphName, cosc + "terms/project#slug", entry.Slug);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {cosc}terms/project#slug {entry.Slug}'. ");
    
                    AssertToGraphUriNode(graph, projectGraphName, foaf + "homepage", projectGraphName);
                    Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {foaf}homepage {projectGraphName}'. ");
    
                    foreach (var projectRole in projectRoles)
                    {
                        if (entry.Id == projectRole.ProjectId)
                        {
                            AssertToGraphUriNode(graph, projectGraphName, vcard + "hasMember", cosc + "users/" + projectRole.UserId);
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {vcard}hasMember {cosc}users/{projectRole.UserId}'. ");
    
                            var blankNode = graph.CreateBlankNode();
    
                            AssertToGraphBlankAndUriNode(graph, blankNode, rdf + "type", org + "Membership");
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{blankNode} {rdf}type {org}Membership'. ");
    
                            AssertToGraphBlankAndUriNode(graph, blankNode, org + "organization", projectGraphName);
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{blankNode} {org}organization {projectGraphName}'. ");
    
                            AssertToGraphBlankAndUriNode(graph, blankNode, org + "role", cosc + "roles/" + projectRole.RoleId);
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{blankNode} {org}role {cosc}roles/{projectRole.RoleId}'. ");
    
                            AssertToGraphBlankAndUriNode(graph, blankNode, org + "member", cosc + "users/" + projectRole.UserId);
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{blankNode} {org}member {cosc}users/{projectRole.UserId}'. ");
                        }
                    }
    
                    foreach (var projectResource in projectResources)
                    {
                        if (entry.Id == projectResource.ProjectId)
                        {
                            AssertToGraphUriNode(graph, projectGraphName, dcat + "catalog", $"{projectUrlPrefix}/{projectResource.ResourceId}");
                            Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}catalog {projectUrlPrefix}/{projectResource.ResourceId}'. ");
                        }
                    }
    
                    graphs.Add(graph);
                }
                return graphs;
            }
        }
    }