Ejemplo n.º 1
0
def _load_source(loader: _Loader, element: ElementTree.Element) -> None:
    source_handle = element.get('handle')

    source = Source(element.get('id'), _xpath1(element, './ns:stitle').text)

    repository_source_handle = _load_handle('reporef', element)
    if repository_source_handle is not None:
        loader.add_association(Source, source_handle, 'contained_by', Source,
                               repository_source_handle)

    # Load the author.
    sauthor_element = _xpath1(element, './ns:sauthor')
    if sauthor_element is not None:
        source.author = sauthor_element.text

    # Load the publication info.
    spubinfo_element = _xpath1(element, './ns:spubinfo')
    if spubinfo_element is not None:
        source.publisher = spubinfo_element.text

    _load_attribute_privacy(source, element, 'srcattribute')

    flattened_source = FlattenedEntity(source, source_handle)
    _load_objref(loader, flattened_source, element)
    loader.add_entity(flattened_source)
Ejemplo n.º 2
0
 def test_author(self) -> None:
     sut = Source(None)
     self.assertIsNone(sut.author)
     author = 'Me'
     sut.author = author
     self.assertEquals(author, sut.author)
Ejemplo n.º 3
0
 async def test_source_should_encode_full(self):
     source = Source('the_source', 'The Source')
     source.author = 'The Author'
     source.publisher = 'The Publisher'
     source.date = Date(2000, 1, 1)
     source.contained_by = Source('the_containing_source',
                                  'The Containing Source')
     link = Link('https://example.com/the-source')
     link.label = 'The Source Online'
     source.links.add(link)
     source.contains.append(
         Source('the_contained_source', 'The Contained Source'))
     Citation('the_citation', source)
     expected = {
         '$schema':
         '/schema.json#/definitions/source',
         '@context': {
             'name': 'https://schema.org/name',
         },
         '@type':
         'https://schema.org/Thing',
         'id':
         'the_source',
         'name':
         'The Source',
         'author':
         'The Author',
         'publisher':
         'The Publisher',
         'contains': [
             '/en/source/the_contained_source/index.json',
         ],
         'citations': [
             '/en/citation/the_citation/index.json',
         ],
         'containedBy':
         '/en/source/the_containing_source/index.json',
         'date': {
             'year': 2000,
             'month': 1,
             'day': 1,
         },
         'links': [
             {
                 'url': '/en/source/the_source/index.json',
                 'relationship': 'canonical',
                 'mediaType': 'application/json',
             },
             {
                 'url': '/nl/source/the_source/index.json',
                 'relationship': 'alternate',
                 'locale': 'nl-NL',
             },
             {
                 'url': '/en/source/the_source/index.html',
                 'relationship': 'alternate',
                 'mediaType': 'text/html',
             },
             {
                 'url': 'https://example.com/the-source',
                 'label': 'The Source Online',
             },
         ],
     }
     await self.assert_encodes(expected, source, 'source')
