Beispiel #1
0
 def remove_object_from_handle(self, handle):
     the_lists = get_citation_referents(handle, self.dbstate.db)
     object = self.dbstate.db.get_citation_from_handle(handle)
     query = DeleteCitationQuery(self.dbstate, self.uistate, object,
                                 the_lists)
     is_used = any(the_lists)
     return (query, is_used, object)
Beispiel #2
0
 def remove_object_from_handle(self, handle):
     the_lists = get_citation_referents(handle, self.dbstate.db)
     object = self.dbstate.db.get_citation_from_handle(handle)
     query = DeleteCitationQuery(self.dbstate, self.uistate, object,
                                 the_lists)
     is_used = any(the_lists)
     return (query, is_used, object)
Beispiel #3
0
def delete_citation(db_handle: DbWriteBase, handle: str, trans: DbTxn) -> None:
    """Delete an event and its references."""
    (
        person_list,
        family_list,
        event_list,
        place_list,
        source_list,
        media_list,
        repo_list,
    ) = get_citation_referents(handle, db_handle)

    citation = db_handle.get_citation_from_handle(handle)
    ctn_handle_list = [handle]

    for _handle in person_list:
        person = db_handle.get_person_from_handle(_handle)
        person.remove_citation_references(ctn_handle_list)
        db_handle.commit_person(person, trans)

    for _handle in family_list:
        family = db_handle.get_family_from_handle(_handle)
        family.remove_citation_references(ctn_handle_list)
        db_handle.commit_family(family, trans)

    for _handle in event_list:
        event = db_handle.get_event_from_handle(_handle)
        event.remove_citation_references(ctn_handle_list)
        db_handle.commit_event(event, trans)

    for _handle in place_list:
        place = db_handle.get_place_from_handle(_handle)
        place.remove_citation_references(ctn_handle_list)
        db_handle.commit_place(place, trans)

    for _handle in source_list:
        source = db_handle.get_source_from_handle(_handle)
        source.remove_citation_references(ctn_handle_list)
        db_handle.commit_source(source, trans)

    for _handle in media_list:
        media = db_handle.get_media_from_handle(_handle)
        media.remove_citation_references(ctn_handle_list)
        db_handle.commit_media(media, trans)

    for _handle in repo_list:
        repo = db_handle.get_repository_from_handle(_handle)
        repo.remove_citation_references(ctn_handle_list)
        db_handle.commit_repository(repo, trans)

    db_handle.remove_citation(citation.get_handle(), trans)
Beispiel #4
0
    def remove_object_from_handle(self, handle):
        # The handle will either be a Source handle or a Citation handle
        source, citation = self.get_source_or_citation(handle)
        if citation:
            the_lists = get_citation_referents(handle, self.dbstate.db)
            query = DeleteCitationQuery(self.dbstate, self.uistate, citation,
                                        the_lists)
            is_used = any(the_lists)
            return (query, is_used, citation)
        else:
            the_lists = get_source_and_citation_referents(
                handle, self.dbstate.db)
            LOG.debug('the_lists %s' % [the_lists])

            query = DeleteSrcQuery(self.dbstate, self.uistate, source,
                                   the_lists)
            is_used = any(the_lists)
            return (query, is_used, source)
Beispiel #5
0
    def remove_object_from_handle(self, handle):
        # The handle will either be a Source handle or a Citation handle
        source, citation = self.get_source_or_citation(handle)
        if citation:
            the_lists = get_citation_referents(handle, self.dbstate.db)
            query = DeleteCitationQuery(self.dbstate, self.uistate, citation,
                                        the_lists)
            is_used = any(the_lists)
            return (query, is_used, citation)
        else:
            the_lists = get_source_and_citation_referents(handle,
                                                          self.dbstate.db)
            LOG.debug('the_lists %s' % [the_lists])

            query = DeleteSrcQuery(self.dbstate, self.uistate, source,
                                   the_lists)
            is_used = any(the_lists)
            return (query, is_used, source)
Beispiel #6
0
    def remove_object_from_handle(self, handle):
        # The handle will either be a Source handle or a Citation handle
        source = self.dbstate.db.get_source_from_handle(handle)
        citation = self.dbstate.db.get_citation_from_handle(handle)
        if (not source and not citation) or (source and citation):
            raise ValueError("selection must be either source or citation")
        if citation:
            the_lists = get_citation_referents(handle, self.dbstate.db)
            object = self.dbstate.db.get_citation_from_handle(handle)
            query = DeleteCitationQuery(self.dbstate, self.uistate, object,
                                        the_lists)
            is_used = any(the_lists)
            return (query, is_used, object)
        else:
            the_lists = get_source_and_citation_referents(handle,
                                                                self.dbstate.db)
            LOG.debug('the_lists %s' % [the_lists])

            object = self.dbstate.db.get_source_from_handle(handle)
            query = DeleteSrcQuery(self.dbstate, self.uistate, object,
                                   the_lists)
            is_used = any(the_lists)
            return (query, is_used, object)
Beispiel #7
0
    def remove_object_from_handle(self, handle):
        # The handle will either be a Source handle or a Citation handle
        source = self.dbstate.db.get_source_from_handle(handle)
        citation = self.dbstate.db.get_citation_from_handle(handle)
        if (not source and not citation) or (source and citation):
            raise ValueError("selection must be either source or citation")
        if citation:
            the_lists = get_citation_referents(handle, self.dbstate.db)
            object = self.dbstate.db.get_citation_from_handle(handle)
            query = DeleteCitationQuery(self.dbstate, self.uistate, object,
                                        the_lists)
            is_used = any(the_lists)
            return (query, is_used, object)
        else:
            the_lists = get_source_and_citation_referents(handle,
                                                                self.dbstate.db)
            LOG.debug('the_lists %s' % [the_lists])

            object = self.dbstate.db.get_source_from_handle(handle)
            query = DeleteSrcQuery(self.dbstate, self.uistate, object,
                                   the_lists)
            is_used = any(the_lists)
            return (query, is_used, object)