Skip to content

Commit

Permalink
added examples for annotation in lp
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Jan 30, 2025
1 parent 2a1f515 commit 581b0c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 11 additions & 5 deletions openatlas/api/endpoints/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
flatten_list_and_remove_duplicates, get_geometric_collection,
get_geoms_dict, get_location_link, get_reference_systems,
replace_empty_list_values_in_dict_with_none)
from openatlas.display.util import description
from openatlas.models.annotation import AnnotationText
from openatlas.models.entity import Entity, Link
from openatlas.models.gis import Gis

Expand Down Expand Up @@ -191,10 +191,16 @@ def get_geom(self, entity: Entity, ) -> list[Any]:
return []

def get_annotations(self, entity: Entity) -> list[dict[str, Any]]:
description_ = entity.description
if entity.cidoc_class == 'E33' and self.annotations == 'html':
description_ = entity.get_annotated_text()
return [{'value': description_}] if 'description' in self.show else None
description_ = {'value': entity.description}
if entity.cidoc_class.code == 'E33' and self.annotations == 'html':
description_['annotation_text'] = entity.get_annotated_text()
description_['annotations'] = [{
'source_id': a.source_id,
'entity_id': a.entity_id,
'link_start': a.link_start,
'link_end': a.link_end,
'text': a.text} for a in AnnotationText.get_by_source_id(entity.id)]
return [description_] if 'description' in self.show else None

def get_linked_places_entity(
self,
Expand Down
5 changes: 4 additions & 1 deletion openatlas/api/resources/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ def linked_places_template(parser: Parser) -> dict[str, Type[String]]:
'earliest': fields.String,
'latest': fields.String,
'comment': fields.String}
description = {'value': fields.String}
description = {
'value': fields.String,
'annotation_text': fields.String,
'annotations': fields.Raw}
timespans = {'start': fields.Nested(start), 'end': fields.Nested(end)}
when = {'timespans': fields.List(fields.Nested(timespans))}
relations = {
Expand Down

0 comments on commit 581b0c9

Please sign in to comment.