Find person#

Person#

metacatalog.api.find_person(return_iterator: typing_extensions.Literal[False] = False) List['Person']#
metacatalog.api.find_person(return_iterator: typing_extensions.Literal[True] = False) Query

Return person record on exact matches. Persons can be identified by id, first_name, last_name, organisation details or associated roles. Since version 0.2.5 only Persons which have a is_organisation==False will be returned

Changed in version 0.1.8: string matches now allow ‘%’ and ‘*’ wildcards and can be inverted by prepending !

Changed in version 0.2.6: organisation_abbrev is now available.

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • id (integer) – Database unique ID of the requested record. Will return only one record.

  • uuid (str) –

    New in version 0.2.7.

    Find by version 4 UUID. If uuid is given, all other options will be ignored.

  • first_name (str) – First name attribute of the requested person.

  • last_name (str) – Last name attribute of the requested person.

  • role (int, str) – Role id or name (exact match) that is associated to a person. Will most likely return many persons.

  • organisation_name (str) –

    New in version 0.1.10.

    The name of the head organisation, without department and group specification.

    Note

    Not all Persons may have an organisation_name.

  • organisation_abbrev (str) –

    New in version 0.2.6.

    A short abbreviation of the head organisation if applicable.

    Note

    Not all Persons may have a head organisation

  • attribution (str) –

    New in version 0.2.8.

    Attribtion recommondation, which is associated to all datasets, the user is first author of

  • return_iterator (bool) – If True, an iterator returning the requested objects instead of the objects themselves is returned.

Returns:

records – List of matched Person instance.

Return type:

list of metacatalog.Person

See also

find_organisation

Role#

metacatalog.api.find_role(return_iterator: typing_extensions.Literal[False] = False) List['PersonRole']#
metacatalog.api.find_role(return_iterator: typing_extensions.Literal[True] = False) Query

Return one person role record on exact matches. Roles can be identified by id or name.

Changed in version 0.1.8: string matches now allow ‘%’ and ‘*’ wildcards and can be inverted by prepending !

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • id (integer) – Database unique ID of the requested record. Will return only one record.

  • name (str) – name attribute of the requested role.

  • return_iterator (bool) – If True, an iterator returning the requested objects instead of the objects themselves is returned.

Returns:

records – List of matched PersonRole instance.

Return type:

list of metacatalog.PersonRole

Associations#

Note

Persons are not directly bound to an Entry. They are related by an association that have to be further described by the type of contribution to the Entry. Therefore, if an Entry is deleted, the Person will persist. Finally, you can’t search for contributions directly, you either have to find a Person and load the associated entries, or you need to find an entry and load the contributors.

[1]:
from metacatalog import api
session = api.connect_database()

# get the person
alfred =api.find_person(session, id=2)[0]

for assoc in alfred.entries:
    print(assoc)
Alfred, E. Neumann <ID=2> as author for Entry <ID=18>
Alfred, E. Neumann <ID=2> as author for Entry <ID=19>
Alfred, E. Neumann <ID=2> as author for Entry <ID=20>
[2]:
# now starting from the entry side
entry = api.find_entry(session, id=20)[0]

print('First author:', str(entry.author))
print('all authors: ', ', '.join([str(a) for a in entry.authors]))
for assoc in entry.contributors:
    print(assoc)
First author: Alfred, E. Neumann <ID=2>
all authors:  Alfred, E. Neumann <ID=2>
Alfred, E. Neumann <ID=2> as author for Entry <ID=20>