Skip to content

Commit

Permalink
WIP for #15
Browse files Browse the repository at this point in the history
-   Two new predicates in the RDF for LabCAS data collections
    -   `urn:edrn:predicates:ownerPrincipal`
    -   `urn:edrn:predicates:qaState`
-   Correction of some integration test data
-   Fix an error message
-   Fix a deprecated import message

Note that the portal will need to understand these two new predicates.
  • Loading branch information
nutjob4life committed May 4, 2022
1 parent 21b5e8c commit bae6b00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/edrn.rdf/edrn/rdf/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ And now for the RDF::
>>> graph = rdflib.Graph()
>>> graph.parse(data=browser.contents)
<Graph identifier=...(<class 'rdflib.graph.Graph'>)>
>>> len(graph)
9422
>>> len(graph) > 9422
True
>>> subjects = frozenset([str(i) for i in graph.subjects() if str(i)])
>>> subjects = list(subjects)
>>> subjects.sort()
Expand Down
9 changes: 9 additions & 0 deletions src/edrn.rdf/edrn/rdf/labcascollectionrdfgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
_protocolPredicateURI = URIRef('urn:edrn:predicates:protocol')
_collaborativeGroupPredicateURI = URIRef('urn:edrn:predicates:collaborativeGroup')
_cardinalityPredicateURI = URIRef('urn:edrn:predicates:cardinality')
_ownerPrincipal = URIRef('urn:edrn:predicates:ownerPrincipal')
_qaState = URIRef('urn:edrn:predicates:qaState')

# Type URIs
_statsTypeURI = URIRef('urn:edrn:types:labcas:statistics')
Expand Down Expand Up @@ -113,6 +115,13 @@ def generateGraph(self):
group = _inconsistentCollaborativeGroupNaming.get(group)
if group is not None:
graph.add((subjectURI, _collaborativeGroupPredicateURI, Literal(group)))
for owner in i.get('OwnerPrincipal', []):
# Work around https://github.com/EDRN/EDRN-metadata/issues/63
if owner.startswith('OwnerPrincipal='):
owner = owner[15:]
graph.add((subjectURI, _ownerPrincipal, Literal(owner)))
for qaState in i.get('QAState', []):
graph.add((subjectURI, _qaState, Literal(qaState)))

# And summary info
graph.add((URIRef(context.labcasSolrURL + '/collections'), _cardinalityPredicateURI, Literal(str(numCollections))))
Expand Down
2 changes: 1 addition & 1 deletion src/edrn.rdf/edrn/rdf/siterdfupdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __call__(self):
updater.updateRDF()
self.count += 1
except Exception as ex:
_logger.exception('Failure updating RDF for "%s"', i.getPath())
_logger.exception('Failure updating RDF for "%s"', '/'.join(source.getPhysicalPath()))
self.failures.append(dict(title=i.Title, url=source.absolute_url(), message=str(ex)))
self.numFailed = len(self.failures)
return self.render()
2 changes: 1 addition & 1 deletion src/edrn.rdf/edrn/rdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def parseTokens(s):
# The ZPL 1.0 applies.

try:
from zope.site.hooks import getSite
from zope.component.hooks import getSite
_get_default_context = getSite
except ImportError:
try:
Expand Down

0 comments on commit bae6b00

Please sign in to comment.