Coverage for lode / viewer / owl_viewer.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-10-05 16:02 +0000

1# viewer/owl_viewer.py 

2from typing import Dict, Optional 

3from lode.viewer.base_viewer import BaseViewer 

4 

5class OwlViewer(BaseViewer): 

6 """Viewer OWL""" 

7 

8 TYPE_MAP = { 

9 'concept': {'singular': 'Class', 'plural': 'Classes', 'abb': 'c'}, 

10 'relation': {'singular': 'Object Property', 'plural': 'Object Properties', 'abb': 'op'}, 

11 'attribute': {'singular': 'Data Property', 'plural': 'Data Properties', 'abb': 'dp'}, 

12 'annotation': {'singular': 'Annotation Property', 'plural': 'Annotation Properties', 'abb': 'ap'}, 

13 'individual': {'singular': 'Named Individual', 'plural': 'Named Individuals', 'abb': 'ni'}, 

14 } 

15 

16 def get_toc_config(self): 

17 return [ 

18 ('Concept', 'concepts', 'Concept'), 

19 ('Relation', 'relations', 'Relation'), 

20 ('Attribute', 'attributes', 'Attribute'), 

21 ('Individual', 'individuals', 'Individual'), 

22 ('Annotation', 'annotations', 'Annotation'), 

23 ] 

24 

25 

26 def get_view_data(self, resource_uri: Optional[str] = None, language: Optional[str] = None) -> Dict: 

27 all_instances = self.get_all_instances() 

28 metadata_dict = self._find_and_format_metadata(all_instances) 

29 

30 if resource_uri: 

31 data = super().get_view_data(resource_uri, language) 

32 else: 

33 data = self._build_grouped_view(self.get_toc_config(), language) 

34 

35 data['metadata'] = metadata_dict 

36 data['type_map'] = self.TYPE_MAP 

37 return data