From 7a0c54cbc677c3bfd7742581223b7dad54d0503a Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Wed, 8 Nov 2023 11:33:35 -0600 Subject: [PATCH] Support of #24 --- .../edrn/rdf/dmcccommitteerdfgenerator.py | 28 +++++++++++++++---- .../edrn/rdf/profiles/default/metadata.xml | 4 +-- src/edrn.rdf/edrn/rdf/upgrades.py | 8 +++++- src/edrn.rdf/edrn/rdf/upgrades.zcml | 11 +++++++- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/edrn.rdf/edrn/rdf/dmcccommitteerdfgenerator.py b/src/edrn.rdf/edrn/rdf/dmcccommitteerdfgenerator.py index e1d7ec4..08cde8c 100644 --- a/src/edrn.rdf/edrn/rdf/dmcccommitteerdfgenerator.py +++ b/src/edrn.rdf/edrn/rdf/dmcccommitteerdfgenerator.py @@ -1,5 +1,5 @@ # encoding: utf-8 -# Copyright 2012 California Institute of Technology. ALL RIGHTS +# Copyright 2012–2023 California Institute of Technology. ALL RIGHTS # RESERVED. U.S. Government Sponsorship acknowledged. '''DMCC Committee RDF Generator. An RDF generator that describes EDRN committees using the DMCC's web services. @@ -32,9 +32,10 @@ 'Co-chair': 'coChairPredicateURI', 'Consultant': 'consultantPredicateURI', 'Member': 'memberPredicateURI', - 'Project Scientist': 'memberPredicateURI', - 'Program Officer': 'memberPredicateURI', + 'Project Scientist': 'projectScientistPredicateURI', + 'Program Officer': 'programOfficerPredicateURI', } +# We'll treat all other non-found roles as mere members class IDMCCCommitteeRDFGenerator(IRDFGenerator): @@ -110,12 +111,25 @@ class IDMCCCommitteeRDFGenerator(IRDFGenerator): description=_('The Uniform Resource Identifier of the predicate that indicates members of committees.'), required=True, ) + projectScientistPredicateURI = schema.TextLine( + title=_(u'Project Scientist Predicate URI'), + description=_(u'The Uniform Resource Identifier of the predicate that indicates the project scientist of the committee'), + required=True, + default='urn:edrn:rdf:predicates:project_scientist' + ) + programOfficerPredicateURI = schema.TextLine( + title=_(u'Program Officer Predicate URI'), + description=_(u'The Uniform Resource Identifier of the predicate that indicates the program officer of the committee'), + required=True, + default='urn:edrn:rdf:predicates:program_officer' + ) class DMCCCommitteeGraphGenerator(object): '''A graph generator that produces statements about EDRN's committees using the DMCC's web service.''' def __init__(self, context): self.context = context + def generateGraph(self): graph = rdflib.Graph() context = aq_inner(self.context) @@ -157,9 +171,11 @@ def generateGraph(self): obj = URIRef(context.personPrefix + value) elif key == 'roleName': if value not in _roleNamePredicates: - _logger.warning('🤔 Unknown role "%s"; ignoring this member', value) - continue - predicateURI = URIRef(getattr(context, _roleNamePredicates[value])) + _logger.warning('🤔 Unknown role "%s"; treating as plain member', value) + predicate_name = 'memberPredicateURI' + else: + predicate_name = _roleNamePredicates[value] + predicateURI = URIRef(getattr(context, predicate_name)) if gotChristos: _logger.warning('🎅 Got Christos for subject %s, role %s, obj %s', subjectURI, predicateURI, obj) gotChristos = False diff --git a/src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml b/src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml index 5ff8d70..b290877 100644 --- a/src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml +++ b/src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml @@ -1,10 +1,10 @@ - 10 + 11 EDRN RDF Service profile-plone.app.dexterity:default diff --git a/src/edrn.rdf/edrn/rdf/upgrades.py b/src/edrn.rdf/edrn/rdf/upgrades.py index f23873d..8e506d7 100644 --- a/src/edrn.rdf/edrn/rdf/upgrades.py +++ b/src/edrn.rdf/edrn/rdf/upgrades.py @@ -1,5 +1,5 @@ # encoding: utf-8 -# Copyright 2013–2017 California Institute of Technology. ALL RIGHTS +# Copyright 2013–2023 California Institute of Technology. ALL RIGHTS # RESERVED. U.S. Government Sponsorship acknowledged. from .setuphandlers import publish @@ -160,3 +160,9 @@ def upgrade9to10(setupTool, logger=None): except KeyError: # no person handler found, so nothing to do pass + + +def upgrade10to11(setupTool, logger=None): + if logger is None: + logger = logging.getLogger(PACKAGE_NAME) + setupTool.runImportStepFromProfile(DEFAULT_PROFILE, 'typeinfo') diff --git a/src/edrn.rdf/edrn/rdf/upgrades.zcml b/src/edrn.rdf/edrn/rdf/upgrades.zcml index fad4b1d..16e179c 100644 --- a/src/edrn.rdf/edrn/rdf/upgrades.zcml +++ b/src/edrn.rdf/edrn/rdf/upgrades.zcml @@ -1,6 +1,6 @@ @@ -76,6 +76,15 @@ RESERVED. U.S. Government Sponsorship acknowledged. handler='edrn.rdf.upgrades.upgrade9to10' sortkey='1' /> + \ No newline at end of file