Update uses of get_source_referents to handle citations:
* implement new Utils get_source_and_citation_referents * Update sourceview.py and citationtreeview.py to use it * Fix editsource.py, where deletion of a source object was not properly dealing with all possible citations * Update mediaobj.py which still had a remnant of a source_list * fix _HasTextMatchingSubstringOf filter to deal with text in both sources and citations svn: r18394
This commit is contained in:
59
src/Utils.py
59
src/Utils.py
@ -973,9 +973,9 @@ def get_source_referents(source_handle, db):
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Only Citations can refer to sources, so that is all we need to check
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository', 'Citation')
|
||||
_primaries = ('Citation',)
|
||||
|
||||
return (get_referents(source_handle, db, _primaries))
|
||||
|
||||
@ -991,6 +991,61 @@ def get_citation_referents(citation_handle, db):
|
||||
|
||||
return (get_referents(citation_handle, db, _primaries))
|
||||
|
||||
def get_source_and_citation_referents(source_handle, db):
|
||||
"""
|
||||
Find all citations that refer to the sources, and recursively, all objects
|
||||
that refer to the sources.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Objects -> Citations -> Source
|
||||
e.g.
|
||||
Media object M1 -> Citation C1 -> Source S1
|
||||
Media object M2 -> Citation C1 -> Source S1
|
||||
Person object P1 -> Citation C2 -> Source S1
|
||||
|
||||
The returned structure is rather ugly, but provides all the information in
|
||||
a way that is consistent with the other Util functions.
|
||||
(
|
||||
tuple of objects that refer to the source - only first element is present
|
||||
([C1, C2],),
|
||||
list of citations with objects that refer to them
|
||||
[
|
||||
(C1,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([], [], [], [], [], [M1, M2]. [])
|
||||
)
|
||||
(C2,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([P1], [], [], [], [], []. [])
|
||||
)
|
||||
]
|
||||
)
|
||||
#47738: DEBUG: citationtreeview.py: line 428: source referents [(['bfe59e90dbb555d0d87'],)]
|
||||
#47743: DEBUG: citationtreeview.py: line 432: citation bfe59e90dbb555d0d87
|
||||
#47825: DEBUG: citationtreeview.py: line 435: citation_referents_list [[('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))]]
|
||||
#47827: DEBUG: citationtreeview.py: line 440: the_lists [((['bfe59e90dbb555d0d87'],), [('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))])]
|
||||
|
||||
"""
|
||||
the_lists = get_source_referents(source_handle, db)
|
||||
LOG.debug('source referents %s' % [the_lists])
|
||||
# now, for each citation, get the objects that refer to that citation
|
||||
citation_referents_list = []
|
||||
for citation in the_lists[0]:
|
||||
LOG.debug('citation %s' % citation)
|
||||
refs = get_citation_referents(citation, db)
|
||||
citation_referents_list += [(citation, refs)]
|
||||
LOG.debug('citation_referents_list %s' % [citation_referents_list])
|
||||
|
||||
(citation_list) = the_lists
|
||||
the_lists = (citation_list, citation_referents_list)
|
||||
|
||||
LOG.debug('the_lists %s' % [the_lists])
|
||||
return the_lists
|
||||
|
||||
def get_media_referents(media_handle, db):
|
||||
""" Find objects that refer the media object.
|
||||
|
||||
|
Reference in New Issue
Block a user