Ejemplo n.º 4
0
    async def load(self) -> None:
        amsterdam = Place('betty-demo-amsterdam', [PlaceName('Amsterdam')])
        amsterdam.coordinates = Point(52.366667, 4.9)
        amsterdam.links.add(Link('https://nl.wikipedia.org/wiki/Amsterdam'))
        self._app.ancestry.entities.append(amsterdam)

        ilpendam = Place('betty-demo-ilpendam', [PlaceName('Ilpendam')])
        ilpendam.coordinates = Point(52.465556, 4.951111)
        ilpendam.links.add(Link('https://nl.wikipedia.org/wiki/Ilpendam'))
        self._app.ancestry.entities.append(ilpendam)

        personal_accounts = Source('betty-demo-personal-accounts',
                                   'Personal accounts')
        self._app.ancestry.entities.append(personal_accounts)

        cite_first_person_account = Citation('betty-demo-first-person-account',
                                             personal_accounts)
        self._app.ancestry.entities.append(cite_first_person_account)

        bevolkingsregister_amsterdam = Source(
            'betty-demo-bevolkingsregister-amsterdam',
            'Bevolkingsregister Amsterdam')
        bevolkingsregister_amsterdam.author = 'Gemeente Amsterdam'
        bevolkingsregister_amsterdam.publisher = 'Gemeente Amsterdam'
        self._app.ancestry.entities.append(bevolkingsregister_amsterdam)

        david_marinus_lankester = Person('betty-demo-david-marinus-lankester')
        PersonName(david_marinus_lankester, 'David Marinus', 'Lankester')
        self._app.ancestry.entities.append(david_marinus_lankester)

        geertruida_van_ling = Person('betty-demo-geertruida-van-ling')
        PersonName(geertruida_van_ling, 'Geertruida', 'Van Ling')
        self._app.ancestry.entities.append(geertruida_van_ling)

        marriage_of_dirk_jacobus_lankester_and_jannigje_palsen = Event(
            'betty-demo-marriage-of-dirk-jacobus-lankester-and-jannigje-palsen',
            Marriage(), Date(1922, 7, 4))
        marriage_of_dirk_jacobus_lankester_and_jannigje_palsen.place = ilpendam
        self._app.ancestry.entities.append(
            marriage_of_dirk_jacobus_lankester_and_jannigje_palsen)

        birth_of_dirk_jacobus_lankester = Event(
            'betty-demo-birth-of-dirk-jacobus-lankester', Birth(),
            Date(1897, 8, 25))
        birth_of_dirk_jacobus_lankester.place = amsterdam
        self._app.ancestry.entities.append(birth_of_dirk_jacobus_lankester)

        death_of_dirk_jacobus_lankester = Event(
            'betty-demo-death-of-dirk-jacobus-lankester', Death(),
            Date(1986, 8, 18))
        death_of_dirk_jacobus_lankester.place = amsterdam
        self._app.ancestry.entities.append(death_of_dirk_jacobus_lankester)

        dirk_jacobus_lankester = Person('betty-demo-dirk-jacobus-lankester')
        PersonName(dirk_jacobus_lankester, 'Dirk Jacobus', 'Lankester')
        Presence(dirk_jacobus_lankester, Subject(),
                 birth_of_dirk_jacobus_lankester)
        Presence(dirk_jacobus_lankester, Subject(),
                 death_of_dirk_jacobus_lankester)
        Presence(dirk_jacobus_lankester, Subject(),
                 marriage_of_dirk_jacobus_lankester_and_jannigje_palsen)
        dirk_jacobus_lankester.parents.append(david_marinus_lankester,
                                              geertruida_van_ling)
        self._app.ancestry.entities.append(dirk_jacobus_lankester)

        birth_of_marinus_david_lankester = Event(
            'betty-demo-birth-of-marinus-david', Birth(),
            DateRange(Date(1874, 1, 15),
                      Date(1874, 3, 21),
                      start_is_boundary=True,
                      end_is_boundary=True))
        birth_of_marinus_david_lankester.place = amsterdam
        self._app.ancestry.entities.append(birth_of_marinus_david_lankester)

        death_of_marinus_david_lankester = Event(
            'betty-demo-death-of-marinus-david', Death(), Date(1971))
        death_of_marinus_david_lankester.place = amsterdam
        self._app.ancestry.entities.append(death_of_marinus_david_lankester)

        marinus_david_lankester = Person('betty-demo-marinus-david-lankester')
        PersonName(marinus_david_lankester, 'Marinus David', 'Lankester')
        Presence(marinus_david_lankester, Subject(),
                 birth_of_marinus_david_lankester)
        Presence(marinus_david_lankester, Subject(),
                 death_of_marinus_david_lankester)
        marinus_david_lankester.parents.append(david_marinus_lankester,
                                               geertruida_van_ling)
        self._app.ancestry.entities.append(marinus_david_lankester)

        birth_of_jacoba_gesina_lankester = Event(
            'betty-demo-birth-of-jacoba-gesina', Birth(), Date(1900, 3, 14))
        birth_of_jacoba_gesina_lankester.place = amsterdam
        self._app.ancestry.entities.append(birth_of_jacoba_gesina_lankester)

        jacoba_gesina_lankester = Person('betty-demo-jacoba-gesina-lankester')
        PersonName(jacoba_gesina_lankester, 'Jacoba Gesina', 'Lankester')
        Presence(jacoba_gesina_lankester, Subject(),
                 birth_of_jacoba_gesina_lankester)
        jacoba_gesina_lankester.parents.append(david_marinus_lankester,
                                               geertruida_van_ling)
        self._app.ancestry.entities.append(jacoba_gesina_lankester)

        jannigje_palsen = Person('betty-demo-jannigje-palsen')
        PersonName(jannigje_palsen, 'Jannigje', 'Palsen')
        Presence(jannigje_palsen, Subject(),
                 marriage_of_dirk_jacobus_lankester_and_jannigje_palsen)
        self._app.ancestry.entities.append(jannigje_palsen)

        marriage_of_johan_de_boer_and_liberta_lankester = Event(
            'betty-demo-marriage-of-johan-de-boer-and-liberta-lankester',
            Marriage(), Date(1953, 6, 19))
        marriage_of_johan_de_boer_and_liberta_lankester.place = amsterdam
        self._app.ancestry.entities.append(
            marriage_of_johan_de_boer_and_liberta_lankester)

        cite_birth_of_liberta_lankester_from_bevolkingsregister_amsterdam = Citation(
            'betty-demo-birth-of-liberta-lankester-from-bevolkingsregister-amsterdam',
            bevolkingsregister_amsterdam)
        cite_birth_of_liberta_lankester_from_bevolkingsregister_amsterdam.location = 'Amsterdam'
        self._app.ancestry.entities.append(
            cite_birth_of_liberta_lankester_from_bevolkingsregister_amsterdam)

        birth_of_liberta_lankester = Event(
            'betty-demo-birth-of-liberta-lankester', Birth(),
            Date(1929, 12, 22))
        birth_of_liberta_lankester.place = amsterdam
        birth_of_liberta_lankester.citations.append(
            cite_birth_of_liberta_lankester_from_bevolkingsregister_amsterdam)
        self._app.ancestry.entities.append(birth_of_liberta_lankester)

        death_of_liberta_lankester = Event(
            'betty-demo-death-of-liberta-lankester', Death(),
            Date(2015, 1, 17))
        death_of_liberta_lankester.place = amsterdam
        death_of_liberta_lankester.citations.append(cite_first_person_account)
        self._app.ancestry.entities.append(death_of_liberta_lankester)

        liberta_lankester = Person('betty-demo-liberta-lankester')
        PersonName(liberta_lankester, 'Liberta', 'Lankester')
        PersonName(liberta_lankester, 'Betty')
        Presence(liberta_lankester, Subject(), birth_of_liberta_lankester)
        Presence(liberta_lankester, Subject(), death_of_liberta_lankester)
        Presence(liberta_lankester, Subject(),
                 marriage_of_johan_de_boer_and_liberta_lankester)
        liberta_lankester.parents.append(dirk_jacobus_lankester,
                                         jannigje_palsen)
        self._app.ancestry.entities.append(liberta_lankester)

        birth_of_johan_de_boer = Event('betty-demo-birth-of-johan-de-boer',
                                       Birth(), Date(1930, 6, 20))
        birth_of_johan_de_boer.place = amsterdam
        self._app.ancestry.entities.append(birth_of_johan_de_boer)

        death_of_johan_de_boer = Event('betty-demo-death-of-johan-de-boer',
                                       Death(), Date(1999, 3, 10))
        death_of_johan_de_boer.place = amsterdam
        death_of_johan_de_boer.citations.append(cite_first_person_account)
        self._app.ancestry.entities.append(death_of_johan_de_boer)

        johan_de_boer = Person('betty-demo-johan-de-boer')
        PersonName(johan_de_boer, 'Johan', 'De Boer')
        PersonName(johan_de_boer, 'Hans')
        Presence(johan_de_boer, Subject(), birth_of_johan_de_boer)
        Presence(johan_de_boer, Subject(), death_of_johan_de_boer)
        Presence(johan_de_boer, Subject(),
                 marriage_of_johan_de_boer_and_liberta_lankester)
        self._app.ancestry.entities.append(johan_de_boer)

        parent_of_bart_feenstra_child_of_liberta_lankester = Person(
            'betty-demo-parent-of-bart-feenstra-child-of-liberta-lankester')
        PersonName(parent_of_bart_feenstra_child_of_liberta_lankester,
                   'Bart\'s parent')
        parent_of_bart_feenstra_child_of_liberta_lankester.parents.append(
            johan_de_boer, liberta_lankester)
        self._app.ancestry.entities.append(
            parent_of_bart_feenstra_child_of_liberta_lankester)

        bart_feenstra = Person('betty-demo-bart-feenstra')
        PersonName(bart_feenstra, 'Bart', 'Feenstra')
        bart_feenstra.parents.append(
            parent_of_bart_feenstra_child_of_liberta_lankester)
        self._app.ancestry.entities.append(bart_feenstra)