Exemplo n.º 1
0
def get_people_by_surname(surname):
    people = []
    result = Name.get_people_with_surname(surname)
    for record in result:
        p = Person_combo()
        p.uniq_id = record['uniq_id']
        p.get_person_and_name_data_by_id()
        people.append(p)

    return (people)
Exemplo n.º 2
0
def read_same_eventday(event_type):
    """ Lukee tietokannasta henkilötiedot, joilla on sama syntymäaika, näytettäväksi
    """

    ids = []
    if event_type == "Birth":
        result = Person_combo.get_people_with_same_birthday()
    elif event_type == "Death":
        result = Person_combo.get_people_with_same_deathday()
    else:
        raise NotImplementedError("Only Birth and Death accepted")

    for record in result:
        # <Record
        #    id1=259451 name1=['Julius Ferdinand', '', 'Lundahl']
        #    birth1=[0, 1861880, 1861880] death1=[0, 1898523, 1898523]
        #    id2=494238 name2=['Julius Ferdinand', '', 'Lundahl']
        #    birth2=[0, 1861880, 1861880] death2=[0, 1898523, 1898523]
        # >

        uniq_id = record['id1']
        name = record['name1']
        b = record['birth1']
        birth = DateRange(b)
        d = record['death1']
        death = DateRange(d)
        l = [uniq_id, name, birth, death]

        uniq_id = record['id2']
        name = record['name2']
        b = record['birth2']
        birth = DateRange(b)
        d = record['death2']
        death = DateRange(d)
        l.extend([uniq_id, name, DateRange(birth), DateRange(death)])

        print(f'found {l[0]} {l[1]} {l[2]}, {l[3]}')
        print(f'   -- {l[4]} {l[5]} {l[6]}, {l[7]}')
        ids.append(l)

    return ids
Exemplo n.º 3
0
def read_people_wo_birth():
    """ Lukee tietokannasta Person- objektit, joilta puuttuu syntymätapahtuma
        näytettäväksi
    """

    headings = []
    titles, people = Person_combo.get_people_wo_birth()

    headings.append(_("Event list"))
    headings.append(_("Showing persons without a birth event"))

    return (headings, titles, people)
Exemplo n.º 4
0
def read_old_people_top():
    """ Lukee tietokannasta Person- objektit, joilla syntymä- ja kuolintapahtuma
        näytettäväksi
    """

    headings = []
    titles, people = Person_combo.get_old_people_top()

    sorted_people = sorted(people, key=itemgetter(7), reverse=True)
    top_of_sorted_people = []
    for i in range(20 if len(sorted_people) > 19 else len(sorted_people)):
        top_of_sorted_people.append(sorted_people[i])

    headings.append(_("Event list"))
    headings.append(_("Showing oldest persons and their age"))

    return (headings, titles, top_of_sorted_people)
Exemplo n.º 5
0
    def set_estimated_person_dates(self):
        ''' Sets estimated dates for each Person processed in handle_people
            in transaction
            
            Called from bp.gramps.gramps_loader.xml_to_neo4j
        '''
        print("***** {} Estimated lifetimes *****".format(len(
            self.person_ids)))
        t0 = time.time()

        cnt = Person_combo.estimate_lifetimes(self.tx, self.person_ids)

        self.blog.log_event({
            'title': "Estimated person lifetimes",
            'count': cnt,
            'elapsed': time.time() - t0
        })
Exemplo n.º 6
0
def set_estimated_person_dates(uids=[]):
    """ Sets an estimated lifetime in Person.dates.

        Asettaa kaikille tai valituille henkilölle arvioidut syntymä- ja kuolinajat

        The properties in Person node are datetype, date1, and date2.
        With transaction, see gramps_loader.DOM_handler.set_estimated_dates_tr

        Called from bp.admin.routes.estimate_dates
    """
    my_tx = User.beginTransaction()

    cnt = Person_combo.estimate_lifetimes(my_tx, uids)

    msg = _("Estimated {} person lifetimes").format(cnt)
    User.endTransaction(my_tx)

    return msg
