Exemplo n.º 1
0
    def __init__(self, rzdoc):
        """
        Rhizi version control - initialize meta namespace block chain
        """
        super(DBO_block_chain__init, self).__init__()

        #
        # setup meta rzdoc NS
        #
        meta_ns_label_q = quote__backtick(rzdoc__meta_ns_label(rzdoc))
        q_arr = ['create (n:%s:%s:%s {commit_attr})' % (meta_ns_label_q,
                                                        neo4j_schema.META_LABEL__VC_HEAD,
                                                        neo4j_schema.META_LABEL__VC_COMMIT,
                                                        ),
                 'set n.ts_created=timestamp()', ]

        hash_value = neo4j_schema.META_LABEL__VC_EMPTY_RZDOC_HASH
        param_set = {'commit_attr': {
                                       'blob': '',
                                       'hash': hash_value,
                                       'id': hash_value,
                                       'name': 'root-commit'},
                       }

        db_q = DB_Query(q_arr, param_set)
        self.add_db_query(db_q)
Exemplo n.º 2
0
    def __init__(self, rzdoc):
        """
        Rhizi version control - initialize meta namespace block chain
        """
        super(DBO_block_chain__init, self).__init__()

        #
        # setup meta rzdoc NS
        #
        meta_ns_label_q = quote__backtick(rzdoc__meta_ns_label(rzdoc))
        q_arr = [
            'create (n:%s:%s:%s {commit_attr})' % (
                meta_ns_label_q,
                neo4j_schema.META_LABEL__VC_HEAD,
                neo4j_schema.META_LABEL__VC_COMMIT,
            ),
            'set n.ts_created=timestamp()',
        ]

        hash_value = neo4j_schema.META_LABEL__VC_EMPTY_RZDOC_HASH
        param_set = {
            'commit_attr': {
                'blob': '',
                'hash': hash_value,
                'id': hash_value,
                'name': 'root-commit'
            },
        }

        db_q = DB_Query(q_arr, param_set)
        self.add_db_query(db_q)
Exemplo n.º 3
0
    def __init__(self, rzdoc):
        """
        delete a rhizi doc
        """
        super(DBO_rzdoc__delete, self).__init__()

        rzdoc_label_q = quote__backtick(rzdoc__ns_label(rzdoc))
        rzdoc_id_q = quote__singlequote(rzdoc.id)

        # delete doc nodes & links
        q_arr = [
            'match (n:%s)' % (rzdoc_label_q),
            'optional match (n:%s)-[r]-()' % (rzdoc_label_q), 'delete r,n'
        ]
        db_q = DB_Query(q_arr)
        self.add_db_query(db_q)

        # delete doc meta node
        q_arr = [
            'match (n:%s {id: %s})' %
            (neo4j_schema.META_LABEL__RZDOC_TYPE, rzdoc_id_q),
            'optional match (n)-[r]-()', 'delete r,n'
        ]
        db_q = DB_Query(q_arr)
        self.add_db_query(db_q)
Exemplo n.º 4
0
    def add_link_rename_statements(self, id_attr, new_label):
        # TODO - where do we sanitize the label name? any better way of doing this?
        # XXX - the return here is a bit verbose? maybe better built on python side?
        # NONGOALS: doing this on the client.

        # Should assert the following returns 1
        # match n-[l:new_label]->m return count(l)
        # Not doing so to avoid roundtrip - the following doesn't require knowing
        # the replaced label.

        q_create_new = ["match (n)-[l_old {id: {id}}]->(m)",
                        "create (n)-[l_new:%s]->(m) set l_new=l_old" % db_util.quote__backtick(new_label),
                        "return l_new.id, {id: l_new.id, name: type(l_new)}",  # currently unused
                        ]
        q_delete_old = ["match (n)-[l_old {id: {id}}]->(m)",
                        "where type(l_old)<>'%s' delete l_old" % new_label,
                        ]
        q_param_set = {'id': id_attr}
        self.add_statement(q_create_new, q_param_set)
        self.add_statement(q_delete_old, q_param_set)
Exemplo n.º 5
0
    def __init__(self, rzdoc):
        """
        delete a rhizi doc
        """
        super(DBO_rzdoc__delete, self).__init__()

        rzdoc_label_q = quote__backtick(rzdoc__ns_label(rzdoc))
        rzdoc_id_q = quote__singlequote(rzdoc.id)

        # delete doc nodes & links
        q_arr = ['match (n:%s)' % (rzdoc_label_q),
                 'optional match (n:%s)-[r]-()' % (rzdoc_label_q),
                 'delete r,n']
        db_q = DB_Query(q_arr)
        self.add_db_query(db_q)

        # delete doc meta node
        q_arr = ['match (n:%s {id: %s})' % (neo4j_schema.META_LABEL__RZDOC_TYPE,
                                           rzdoc_id_q),
                 'optional match (n)-[r]-()',
                 'delete r,n']
        db_q = DB_Query(q_arr)
        self.add_db_query(db_q)
Exemplo n.º 6
0
    def add_link_rename_statements(self, id_attr, new_label):
        # TODO - where do we sanitize the label name? any better way of doing this?
        # XXX - the return here is a bit verbose? maybe better built on python side?
        # NONGOALS: doing this on the client.

        # Should assert the following returns 1
        # match n-[l:new_label]->m return count(l)
        # Not doing so to avoid roundtrip - the following doesn't require knowing
        # the replaced label.

        q_create_new = [
            "match (n)-[l_old {id: {id}}]->(m)",
            "create (n)-[l_new:%s]->(m) set l_new=l_old" %
            db_util.quote__backtick(new_label),
            "return l_new.id, {id: l_new.id, name: type(l_new)}",  # currently unused
        ]
        q_delete_old = [
            "match (n)-[l_old {id: {id}}]->(m)",
            "where type(l_old)<>'%s' delete l_old" % new_label,
        ]
        q_param_set = {'id': id_attr}
        self.add_statement(q_create_new, q_param_set)
        self.add_statement(q_delete_old, q_param_set)