Skip to content

Commit

Permalink
Support of #24
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Nov 8, 2023
1 parent 07e2b4b commit 7a0c54c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
28 changes: 22 additions & 6 deletions src/edrn.rdf/edrn/rdf/dmcccommitteerdfgenerator.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
Copyright 2012–2021 California Institute of Technology. ALL RIGHTS
Copyright 2012–2023 California Institute of Technology. ALL RIGHTS
RESERVED. U.S. Government Sponsorship acknowledged.
-->
<metadata>
<version>10</version>
<version>11</version>
<description>EDRN RDF Service</description>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
Expand Down
8 changes: 7 additions & 1 deletion src/edrn.rdf/edrn/rdf/upgrades.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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')
11 changes: 10 additions & 1 deletion src/edrn.rdf/edrn/rdf/upgrades.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
Copyright 2013 California Institute of Technology. ALL RIGHTS
Copyright 2013–2023 California Institute of Technology. ALL RIGHTS
RESERVED. U.S. Government Sponsorship acknowledged.
-->
<configure xmlns='http://namespaces.zope.org/zope' xmlns:genericsetup='http://namespaces.zope.org/genericsetup'>
Expand Down Expand Up @@ -76,6 +76,15 @@ RESERVED. U.S. Government Sponsorship acknowledged.
handler='edrn.rdf.upgrades.upgrade9to10'
sortkey='1'
/>
<genericsetup:upgradeStep
source='10'
destination='11'
title='Upgrade 10 to 11'
description='Add project scientist and program officer support to committees'
profile='edrn.rdf:default'
handler='edrn.rdf.upgrades.upgrade10to11'
sortkey='1'
/>


</configure>

0 comments on commit 7a0c54c

Please sign in to comment.