コード例 #1
0
        private Graph GenerateDefinitionsGraph(JObject metadataJson)
        {
            var definitionsGraph  = new Graph();
            var metadataExtractor = new MetdataExtractor();

            ProgressLog.Info("Extracting column property definitions");
            metadataExtractor.GenerateColumnDefinitions(metadataJson, definitionsGraph);
            return(definitionsGraph);
        }
コード例 #2
0
        public void ItAssertsRdfType()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"));
            var g   = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, null);
            var expectSubject = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));

            GraphShouldContainRdfTypeStatement(g, expectSubject);
        }
コード例 #3
0
        public void ItAssertsVoidTriples()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"));
            var g   = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, null);
            var expectSubject     = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));
            var voidTriples       = g.CreateUriNode(new Uri("http://rdfs.org/ns/void#triples"));
            var expectTripleCount = g.CreateLiteralNode("100", new Uri("http://www.w3.org/2001/XMLSchema#integer"));
            var statements        = g.GetTriplesWithSubjectPredicate(expectSubject, voidTriples);

            statements.Count().Should().Be(1);
            statements.Should().Contain(x => x.Object.Equals(expectTripleCount));
        }
コード例 #4
0
        public void ItCanProcessDcTitleStringField()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"),
                                  new JProperty("dc:title", "This is a title"));
            var g = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, null);

            var expectSubject   = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));
            var expectPredicate = g.CreateUriNode(new Uri("http://purl.org/dc/terms/title"));

            var titleStatement = g.GetTriplesWithSubjectPredicate(expectSubject, expectPredicate).FirstOrDefault();

            titleStatement.Should().NotBeNull();
            titleStatement.Object.Should().BeAssignableTo <ILiteralNode>().Which.Value.Should().Be("This is a title");
        }
コード例 #5
0
        public void ItCanProcessDcLicenseUrlField()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"),
                                  new JProperty("dc:license", "http://creativecommons.org/ns#cc-0"));
            var g = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, null);

            var expectSubject    = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));
            var expectPredicate  = g.CreateUriNode(new Uri("http://purl.org/dc/terms/license"));
            var licenseStatement = g.GetTriplesWithSubjectPredicate(expectSubject, expectPredicate).FirstOrDefault();

            licenseStatement.Should().NotBeNull();
            licenseStatement.Object.Should()
            .BeAssignableTo <IUriNode>()
            .Which.Uri.Should()
            .Be(new Uri("http://creativecommons.org/ns#cc-0"));
        }
コード例 #6
0
        public void ItAssertsModifiedDate()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"),
                                  new JProperty("dc:license", "http://creativecommons.org/ns#cc-0"));
            var g = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, new DateTime(2017, 01, 02, 03, 04, 05));
            var expectSubject   = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));
            var expectPredicate = g.CreateUriNode(new Uri("http://purl.org/dc/terms/modified"));

            var statements = g.GetTriplesWithSubjectPredicate(expectSubject, expectPredicate).ToList();

            statements.Count.Should().Be(1);
            var val = statements[0].Object as ILiteralNode;

            val.Should().NotBeNull();
            val.Value.Should().Be("2017-01-02");
            val.DataType.ToString().Should().Be("http://www.w3.org/2001/XMLSchema#date");
        }
コード例 #7
0
        private Graph GenerateMetadataGraph(Uri datasetUri, Uri publisherIri, JObject metadataJson, IEnumerable <Uri> downloadUris, IGraph dataGraph)
        {
            var metadataGraph     = new Graph();
            var metadataExtractor = new MetdataExtractor();

            ProgressLog.Info("Extracting dataset metadata");
            metadataExtractor.Run(metadataJson, metadataGraph, publisherIri, dataGraph.Triples.Count, DateTime.UtcNow);
            var dsNode          = metadataGraph.CreateUriNode(datasetUri);
            var ddNode          = metadataGraph.CreateUriNode(new Uri("http://rdfs.org/ns/void#dataDump"));
            var exampleResource = metadataGraph.CreateUriNode(new Uri("http://rdfs.org/ns/void#exampleResource"));

            foreach (var downloadUri in downloadUris)
            {
                metadataGraph.Assert(dsNode, ddNode, metadataGraph.CreateUriNode(downloadUri));
            }
            foreach (var distinctSubject in dataGraph.Triples.Select(t => t.Subject).OfType <IUriNode>().Distinct().Take(10))
            {
                metadataGraph.Assert(dsNode, exampleResource, distinctSubject);
            }
            return(metadataGraph);
        }
コード例 #8
0
        public void ItCanProcessMultipleDcatKeywords()
        {
            var ex  = new MetdataExtractor();
            var obj = new JObject(new JProperty("url", "http://datadock.io/test/repo/data"),
                                  new JProperty("dcat:keyword", new JArray(new JValue("one"), new JValue("two"), new JValue("three"))));
            var g = new Graph();

            ex.Run(obj, g, new Uri("http://datadock.io/test/repo/publisher"), 100, null);

            var expectSubject   = g.CreateUriNode(new Uri("http://datadock.io/test/repo/data"));
            var expectPredicate = g.CreateUriNode(new Uri("http://www.w3.org/ns/dcat#keyword"));

            var statements = g.GetTriplesWithSubjectPredicate(expectSubject, expectPredicate).ToList();

            statements.Count.Should().Be(3);
            foreach (var statement in statements)
            {
                statement.Object.Should()
                .BeAssignableTo <ILiteralNode>()
                .Which.Value.Should()
                .BeOneOf("one", "two", "three");
            }
        }