clients.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:prov2bigchaindb 作者: DLR-SC 项目源码 文件源码
def save_document(self, document: str or BufferedReader or provmodel.ProvDocument) -> list:
        """
        Write a document into BigchainDB

        :param document: Document as JSON/XML/PROVN
        :type document: str or BufferedReader or ProvDocument
        :return: List of transaction ids
        :rtype: list
        """
        log.info("Save document...")
        document_tx_ids = []
        prov_document = utils.to_prov_document(content=document)
        account_data = RoleConceptClient.calculate_account_data(prov_document)

        id_mapping = {}
        log.info("Create and Save instances")
        for agent, relations, elements, namespaces in account_data:
            account = accounts.RoleConceptAccount(agent, relations, elements, id_mapping, namespaces, self.store)
            self.accounts.append(account)
            tx_id = account.save_instance_asset(self._get_bigchain_connection())
            document_tx_ids.append(tx_id)

        log.info("Save elements")
        for account in self.accounts:
            document_tx_ids += account.save_elements(self._get_bigchain_connection())

        log.info("Saved document in %s Tx", len(document_tx_ids))
        return document_tx_ids
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号