Skip to content

Commit

Permalink
Resolve #22
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Aug 25, 2023
1 parent 8a33ba9 commit be88783
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/edrn.rdf/edrn/rdf/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ RESERVED. U.S. Government Sponsorship acknowledged.
provides='.interfaces.IAsserter'
for='.multiliteralpredicatehandler.IMultiLiteralPredicateHandler'
/>
<adapter
factory='.multipipepredicatehandler.MultiPipeAsserter'
provides='.interfaces.IAsserter'
for='.multipipepredicatehandler.IMultiPipePredicateHandler'
/>
<adapter
factory='.referencepredicatehandler.ReferenceAsserter'
provides='.interfaces.IAsserter'
Expand Down
23 changes: 23 additions & 0 deletions src/edrn.rdf/edrn/rdf/multipipepredicatehandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding: utf-8
# Copyright 2023 California Institute of Technology. ALL RIGHTS
# RESERVED. U.S. Government Sponsorship acknowledged.


from .predicatehandler import ISimplePredicateHandler
from Acquisition import aq_inner
import rdflib


class IMultiPipePredicateHandler(ISimplePredicateHandler):
'''A handler for DMCC web services that maps tokenized |-separated keys to multiple literal RDF values.'''
# No further fields are necessary.


class MultiPipeAsserter(object):
'''Describes subjects using predicates with multiple literal complementary objects separated by |.'''
def __init__(self, context):
self.context = context
def characterize(self, obj):
context = aq_inner(self.context)
rc = [(rdflib.URIRef(context.predicateURI), rdflib.Literal(i.strip())) for i in obj.split('|')]
return rc
2 changes: 1 addition & 1 deletion src/edrn.rdf/edrn/rdf/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright 2012–2021 California Institute of Technology. ALL RIGHTS
RESERVED. U.S. Government Sponsorship acknowledged.
-->
<metadata>
<version>9</version>
<version>10</version>
<description>EDRN RDF Service</description>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
Expand Down
1 change: 1 addition & 0 deletions src/edrn.rdf/edrn/rdf/profiles/default/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RESERVED. U.S. Government Sponsorship acknowledged.
<object name='edrn.rdf.dmccprotocolrdfgenerator' meta_type='Dexterity FTI' />
<object name='edrn.rdf.literalpredicatehandler' meta_type='Dexterity FTI' />
<object name='edrn.rdf.multiliteralpredicatehandler' meta_type='Dexterity FTI' />
<object name='edrn.rdf.multipipepredicatehandler' meta_type='Dexterity FTI' />
<object name='edrn.rdf.referencepredicatehandler' meta_type='Dexterity FTI' />
<object name='edrn.rdf.emailpredicatehandler' meta_type='Dexterity FTI' />
<object name='edrn.rdf.biomutardfgenerator' meta_type='Dexterity FTI' />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
Copyright 2012 California Institute of Technology. ALL RIGHTS
RESERVED. U.S. Government Sponsorship acknowledged.
-->
<object name='edrn.rdf.multipipepredicatehandler' meta_type='Dexterity FTI' i18n:domain='edrn.rdf'
xmlns:i18n='http://xml.zope.org/namespaces/i18n'>
<property name='title' i18n:translate=''>Multi-Pipe Predicate Handler</property>
<property name='description' i18n:translate=''>A handler for DMCC web services that maps tokenized |-separated keys to multiple literal RDF values.</property>
<property name='allow_discussion'>False</property>
<property name='global_allow'>False</property>
<property name='filter_content_types'>True</property>
<property name='allowed_content_types' />
<property name='schema'>edrn.rdf.multipipepredicatehandler.IMultiPipePredicateHandler</property>
<property name='klass'>plone.dexterity.content.Item</property>
<property name='add_permission'>cmf.AddPortalContent</property>
<property name='behaviors'>
<element value='plone.app.content.interfaces.INameFromTitle' />
</property>
<property name='default_view'>view</property>
<property name='default_view_fallback'>False</property>
<property name='view_methods'>
<element value='view' />
</property>
<alias from='(Default)' to='(dynamic view)' />
<alias from='edit' to='@@edit' />
<alias from='sharing' to='@@sharing' />
<alias from='view' to='(selected layout)' />
<action title='View' action_id='view' category='object' condition_expr='' url_expr='string:${object_url}' visible='True'>
<permission value='View' />
</action>
<action title='Edit' action_id='edit' category='object' condition_expr='' url_expr='string:${object_url}/edit' visible='True'>
<permission value='Modify portal content' />
</action>
</object>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sets of data available at the DMCC by accessing their crummy web service.</prope
<property name='allowed_content_types'>
<element value='edrn.rdf.literalpredicatehandler' />
<element value='edrn.rdf.multiliteralpredicatehandler' />
<element value='edrn.rdf.multipipepredicatehandler' />
<element value='edrn.rdf.referencepredicatehandler' />
<element value='edrn.rdf.emailpredicatehandler' />
</property>
Expand Down
41 changes: 41 additions & 0 deletions src/edrn.rdf/edrn/rdf/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,44 @@ def upgrade8to9(setup_tool, logger=None):
logger = logging.getLogger(PACKAGE_NAME)
setup_tool.runImportStepFromProfile(DEFAULT_PROFILE, 'plone.app.registry')
logging.info('Loaded registry')


def upgrade9to10(setupTool, logger=None):
if logger is None:
logger = logging.getLogger(PACKAGE_NAME)
setupTool.runImportStepFromProfile(DEFAULT_PROFILE, 'typeinfo')
portal = plone.api.portal.get()
try:
generator = portal.unrestrictedTraverse('rdf-generators/person-generator')

try:
generator.manage_delObject('interestnamelist')
except AttributeError:
# no email handler found, so no worries
pass
handler = createContentInContainer(
generator,
'edrn.rdf.multipipepredicatehandler',
title='InterestNameList',
description='A list of names of intereest',
predicateURI='http://edrn.nci.nih.gov/rdf/schema.rdf#interestName'
)
publish(handler, plone.api.portal.get_tool('portal_workflow'))

try:
generator.manage_delObject('interestdesclist')
except AttributeError:
# no email handler found, so no worries
pass
handler = createContentInContainer(
generator,
'edrn.rdf.multipipepredicatehandler',
title='InterestDescList',
description='A list of descriptions of intereest',
predicateURI='http://edrn.nci.nih.gov/rdf/schema.rdf#interestDescription'
)
publish(handler, plone.api.portal.get_tool('portal_workflow'))

except KeyError:
# no person handler found, so nothing to do
pass
9 changes: 9 additions & 0 deletions src/edrn.rdf/edrn/rdf/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ RESERVED. U.S. Government Sponsorship acknowledged.
handler='edrn.rdf.upgrades.upgrade8to9'
sortkey='1'
/>
<genericsetup:upgradeStep
source='9'
destination='10'
title='Upgrade 9 to 10'
description='Add new edrn.rdf.multipipepredicatehandler'
profile='edrn.rdf:default'
handler='edrn.rdf.upgrades.upgrade9to10'
sortkey='1'
/>


</configure>

0 comments on commit be88783

Please sign in to comment.