Beispiel #1
0
def sorting(entities: list[Entity], parser: dict[str, Any]) -> list[Entity]:
    entities = remove_duplicate_entities(entities)
    return entities if 'latest' in request.path else \
        sorted(
            entities,
            key=lambda entity: get_key(entity, parser['column']),
            reverse=bool(parser['sort'] == 'desc'))
Beispiel #2
0
def get_type_links_inverse(entities: list[Entity]) -> list[Link]:
    types = remove_duplicate_entities(
        [type_ for entity in entities for type_ in entity.types])
    links = get_all_links_inverse([type_.id for type_ in types], 'P67')
    return [
        link_ for link_ in links
        if link_.domain.class_.name == 'reference_system'
    ]
Beispiel #3
0
def get_entities_grouped_by_class(entities: list[Entity]) -> dict[str, Any]:
    entities += get_linked_entities_api([e.id for e in entities])
    entities = remove_duplicate_entities(entities)
    grouped_entities = {}
    for class_, entities_ in groupby(
            sorted(entities, key=lambda entity: entity.class_.name),
            key=lambda entity: entity.class_.name):
        grouped_entities[class_] = \
            [build_entity_dataframe(entity) for entity in entities_]
    return grouped_entities
Beispiel #4
0
 def get_type_links_inverse(entities: list[Entity]) -> list[Link]:
     types = remove_duplicate_entities(
         [type_ for entity in entities for type_ in entity.types])
     return link_builder(types, True)