From eb8c17cfa5db5bc7f876adbe2cf20ac30edd7d77 Mon Sep 17 00:00:00 2001 From: romjerome Date: Sat, 3 Dec 2016 10:59:33 +0100 Subject: [PATCH] 9812: 'Check and Repair' tool ignores some objects with tag support --- gramps/plugins/tool/check.py | 77 +++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/tool/check.py b/gramps/plugins/tool/check.py index 3965a2ca1..a12878c73 100644 --- a/gramps/plugins/tool/check.py +++ b/gramps/plugins/tool/check.py @@ -1877,7 +1877,12 @@ class CheckIntegrity: total = (self.db.get_number_of_people() + self.db.get_number_of_families() + self.db.get_number_of_media() + - self.db.get_number_of_notes()) + self.db.get_number_of_notes() + + self.db.get_number_of_events() + + self.db.get_number_of_citations() + + self.db.get_number_of_sources() + + self.db.get_number_of_places() + + self.db.get_number_of_repositories()) self.progress.set_pass(_('Looking for tag reference problems'), total) @@ -1939,6 +1944,76 @@ class CheckIntegrity: elif item[1] not in known_handles: self.invalid_tag_references.add(item[1]) + for bhandle in self.db.get_event_handles(): + self.progress.step() + event = self.db.get_event_from_handle(bhandle) + handle_list = event.get_referenced_handles_recursively() + for item in handle_list: + if item[0] == 'Tag': + if item[1] is None: + new_handle = create_id() + event.replace_tag_references(None, new_handle) + self.db.commit_event(event, self.trans) + self.invalid_tag_references.add(new_handle) + elif item[1] not in known_handles: + self.invalid_tag_references.add(item[1]) + + for bhandle in self.db.get_citation_handles(): + self.progress.step() + citation = self.db.get_citation_from_handle(bhandle) + handle_list = citation.get_referenced_handles_recursively() + for item in handle_list: + if item[0] == 'Tag': + if item[1] is None: + new_handle = create_id() + citation.replace_tag_references(None, new_handle) + self.db.commit_citation(citation, self.trans) + self.invalid_tag_references.add(new_handle) + elif item[1] not in known_handles: + self.invalid_tag_references.add(item[1]) + + for bhandle in self.db.get_source_handles(): + self.progress.step() + source = self.db.get_source_from_handle(bhandle) + handle_list = source.get_referenced_handles_recursively() + for item in handle_list: + if item[0] == 'Tag': + if item[1] is None: + new_handle = create_id() + source.replace_tag_references(None, new_handle) + self.db.commit_source(source, self.trans) + self.invalid_tag_references.add(new_handle) + elif item[1] not in known_handles: + self.invalid_tag_references.add(item[1]) + + for bhandle in self.db.get_place_handles(): + self.progress.step() + place = self.db.get_place_from_handle(bhandle) + handle_list = place.get_referenced_handles_recursively() + for item in handle_list: + if item[0] == 'Tag': + if item[1] is None: + new_handle = create_id() + place.replace_tag_references(None, new_handle) + self.db.commit_place(place, self.trans) + self.invalid_tag_references.add(new_handle) + elif item[1] not in known_handles: + self.invalid_tag_references.add(item[1]) + + for bhandle in self.db.get_repository_handles(): + self.progress.step() + repository = self.db.get_repository_from_handle(bhandle) + handle_list = repository.get_referenced_handles_recursively() + for item in handle_list: + if item[0] == 'Tag': + if item[1] is None: + new_handle = create_id() + repository.replace_tag_references(None, new_handle) + self.db.commit_repository(repository, self.trans) + self.invalid_tag_references.add(new_handle) + elif item[1] not in known_handles: + self.invalid_tag_references.add(item[1]) + for bad_handle in self.invalid_tag_references: make_unknown(bad_handle, None, self.class_tag, self.commit_tag, self.trans)