Exemplo n.º 7
0
def read_persons_with_events(keys=None,
                             args={}
                             ):  #, user=None, take_refnames=False, order=0):
    """ Reads Person Name and Event objects for display.
        Filter persons by args['context_code'].

        Returns Person objects, whith included Events and Names
        and optionally Refnames (if args['take_refnames'])

        NOTE. Called with
            keys = ('uniq_id', uid)     in bp.scene.routes.show_person_list
            keys = ('refname', refname) in bp.scene.routes.show_persons_by_refname
            keys = ('all',)             in bp.scene.routes.show_all_persons_list

            keys = None                 in routes.show_table_data
            keys = ['surname',value]    in routes.pick_selection
            keys = ("uniq_id",value)    in routes.pick_selection
    """

    persons = Person_combo.get_person_w_events(
        keys, args=args)  #user, take_refnames=take_refnames, order=order)
    return (persons)
Exemplo n.º 8
0
def get_person_data_by_id(pid):
    """ Get 5 data sets:                        ---- vanhempi versio ----

        ###Obsolete? still used in
        - /compare/uniq_id=311006,315556 
        - /lista/person_data/<string:uniq_id>
        - /lista/person_data/<string:uniq_id>

        The given pid may be an uuid (str) or uniq_id (int).

        person: Person object with name data
            The indexes of referred objects are in variables
                event_ref[]        str tapahtuman uniq_id, rooli eventref_role[]
                media_ref[]        str tallenteen uniq_id
                parentin_hlink[]   str vanhempien uniq_id
                note_ref[]         str huomautuksen uniq_id
                citation_ref[]     str viittauksen uniq_id
        events[]         Event_combo  with location name and id (?)
        photos
        citations
        families
    """
    p = Person_combo()
    if isinstance(pid, int):
        p.uniq_id = pid
    else:
        p.uuid = pid
    # Get Person and her Name properties, also Note properties
    p.get_person_w_names()
    # Get reference (uniq_id) and role for Events
    # Get references to Media, Citation objects
    # Get Persons birth family reference and role
    p.get_hlinks_by_id()

    # Person_display(Person)
    events = []
    citations = []
    photos = []
    source_cnt = 0
    my_birth_date = ''

    # Events

    for i in range(len(p.event_ref)):
        # Store Event data
        e = Event_combo()  # Event_for_template()
        e.uniq_id = p.event_ref[i]
        e.role = p.eventref_role[i]
        # Read event with uniq_id's of related Place (Note, and Citation?)
        e.get_event_combo()  # Read data to e
        if e.type == "Birth":
            my_birth_date = e.dates.estimate()

        for ref in e.place_ref:
            place = Place_combo.get_w_notes(ref)
            #             place.read_w_notes()
            # Location / place name, type and reference
            e.place = place
