Skip to content

Commit

Permalink
Add fixture data for non-numeric ids. Refs #813 (#814)
Browse files Browse the repository at this point in the history
* Add fixture data for non-numeric ids. Refs #813

* Update URIGenerator pattern and fix bug. Refs #813
  • Loading branch information
koenedaele authored Mar 23, 2023
1 parent 3cd3502 commit 61274d6
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
13 changes: 13 additions & 0 deletions atramhasis/scripts/initializedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def main(argv=sys.argv):
from fixtures.heritagetypes import heritagetypes
from fixtures.periods import periods
from fixtures.species import species
from fixtures.bluebirds import bluebirds
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
Expand Down Expand Up @@ -130,6 +131,18 @@ def main(argv=sys.argv):
),
db_session
)
import_provider(
bluebirds,
ConceptScheme(
id=9,
uri='https://id.bluebirds.org',
labels=[
Label('Blauwe vogels', 'prefLabel', 'nl'),
Label('Blue birds', 'prefLabel', 'en')
]
),
db_session
)
db_session.commit()
db_session.close()
print('--atramhasis-db-initialized--')
11 changes: 11 additions & 0 deletions atramhasis/skos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ def create_registry(request):
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/soorten/%s')
)

bluebirds = SQLAlchemyProvider(
{
'id': 'BLUEBIRDS',
'conceptscheme_id': 9,
'atramhasis.id_generation_strategy': IDGenerationStrategy.MANUAL
},
request.db,
uri_generator=UriPatternGenerator('https://id.bluebirds.org/%s')
)

# use 'subject': ['external'] for read only external providers
# (only available in REST service)

Expand All @@ -170,6 +180,7 @@ def create_registry(request):
registry.register_provider(heritagetypes)
registry.register_provider(periods)
registry.register_provider(species)
registry.register_provider(bluebirds)
registry.register_provider(aat)
registry.register_provider(tgn)
return registry
Expand Down
5 changes: 5 additions & 0 deletions fixtures/LICENSE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ The data in this folder can be used according to either the `CC BY 4.0 license
Open Data Licentie
<http://www.opendataforum.info/files/modellicenties_NL_28_03.pdf>`_ used by the
Flemish Government.

Please beware that this is not the most current and up to date version of these
thesauri. The data is only fit for demonstrating and developing Atramhasis. If
you are looking for the most recent Flanders Heritage thesauri, please consult
`the Flanders Heritage thesaurus <https://thesaurus.onroerenderfgoed.be>`_.
14 changes: 14 additions & 0 deletions fixtures/bluebirds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Testdata containing blue birds such as the famous Norwegian Blue
.. versionadded:: 2.0.0
"""


from skosprovider.providers import DictionaryProvider
from .bluebirds_data import BLUEBIRDSDATA

bluebirds = DictionaryProvider(
{'id': 'BLUEBIRDS'},
BLUEBIRDSDATA
)
72 changes: 72 additions & 0 deletions fixtures/bluebirds_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
BLUEBIRDSDATA = [
{
'id': 'http://id.bluebirds.org/bird',
'uri': 'http://id.bluebirds.org/bird',
'type': 'concept',
'labels': [{'label': 'Bird', 'type': 'prefLabel', 'language': 'en'}, {'label': 'Vogel', 'type': 'prefLabel', 'language': 'nl'}],
'notes': [],
'sources': [],
'narrower': ['parrot', '579A439C-1A7A-476A-92C3-8A74ABD6B3DB'],
'broader': [],
'related': [],
'member_of': [],
'subordinate_arrays': [],
'matches': {'close': [], 'exact': [], 'related': [], 'broad': [], 'narrow': []}
},
{

'id': 'parrot',
'uri': 'http://id.bluebirds.org/parrot',
'type': 'concept',
'labels': [{'label': 'Parrot', 'type': 'prefLabel', 'language': 'en'}, {'label': 'Papegaai', 'type': 'prefLabel', 'language': 'nl'}],
'notes': [],
'sources': [],
'narrower': ['norwegianblue'],
'broader': [],
'related': [],
'member_of': [],
'subordinate_arrays': [], 'matches': {'close': [], 'exact': [], 'related': [], 'broad': [], 'narrow': []}
},
{
'id': 'norwegianblue',
'uri': 'http://id.bluebirds.org/norwegianblue',
'type': 'concept',
'labels': [{'label': 'Norwegian Blue', 'type': 'prefLabel', 'language': 'en'}, {'label': 'Noorse Blauwe', 'type': 'prefLabel', 'language': 'nl'}],
'notes': [],
'sources': [],
'narrower': [],
'broader': ['parrot'],
'related': [],
'member_of': [],
'subordinate_arrays': [],
'matches': {'close': [], 'exact': [], 'related': ['http://id.slugs.org/slug'], 'broad': [], 'narrow': []}
},
{
'id': '579A439C-1A7A-476A-92C3-8A74ABD6B3DB',
'uri': 'http://id.bluebirds.org/579A439C-1A7A-476A-92C3-8A74ABD6B3DB',
'type': 'concept',
'labels': [{'label': 'Heron', 'type': 'prefLabel', 'language': 'en'}, {'label': 'Héron', 'type': 'prefLabel', 'language': 'fr'}, {'label': 'Reiger', 'type': 'prefLabel', 'language': 'nl'}],
'notes': [],
'sources': [],
'narrower': ['blauwereiger'],
'broader': [],
'related': [],
'member_of': [],
'subordinate_arrays': [],
'matches': {'close': [], 'exact': [], 'related': [], 'broad': [], 'narrow': []}
},
{
'id': 'blauwereiger',
'uri': 'http://id.bluebirds.org/blauwereiger',
'type': 'concept',
'labels': [{'label': 'Grey heron', 'type': 'prefLabel', 'language': 'en'}, {'label': 'Héron cendré', 'type': 'prefLabel', 'language': 'fr'}, {'label': 'Blauwe reiger', 'type': 'prefLabel', 'language': 'nl'}, {'label': 'Ardea cinerea', 'type': 'prefLabel', 'language': 'la'}],
'notes': [],
'sources': [],
'narrower': [],
'broader': [],
'related': [],
'member_of': [],
'subordinate_arrays': [],
'matches': {'close': [], 'exact': [], 'related': [], 'broad': [], 'narrow': []}
}
]

0 comments on commit 61274d6

Please sign in to comment.