def get_document(self, doc_id):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     try:
         ref = UniqueLedgerReference.from_id(doc_id)
         return self.ledger_accessors.get_ledger_value(**ref._asdict()).to_json()
     except LedgerValueNotFound as e:
         raise DocumentNotFoundError(e)
Exemple #2
0
 def get_doc(self, doc_id):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     ref = UniqueLedgerReference.from_id(doc_id)
     try:
         return LedgerAccessorSQL.get_ledger_value(**ref._asdict())
     except CaseNotFound:
         pass
 def get_document(self, doc_id):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     try:
         ref = UniqueLedgerReference.from_id(doc_id)
         return self.ledger_accessors.get_ledger_value(**ref._asdict()).to_json()
     except LedgerValueNotFound as e:
         raise DocumentNotFoundError(e)
Exemple #4
0
 def get_doc(self, doc_id):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     ref = UniqueLedgerReference.from_id(doc_id)
     try:
         return LedgerAccessorSQL.get_ledger_value(**ref._asdict())
     except CaseNotFound:
         pass
Exemple #5
0
 def __init__(self, diff, ref=None):
     if ref is None:
         ref = UniqueLedgerReference.from_id(diff.doc_id)
         diff = diff.json_diff
     else:
         assert not isinstance(diff.path, str), (ref, diff)
     self.ref = ref
     for name in FormJsonDiff._fields:
         setattr(self, name, getattr(diff, name))
 def iter_documents(self, ids):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     case_id_map = defaultdict(list)
     for id_string in ids:
         case_id, section_id, entry_id = UniqueLedgerReference.from_id(id_string)
         case_id_map[(section_id, entry_id)].append(case_id)
     for section_entry, case_ids in case_id_map.iteritems():
         section_id, entry_id = section_entry
         results = self.ledger_accessors.get_ledger_values_for_cases(case_ids, section_id, entry_id)
         for ledger_value in results:
             yield ledger_value.to_json()
 def iter_documents(self, ids):
     from corehq.form_processor.parsers.ledgers.helpers import UniqueLedgerReference
     case_id_map = defaultdict(list)
     for id_string in ids:
         case_id, section_id, entry_id = UniqueLedgerReference.from_id(id_string)
         case_id_map[(section_id, entry_id)].append(case_id)
     for section_entry, case_ids in case_id_map.iteritems():
         section_id, entry_id = section_entry
         results = self.ledger_accessors.get_ledger_values_for_cases(case_ids, section_id, entry_id)
         for ledger_value in results:
             yield ledger_value.to_json()