def test_fetch_doc_and_event_ids_IV(self):

        der_filter = DocumentEventReferenceFilter()
        der_filter.earliest_date = AlexDate(1945)
        der_filter.latest_date = AlexDate(1950)

        references = self.dao.fetch_doc_event_references(der_filter)
        self.assertEqual(0, len(references.keys()))
    def test_fetch_doc_and_event_ids_II(self):

        der_filter = DocumentEventReferenceFilter()
        der_filter.earliest_date = AlexDate(1950)
        references = self.dao.fetch_doc_event_references(der_filter)
        self.assertEqual(1, len(references.keys()))
        self.assertEqual(1, len(references[4]))
        self.assertIn(1960013001, references[4])
        self.assertIn(4, references)
    def test_fetch_doc_and_event_ids_VI(self):

        der_filter = DocumentEventReferenceFilter()
        der_filter.signature = '1.1.I'
        references = self.dao.fetch_doc_event_references(der_filter)
        self.assertEqual(1, len(references.keys()))
        self.assertEqual(1, len(references[1]))
        self.assertIn(1940000001, references[1])
        self.assertIn(1, references)
Ejemplo n.º 4
0
    def export(self, export_info, data):

        self.messenger.show(
            _("CD generation: Assembling event and document information..."))

        ref_filter = DocumentEventReferenceFilter()
        if export_info.signature:
            ref_filter.signature = export_info.signature
        ref_filter.earliest_date = export_info.start_date
        ref_filter.latest_date = export_info.end_date

        event_references = self.references_dao.fetch_doc_event_references(
            ref_filter)
        document_references = {}

        document_map = {}
        event_ids = set()

        keys = event_references.keys()
        documents = self.document_dao.find(
            DOCUMENT_TABLE.c.hauptnr.in_(
                event_references.keys()))  # @UndefinedVariable

        for document in documents:
            document.related_events = event_references[document.id]
            document.file_infos = self.document_file_info_dao.get_file_infos_for_document(
                document.id)
            document_map[document.id] = document
            for event_id in event_references[document.id]:
                if not event_id in document_references:
                    document_references[event_id] = []
                document_references[event_id].append(document.id)
                event_ids.add(event_id)

        events_map = {}
        events = self.event_dao.find(
            EVENT_TABLE.c.ereignis_id.in_(event_ids))  # @UndefinedVariable
        for event in events:
            events_map[event.id] = event
            event.related_documents = document_references[event.id]
            event.related_events = []
            cross_references = self.event_cross_references_dao.get_cross_references(
                event.id)
            for cross_reference in cross_references:
                if cross_reference in event_ids:
                    event.related_events.append(cross_reference)

        data['events'] = events
        data['documents'] = documents
    def test_fetch_doc_and_event_ids_I(self):

        references = self.dao.fetch_doc_event_references(
            DocumentEventReferenceFilter())
        self.assertEqual(7, len(references.keys()))
        self.assertEqual(2, len(references[4]))