Esempio n. 1
0
def reset_collection(collection):
    """Reset the collection by deleting any derived data."""
    drop_aggregator(collection)
    Match.delete_by_collection(collection.id)
    db.session.commit()
    cancel_queue(collection)
    refresh_collection(collection.id)
Esempio n. 2
0
def reset_collection(collection, sync=False):
    """Reset the collection by deleting any derived data."""
    drop_aggregator(collection)
    Match.delete_by_collection(collection.id)
    cancel_queue(collection)
    index.delete_entities(collection.id, sync=sync)
    refresh_collection(collection.id)
    db.session.commit()
Esempio n. 3
0
def reset_collection(collection, sync=False):
    """Reset the collection by deleting any derived data."""
    drop_aggregator(collection)
    cancel_queue(collection)
    flush_notifications(collection, sync=sync)
    index.delete_entities(collection.id, sync=sync)
    xref_index.delete_xref(collection, sync=sync)
    refresh_collection(collection.id, sync=sync)
Esempio n. 4
0
def flush_mapping(stage, collection, mapping_id, sync=False):
    """Delete entities loaded by a mapping"""
    log.debug("Flushing entities for mapping: %s", mapping_id)
    delete_entities(collection.id, mapping_id=mapping_id, sync=True)
    drop_aggregator(collection)
    collection.touch()
    db.session.commit()
    update_collection(collection)
Esempio n. 5
0
def delete_collection(collection, sync=False):
    flush_notifications(collection)
    drop_aggregator(collection)
    deleted_at = collection.deleted_at or datetime.utcnow()
    Entity.delete_by_collection(collection.id, deleted_at=deleted_at)
    Match.delete_by_collection(collection.id, deleted_at=deleted_at)
    Permission.delete_by_collection(collection.id, deleted_at=deleted_at)
    collection.delete(deleted_at=deleted_at)
    db.session.commit()
    index.delete_collection(collection.id, sync=sync)
    index.delete_entities(collection.id, sync=False)
    refresh_collection(collection.id)
    Authz.flush()
Esempio n. 6
0
    def load_fixtures(self):
        self.admin = self.create_user(foreign_id='admin', is_admin=True)
        self.private_coll = self.create_collection(foreign_id='test_private',
                                                   label="Private Collection",
                                                   category='grey',
                                                   casefile=False,
                                                   creator=self.admin)
        self._banana = Entity.create(
            {
                'schema': 'Person',
                'properties': {
                    'name': ['Banana'],
                }
            }, self.private_coll)
        user = Role.by_foreign_id(Role.SYSTEM_USER)
        Permission.grant(self.private_coll, user, True, False)
        self.public_coll = self.create_collection(foreign_id='test_public',
                                                  label="Public Collection",
                                                  category='news',
                                                  casefile=False,
                                                  creator=self.admin)
        self._kwazulu = Entity.create(
            {
                'schema': 'Company',
                'properties': {
                    'name': ['KwaZulu'],
                    'alias': ['kwazulu']
                }
            }, self.public_coll)
        visitor = Role.by_foreign_id(Role.SYSTEM_GUEST)
        Permission.grant(self.public_coll, visitor, True, False)
        db.session.commit()

        drop_aggregator(self.public_coll)
        stage = get_stage(self.public_coll, OP_PROCESS)
        process_collection(stage, self.public_coll, ingest=False, sync=True)

        aggregator = get_aggregator(self.private_coll)
        aggregator.delete()
        stage = get_stage(self.private_coll, OP_PROCESS)
        for sample in read_entities(self.get_fixture_path('samples.ijson')):
            aggregator.put(sample, fragment='sample')
            index_aggregate(stage,
                            self.private_coll,
                            entity_id=sample.id,
                            sync=True)
        aggregator.close()
        process_collection(stage, self.private_coll, ingest=False, sync=True)
Esempio n. 7
0
 def load_fixtures(self):
     self.private_coll = Collection.create({
         'foreign_id': 'test_private',
         'label': "Private Collection",
         'category': 'grey'
     })
     self._banana = Entity.create(
         {
             'schema': 'Person',
             'properties': {
                 'name': ['Banana'],
             }
         }, self.private_coll)
     user = Role.by_foreign_id(Role.SYSTEM_USER)
     Permission.grant(self.private_coll, user, True, False)
     self.public_coll = Collection.create({
         'foreign_id': 'test_public',
         'label': "Public Collection",
         'category': 'news'
     })
     self._kwazulu = Entity.create(
         {
             'schema': 'Company',
             'properties': {
                 'name': ['KwaZulu'],
                 'alias': ['kwazulu']
             }
         }, self.public_coll)
     visitor = Role.by_foreign_id(Role.SYSTEM_GUEST)
     Permission.grant(self.public_coll, visitor, True, False)
     db.session.commit()
     drop_aggregator(self.public_coll)
     stage = get_stage(self.private_coll, OP_PROCESS)
     process_collection(stage, self.public_coll, ingest=False, sync=True)
     stage = get_stage(self.private_coll, OP_INDEX)
     samples = read_entities(self.get_fixture_path('samples.ijson'))
     drop_aggregator(self.private_coll)
     index_entities(stage, self.private_coll, samples, sync=True)
     stage = get_stage(self.private_coll, OP_PROCESS)
     process_collection(stage, self.private_coll, ingest=False, sync=True)