Exemplo n.º 1
0
def get_subunits(
        entity: Entity,
        children: list[Entity],
        links: list[Link],
        links_inverse: list[Link],
        root: Entity,
        latest_mod_rec: datetime,
        type_links_inverse: list[Link],
        parser: dict[str, Any]) -> dict[str, Any]:
    return replace_empty_list_values_in_dict_with_none({
        'id': entity.id,
        'rootId': root.id,
        'parentId':
            entity.get_linked_entity_safe('P46', inverse=True).id
            if entity.id != root.id else None,
        'openatlasClassName': entity.class_.name,
        'crmClass': entity.cidoc_class.code,
        'created': str(entity.created),
        'modified': str(entity.modified),
        'latestModRec': latest_mod_rec,
        'geometry': get_geometries_thanados(entity, links, parser),
        'children': get_children(children, parser) if children else None,
        'properties': get_properties(
            entity,
            links,
            links_inverse,
            type_links_inverse,
            parser)})
Exemplo n.º 2
0
def get_subunit(entity: Entity, links: list[Link], links_inverse: list[Link],
                ext_reference_links: list[Link], root_id: int,
                latest_mod_rec: datetime, parser: dict[str,
                                                       Any]) -> dict[str, Any]:
    return replace_empty_list_values_in_dict_with_none({
        'id':
        entity.id,
        'rootId':
        root_id,
        'parentId':
        get_parent(links_inverse),
        'openatlasClassName':
        entity.class_.name,
        'crmClass':
        entity.cidoc_class.code,
        'created':
        str(entity.created),
        'modified':
        str(entity.modified),
        'latestModRec':
        latest_mod_rec,
        'geometry':
        get_geometries_thanados(entity, links, parser),
        'children':
        get_children(links, parser),
        'properties':
        get_properties(entity, links, links_inverse, ext_reference_links,
                       parser)
    })
Exemplo n.º 3
0
def get_linked_places_entity(entity: Entity, links: list[Link],
                             links_inverse: list[Link],
                             parser: dict[str, Any]) -> dict[str, Any]:
    return {
        'type':
        'FeatureCollection',
        '@context':
        app.config['API_SCHEMA'],
        'features': [
            replace_empty_list_values_in_dict_with_none({
                '@id':
                url_for('view', id_=entity.id, _external=True),
                'type':
                'Feature',
                'crmClass':
                f'crm:{entity.cidoc_class.code} '
                f"{entity.cidoc_class.i18n['en']}",
                'systemClass':
                entity.class_.name,
                'properties': {
                    'title': entity.name
                },
                'types':
                get_lp_types(entity, links)
                if 'types' in parser['show'] else None,
                'depictions':
                get_lp_file(links_inverse)
                if 'depictions' in parser['show'] else None,
                'when': {
                    'timespans': [get_lp_time(entity)]
                } if 'when' in parser['show'] else None,
                'links':
                get_reference_systems(links_inverse)
                if 'links' in parser['show'] else None,
                'descriptions': [{
                    'value': entity.description
                }],
                'names': [{
                    "alias": value
                } for value in entity.aliases.values()]
                if entity.aliases and 'names' in parser['show'] else None,
                'geometry':
                get_geometries(entity, links)
                if 'geometry' in parser['show'] else None,
                'relations':
                get_lp_links(links, links_inverse, parser)
                if 'relations' in parser['show'] else None
            })
        ]
    }
Exemplo n.º 4
0
def get_properties(
        entity: Entity,
        links: list[Link],
        links_inverse: list[Link],
        type_links_inverse: list[Link],
        parser: dict[str, Any]) -> dict[str, Any]:
    return replace_empty_list_values_in_dict_with_none({
        'name': entity.name,
        'aliases': get_aliases(entity, parser),
        'description': entity.description,
        'standardType':
            get_standard_type(entity.standard_type, type_links_inverse, parser)
            if entity.standard_type else None,
        'timespan': get_timespans(entity),
        'externalReferences': get_ref_system(links_inverse, parser),
        'references': get_references(links_inverse, parser),
        'files': get_file(links_inverse, parser),
        'types': get_types(entity, links, type_links_inverse, parser)})
Exemplo n.º 5
0
def get_geojson_dict(entity: Entity,
                     geom: Optional[dict[str, Any]] = None) -> dict[str, Any]:
    return replace_empty_list_values_in_dict_with_none({
        'type': 'Feature',
        'geometry': geom,
        'properties': {
            '@id': entity.id,
            'systemClass': entity.class_.name,
            'name': entity.name,
            'description': entity.description,
            'begin_earliest': entity.begin_from,
            'begin_latest': entity.begin_to,
            'begin_comment': entity.begin_comment,
            'end_earliest': entity.end_from,
            'end_latest': entity.end_to,
            'end_comment': entity.end_comment,
            'types': [': '.join([type_.name]) for type_ in entity.types]
        }
    })