Пример #1
0
 def get_associated_datasenders(self, dbm):
     keys = [([REPORTER], short_code) for short_code in self.data_senders]
     rows = dbm.view.by_short_codes(reduce=False,
                                    include_docs=True,
                                    keys=keys)
     return [
         Entity.new_from_doc(dbm,
                             Entity.__document_class__.wrap(row.get('doc')))
         for row in rows
     ]
Пример #2
0
def void_data_records(database_name):
    dbm = get_db_manager(database_name)
    entities = dbm.load_all_rows_in_view('entity_by_short_code', include_docs=True)
    for entity in entities:
        if entity['doc']['document_type'] == 'Entity':
            entity = Entity.new_from_doc(dbm, EntityDocument.wrap(entity['doc']))
            if entity.is_void():
                data_records = dbm.load_all_rows_in_view('entity_data', key=entity.id)
                for record in data_records:
                    dbm.invalidate(record.id)
Пример #3
0
 def test_should_create_entity_from_document(self):
     existing = self.dbm.get(self.uuid, Entity)
     e = Entity.new_from_doc(self.dbm, existing._doc)
     self.assertTrue(e._doc is not None)
     self.assertEqual(e.id, existing.id)
     self.assertEqual(e.type_path, existing.type_path)
Пример #4
0
def _from_row_to_subject(dbm, row):
    return Entity.new_from_doc(dbm=dbm,
                               doc=Entity.__document_class__.wrap(
                                   row.get('value')))
Пример #5
0
def _get_entity_for_row(manager, row, type):
    short_code = row['doc']['short_code']
    entity = Entity.new_from_doc(dbm=manager,
                                 doc=Entity.__document_class__.wrap(
                                     row.get('doc')))
    return entity, short_code
Пример #6
0
def _get_entity_for_row(manager, row, type):
    short_code = row['doc']['short_code']
    entity = Entity.new_from_doc(dbm=manager, doc=Entity.__document_class__.wrap(row.get('doc')))
    return entity, short_code
Пример #7
0
 def test_should_create_entity_from_document(self):
     existing = self.dbm.get(self.uuid, Entity)
     e = Entity.new_from_doc(self.dbm, existing._doc)
     self.assertTrue(e._doc is not None)
     self.assertEqual(e.id, existing.id)
     self.assertEqual(e.type_path, existing.type_path)