Skip to content

Commit

Permalink
Merge pull request #686 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
goessebr authored Jan 6, 2022
2 parents 5ec47fb + 8959677 commit edf10e6
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
1.0.2 (06-01-2022)
------------------

- Keep uri field when change concept type: uri field is set to null in database when we change the type of a concept #680
- Not possible to save notes within a collection via the UI #682
- Add 2 references (article and software) to CITATION.cff file.


1.0.1 (04-01-2022)
------------------

Expand Down
32 changes: 31 additions & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,41 @@ abstract: >-
complex thesauri. Atramhasis is not suited for
managing very large or complex thesauri such as the
Getty Art and Architecture Thesaurus.
references:
- doi: 10.5194/isprs-annals-IV-2-W2-151-2017
type: article
year: 2017
title: 'Calling it what it is. Thesauri in the Flanders Heritage Agency: History, Importance, Use and Technological Advances'
authors:
- given-names: Sophie
family-names: Mortier
- given-names: Koen
family-names: Van Daele
email: koen.vandaele@vlaanderen.be
affiliation: Agentschap Onroerend Erfgoed
orcid: 'https://orcid.org/0000-0002-8153-2978'
- given-names: Leen
family-names: Meganck
email: leen.meganck@vlaanderen.be
affiliation: Agentschap Onroerend Erfgoed
journal: ISPRS Annals of Photogrammetry, Remote Sensing and Spatial Information Sciences
volume: 4W2
pages: 151-156
notes: Publication documenting how Atramhasis is used by Flanders Heritage Agency
- doi: 10.5281/zenodo.5767151
type: software
title: Skosprovider
authors:
- given-names: Koen
family-names: Van Daele
email: koen.vandaele@vlaanderen.be
affiliation: Flanders Heritage Agency
orcid: 'https://orcid.org/0000-0002-8153-2978'
keywords:
- SKOS
- thesaurus
- vocabulary
- python
license: GPL-3.0
version: 1.0.1
version: 1.0.2
date-released: '2021-12-22'
3 changes: 2 additions & 1 deletion atramhasis/data/datamanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ def save(self, thing):
self.session.flush()
return thing

def change_type(self, thing, concept_id, conceptscheme_id, new_type):
def change_type(self, thing, concept_id, conceptscheme_id, new_type, uri):
self.delete_thing(thing)
self.session.flush()
thing = Concept() if new_type == 'concept' else Collection()
thing.type = new_type
thing.concept_id = concept_id
thing.conceptscheme_id = conceptscheme_id
thing.uri = uri
self.save(thing)
return thing

Expand Down
30 changes: 20 additions & 10 deletions atramhasis/mappers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
"""
Module containing mapping functions used by Atramhasis.
"""

from skosprovider_sqlalchemy.models import Label, Note, Source, Concept, Collection, Match
from skosprovider_sqlalchemy.models import Collection
from skosprovider_sqlalchemy.models import Concept
from skosprovider_sqlalchemy.models import Label
from skosprovider_sqlalchemy.models import Match
from skosprovider_sqlalchemy.models import Note
from skosprovider_sqlalchemy.models import Source
from sqlalchemy.orm.exc import NoResultFound


Expand Down Expand Up @@ -35,10 +39,13 @@ def map_concept(concept, concept_json, skos_manager):

if concept_json_type == 'concept':
members = concept.members
concept = skos_manager.change_type(concept,
concept.concept_id,
concept.conceptscheme_id,
concept_json_type)
concept = skos_manager.change_type(
concept,
concept.concept_id,
concept.conceptscheme_id,
concept_json_type,
concept.uri
)
for member in members:
if member.type == 'concept':
concept.narrower_concepts.add(member)
Expand All @@ -47,10 +54,13 @@ def map_concept(concept, concept_json, skos_manager):
elif concept_json_type == 'collection':
narrower_concepts = concept.narrower_concepts
narrower_collections = concept.narrower_collections
concept = skos_manager.change_type(concept,
concept.concept_id,
concept.conceptscheme_id,
concept_json_type)
concept = skos_manager.change_type(
concept,
concept.concept_id,
concept.conceptscheme_id,
concept_json_type,
concept.uri
)
for narrower_concept in narrower_concepts:
concept.members.add(narrower_concept)
for narrower_collection in narrower_collections:
Expand Down
2 changes: 1 addition & 1 deletion atramhasis/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3

info:
title: Atramhasis API
version: 1.0.1
version: 1.0.2

servers:
- url: '/'
Expand Down
1 change: 1 addition & 0 deletions atramhasis/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def collection_adapter(obj, request):
'type': obj.type,
'uri': obj.uri,
'label': label.label if label else None,
'notes': obj.notes,
'labels': obj.labels,
'sources': obj.sources,
'members': [map_relation(c, language) for c in obj.members],
Expand Down
4 changes: 4 additions & 0 deletions atramhasis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def from_thing(thing):
Label(l.label, l.labeltype_id, l.language_id)
for l in thing.labels
],
notes=[
Note(n.note, n.notetype_id, n.language_id)
for n in thing.notes
],
sources=[
Source(s.citation)
for s in thing.sources
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.1'
release = '1.0.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run(self):
]

setup(name='atramhasis',
version='1.0.1',
version='1.0.2',
description='A web based editor for thesauri adhering to the SKOS specification.',
long_description=README + '\n\n' + CHANGES,
long_description_content_type='text/x-rst',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def setUp(self):
self.collection = Collection()
self.collection.concept_id = 0
self.collection.conceptscheme_id = 1
self.collection.uri = "urn:x-skosprovider:trees/3"
self.conceptscheme = ConceptScheme()
self.conceptscheme.id = 1
member_concept_1 = Concept()
Expand Down Expand Up @@ -302,6 +303,7 @@ def test_mapping_collection_to_concept(self):
self.assertTrue(hasattr(result_concept, 'related_concepts'))
self.assertTrue(hasattr(result_concept, 'narrower_concepts'))
self.assertTrue(hasattr(result_concept, 'narrower_collections'))
self.assertEqual(result_concept.uri, 'urn:x-skosprovider:trees/3')

def test_mapping_conceptscheme(self):
result_conceptscheme = map_conceptscheme(self.conceptscheme, test_json_conceptscheme)
Expand Down

0 comments on commit edf10e6

Please sign in to comment.