Beispiel #1
0
 def test_rdf(self):
     global RESOURCES
     RESOURCES = _RESOURCES
     qname_as_resource = re.compile('rdf:[a-z]+=\"\w+:\w+\"')
     for rsc in _RESOURCES:
         if not hasattr(rsc.model, 'first'):
             continue
         ctx = rsc.model.first()
         res = render('%s/rdf.mako' % rsc.name,
                      dict(ctx=ctx),
                      request=self.env['request'])
         assert not qname_as_resource.search(res)
         g = Graph()
         g.load(StringIO(res.encode('utf8') if PY2 else res))
         for predicate in ['void:inDataset', 'skos:prefLabel']:
             if predicate == 'void:inDataset' and rsc.name == 'dataset':
                 continue
             subject = URIRef(self.env['request'].resource_url(ctx))
             predicate = URIRef(rdf.url_for_qname(predicate))
             assert (subject, predicate, None) in g
     p = Parameter.get('parameter')
     res = render('parameter/rdf.mako',
                  dict(ctx=p),
                  request=self.env['request'])
     assert p.domain[0].name in res
Beispiel #2
0
 def test_rdf(self):
     qname_as_resource = re.compile('rdf:[a-z]+=\"\w+:\w+\"')
     for rsc in _RESOURCES:
         if not hasattr(rsc.model, 'first'):
             continue
         ctx = rsc.model.first()
         res = render(
             '%s/rdf.mako' % rsc.name, dict(ctx=ctx), request=self.env['request'])
         assert not qname_as_resource.search(res)
         g = Graph()
         g.load(StringIO(res))
         for predicate in ['void:inDataset', 'skos:prefLabel']:
             if predicate == 'void:inDataset' and rsc.name == 'dataset':
                 continue
             subject = URIRef(self.env['request'].resource_url(ctx))
             predicate = URIRef(rdf.url_for_qname(predicate))
             assert (subject, predicate, None) in g
     p = Parameter.get('parameter')
     res = render('parameter/rdf.mako', dict(ctx=p), request=self.env['request'])
     assert p.domain[0].name in res
Beispiel #3
0
 def __rdf__(self, request):
     if self.omegawiki:
         yield 'owl:sameAs', self.omegawiki_url
     yield 'dcterms:type', self.ontological_category
     yield 'rdf:type', url_for_qname('skos:Collection')
     for vs in self.valuesets:
         yield 'skos:member', request.resource_url(vs.values[0])
     for rel in self.rel_to:
         if rel.description == 'broader':
             yield 'skos:broader', request.resource_url(rel.target)
         elif rel.description == 'narrower':
             yield 'skos:narrower', request.resource_url(rel.target)
         else:
             yield 'skos:related', request.resource_url(rel.target)
     for rel in self.rel_from:
         if rel.description == 'broader':
             yield 'skos:narrower', request.resource_url(rel.source)
         elif rel.description == 'narrower':
             yield 'skos:broader', request.resource_url(rel.source)
         else:
             yield 'skos:related', request.resource_url(rel.source)
Beispiel #4
0
 def __rdf__(self, request):
     yield 'dcterms:type', self.ontological_category
     yield 'rdf:type', url_for_qname('skos:Collection')
     for vs in self.valuesets:
         yield 'skos:member', request.resource_url(vs.values[0])
     for rel in self.rel_to:
         if rel.description == 'broader':
             yield 'skos:broader', request.resource_url(rel.target)
         elif rel.description == 'narrower':
             yield 'skos:narrower', request.resource_url(rel.target)
         else:
             yield 'skos:related', request.resource_url(rel.target)
     for rel in self.rel_from:
         if rel.description == 'broader':
             yield 'skos:narrower', request.resource_url(rel.source)
         elif rel.description == 'narrower':
             yield 'skos:broader', request.resource_url(rel.source)
         else:
             yield 'skos:related', request.resource_url(rel.source)
     for meta in self.meta:
         if meta.propertyUrl and meta.valueUrl:
             yield meta.propertyUrl, meta.valueUrl
Beispiel #5
0
 def __rdf__(self, request):
     yield 'dcterms:type', self.ontological_category
     yield 'rdf:type', url_for_qname('skos:Collection')
     for vs in self.valuesets:
         yield 'skos:member', request.resource_url(vs.values[0])
     for rel in self.rel_to:
         if rel.description == 'broader':
             yield 'skos:broader', request.resource_url(rel.target)
         elif rel.description == 'narrower':
             yield 'skos:narrower', request.resource_url(rel.target)
         else:
             yield 'skos:related', request.resource_url(rel.target)
     for rel in self.rel_from:
         if rel.description == 'broader':
             yield 'skos:narrower', request.resource_url(rel.source)
         elif rel.description == 'narrower':
             yield 'skos:broader', request.resource_url(rel.source)
         else:
             yield 'skos:related', request.resource_url(rel.source)
     for meta in self.meta:
         if meta.propertyUrl and meta.valueUrl:
             yield meta.propertyUrl, meta.valueUrl
Beispiel #6
0
def test_url_for_qname():
    from clld.lib.rdf import url_for_qname

    assert url_for_qname('dcterms:title') == 'http://purl.org/dc/terms/title'
Beispiel #7
0
    def test_url_for_qname(self):
        from clld.lib.rdf import url_for_qname

        assert url_for_qname('dcterms:title') == 'http://purl.org/dc/terms/title'
Beispiel #8
0
 def __rdf__(self, request):
     cls = self.segment_class.capitalize() \
         if self.segment_class in ['consonant', 'vowel'] else 'Segment'
     yield 'rdf:type', url_for_qname('gold:' + cls)
     if self.segment_class:
         yield 'dcterms:description', self.segment_class
Beispiel #9
0
 def __rdf__(self, request):
     yield 'rdf:type', url_for_qname('skos:Concept')
     yield 'skos:topConceptOf', request.resource_url(
         self.valueset.contribution)
Beispiel #10
0
 def __rdf__(self, request):
     yield 'rdf:type', url_for_qname('skos:ConceptScheme')
     for vs in self.valuesets:
         yield 'skos:hasTopConcept', request.resource_url(vs.values[0])
     for ref in self.references:
         yield 'dcterms:source', request.resource_url(ref.source)
Beispiel #11
0
 def __rdf__(self, request):
     cls = self.segment_class.capitalize() \
         if self.segment_class in ['consonant', 'vowel'] else 'Segment'
     yield 'rdf:type', url_for_qname('gold:' + cls)
     if self.segment_class:
         yield 'dcterms:description', self.segment_class
Beispiel #12
0
 def __rdf__(self, request):
     yield 'rdf:type', url_for_qname('skos:ConceptScheme')
     for vs in self.valuesets:
         yield 'skos:hasTopConcept', request.resource_url(vs.values[0])
     for ref in self.references:
         yield 'dcterms:source', request.resource_url(ref.source)
Beispiel #13
0
 def __rdf__(self, request):
     yield 'rdf:type', url_for_qname('skos:Concept')
     yield 'skos:topConceptOf', request.resource_url(self.valueset.contribution)