def get_document_store_for_doc_type(domain, doc_type, case_type_or_xmlns=None, load_source="unknown"): """Only applies to documents that have a document type: * forms * cases * locations * all couch models """ from corehq.apps.change_feed import document_types if doc_type in all_known_formlike_doc_types(): store = ReadonlyFormDocumentStore(domain, xmlns=case_type_or_xmlns) load_counter = form_load_counter elif doc_type in document_types.CASE_DOC_TYPES: store = ReadonlyCaseDocumentStore(domain, case_type=case_type_or_xmlns) load_counter = case_load_counter elif doc_type == LOCATION_DOC_TYPE: return ReadonlyLocationDocumentStore(domain) else: # all other types still live in couchdb return CouchDocumentStore(couch_db=get_db_by_doc_type(doc_type), domain=domain, doc_type=doc_type) track_load = load_counter(load_source, domain) return DocStoreLoadTracker(store, track_load)
def get_document_store(data_source_type, data_source_name, domain): if data_source_type == COUCH: try: return CouchDocumentStore( couch_config.get_db_for_db_name(data_source_name)) except DatabaseNotFound: # in debug mode we may be flipping around our databases so don't fail hard here if settings.DEBUG: return None raise elif data_source_type == FORM_SQL: return ReadonlyFormDocumentStore(domain) elif data_source_type == CASE_SQL: return ReadonlyCaseDocumentStore(domain) elif data_source_type == SMS: return ReadonlySMSDocumentStore() elif data_source_type == LEDGER_V2: return ReadonlyLedgerV2DocumentStore(domain) elif data_source_type == LEDGER_V1: return LedgerV1DocumentStore(domain) elif data_source_type == LOCATION: return ReadonlyLocationDocumentStore(domain) else: raise UnknownDocumentStore( 'getting document stores for backend {} is not supported!'.format( data_source_type))
def get_document_store(data_source_type, data_source_name, domain): # change this to just 'data_source_name' after June 2018 type_or_name = (data_source_type, data_source_name) if data_source_type == SOURCE_COUCH: try: return CouchDocumentStore( couch_config.get_db_for_db_name(data_source_name)) except DatabaseNotFound: # in debug mode we may be flipping around our databases so don't fail hard here if settings.DEBUG: return None raise elif FORM_SQL in type_or_name: return ReadonlyFormDocumentStore(domain) elif CASE_SQL in type_or_name: return ReadonlyCaseDocumentStore(domain) elif SMS in type_or_name: return ReadonlySMSDocumentStore() elif LEDGER_V2 in type_or_name: return ReadonlyLedgerV2DocumentStore(domain) elif LEDGER_V1 in type_or_name: return LedgerV1DocumentStore(domain) elif LOCATION in type_or_name: return ReadonlyLocationDocumentStore(domain) elif SYNCLOG_SQL in type_or_name: return ReadonlySyncLogDocumentStore() else: raise UnknownDocumentStore( 'getting document stores for backend {} is not supported!'.format( data_source_type))
def get_document_store(domain, doc_type): use_sql = should_use_sql_backend(domain) if use_sql and doc_type == 'XFormInstance': return ReadonlyFormDocumentStore(domain) elif use_sql and doc_type == 'CommCareCase': return ReadonlyCaseDocumentStore(domain) else: # all other types still live in couchdb return CouchDocumentStore(couch_db=get_db_by_doc_type(doc_type), domain=domain, doc_type=doc_type)
def get_document_store(domain, doc_type, case_type_or_xmlns=None): if doc_type == 'XFormInstance': return ReadonlyFormDocumentStore(domain, xmlns=case_type_or_xmlns) elif doc_type == 'CommCareCase': return ReadonlyCaseDocumentStore(domain, case_type=case_type_or_xmlns) elif doc_type == LOCATION_DOC_TYPE: return ReadonlyLocationDocumentStore(domain) else: # all other types still live in couchdb return CouchDocumentStore(couch_db=get_db_by_doc_type(doc_type), domain=domain, doc_type=doc_type)
def get_document_store_for_doc_type(domain, doc_type, case_type_or_xmlns=None): """Only applies to documents that have a document type: * forms * cases * locations * all couch models """ from corehq.apps.change_feed import document_types if doc_type in all_known_formlike_doc_types(): return ReadonlyFormDocumentStore(domain, xmlns=case_type_or_xmlns) elif doc_type in document_types.CASE_DOC_TYPES: return ReadonlyCaseDocumentStore(domain, case_type=case_type_or_xmlns) elif doc_type == LOCATION_DOC_TYPE: return ReadonlyLocationDocumentStore(domain) else: # all other types still live in couchdb return CouchDocumentStore(couch_db=get_db_by_doc_type(doc_type), domain=domain, doc_type=doc_type)