#             #TODO: remove 3 lines
#             e.location = place.pname
#             e.locid = place.uniq_id
#             e.ltype = place.type

        if e.note_ref:  # A list of uniq_ids; prev. e.noteref_hlink != '':
            # Read the Note objects from db and store them as a member of Event
            e.notes = Note.get_notes(e.note_ref)

        events.append(e)

        # Citations

        for ref in e.citation_ref:  # citationref_hlink != '':
            c = Citation()
            c.uniq_id = ref
            # If there is already the same citation on the list of citations,
            # use that index
            citation_ind = -1
            for i in range(len(citations)):
                if citations[i].uniq_id == c.uniq_id:
                    citation_ind = i + 1
                    break
            if citation_ind > 0:
                # Citation found; Event_combo.source = sitaatin numero
                e.source = citation_ind
            else:
                # Store the new source to the list
                # source = lähteen numero samassa listassa
                source_cnt += 1
                e.source = source_cnt

                result = c.get_source_repo(c.uniq_id)
                for record in result:
                    # Citation data & list of Source, Repository and Note data
                    #
                    # <Record id=92127 date='2017-01-25' page='1785 Novembr 3. kaste'
                    #    confidence='3' notetext='http://www.sukuhistoria.fi/...'
                    #    sources=[
                    #        [91360,
                    #         'Lapinjärvi syntyneet 1773-1787 vol  es346',
                    #         'Book',
                    #         100272,
                    #         'Lapinjärven seurakunnan arkisto',
                    #         'Archive']
                    #    ]
                    #   url='http://...">
                    c.dateval = record['date']
                    c.page = record['page']
                    c.confidence = record['confidence']
                    if not record['notetext']:
                        if c.page[:4] == "http":
                            c.notetext = c.page
                            c.page = ''
                    else:
                        c.notetext = record['notetext']

                    for source in record['sources']:
                        s = Source()
                        s.uniq_id = source[0]
                        s.stitle = source[1]
                        s.sauthor = source[2]
                        s.spubinfo = source[3]
                        s.reporef_medium = source[
                            4]  #Todo: Should use repository.medium

                        r = Repository()
                        r.uniq_id = source[5]
                        r.rname = source[6]
                        r.type = source[7]
                        s.repositories.append(r)

                        n = Note()
                        n.url = record['url']
                        s.notes.append(n)

                        c.source = s

                    print("Eve:{} {} > Cit:{} '{}' > Sour:{} '{}' '{}' '{}' > Repo:{} '{}' > Url: '{}'".\
                          format(e.uniq_id, e.id,
                                 c.uniq_id, c.page,
                                 s.uniq_id, s.stitle, s.sauthor, s.spubinfo,
                                 r.uniq_id, r.rname,
                                 n.url,
                          ))
                    citations.append(c)

    for uniq_id in p.media_ref:
        o = Media.get_one(uniq_id)
        photos.append(o)

    # Families

    # Returning a list of Family objects
    # - which include a list of members (Person with 'role' attribute)
    #   - Person includes a list of Name objects
    families = {}
    fid = 0
    result = Person_combo.get_family_members(p.uniq_id)
    for record in result:
        # <Record family_id='F0018' f_uniq_id=217546 role='PARENT' parent_role='mother'
        #  m_id='I0038' uniq_id=217511 sex=2 birth_date=[0, 1892433, 1892433]
        #  names=[
        #    <Node id=217512 labels={'Name'} properties={'firstname': 'Brita Kristina',
        #        'type': 'Birth Name', 'suffix': 'Eriksdotter', 'surname': 'Berttunen',
        #        'order': 0}>,
        #    <Node id=217513 labels={'Name'} properties={'firstname': 'Brita Kristina',
        #        'type': 'Married Name', 'suffix': '', 'surname': 'Silius',
        #        'order': 1}>]>
        if fid != record["f_uniq_id"]:
            fid = record["f_uniq_id"]
            if not fid in families:
                families[fid] = Family_combo(fid)
                families[fid].id = record['family_id']

        member = Person_as_member()  # A kind of Person
        member.role = record["role"]
        member.id = record["m_id"]
        member.uniq_id = record["uniq_id"]
        if member.uniq_id == p.uniq_id:
            # What kind of family this is? I am a Child or Parent in family
            if member.role == "CHILD":
                families[fid].role = "CHILD"
            else:
                families[fid].role = "PARENT"
            if my_birth_date:
                member.birth_date = my_birth_date

        if record["sex"]:
            member.sex = record["sex"]
        if record["birth_date"]:
            datetype, date1, date2 = record["birth_date"]
            if datetype != None:
                member.birth_date = DateRange(datetype, date1,
                                              date2).estimate()
        if record["names"]:
            for node in record["names"]:
                n = Name.from_node(node)
                member.names.append(n)

        if member.role == "CHILD":
            families[fid].children.append(member)
        elif member.role == "PARENT":
            parent_role = record["parent_role"]
            if parent_role == 'mother':
                families[fid].mother = member
            elif parent_role == 'father':
                families[fid].father = member
        # TODO: Remove these, obsolete
        elif member.role == "FATHER":
            families[fid].father = member
        elif member.role == "MOTHER":
            families[fid].mother = member

    family_list = list(families.values())

    # Find all referenced for the nodes found so far

    nodes = {p.uniq_id: p}
    for e in events:
        nodes[e.uniq_id] = e
    for e in photos:
        nodes[e.uniq_id] = e
    for e in citations:
        nodes[e.uniq_id] = e
    for e in family_list:
        nodes[e.uniq_id] = e

    return (p, events, photos, citations, family_list)