def create_default_node(my, node_name, search_key=None, context=None): '''Creates a default template structure when loading a context that has no snapshots associated with it @params node_name: the name of the node to be created search_key: a search_key representing the sobject that this node belongs to @return the name of the tactic node created ''' # create the node type = "transform" node_name = my.app.add_node(node_name, type) # create the tactic node tactic_type = "transform" tactic_node_name = "tactic_%s" % node_name tactic_node_name = my.app.add_node(tactic_node_name, tactic_type) # add the tacticNodeData attribute and record the search type node_data = NodeData(tactic_node_name) if search_key: node_data.set_attr("ref", "search_key", search_key) if context: node_data.set_attr("ref", "context", context) node_data.commit() # attache the tactic node to the node my.mel("parent %s %s" % (tactic_node_name, node_name)) return tactic_node_name
def create_default_node(self, node_name, search_key=None, context=None): '''Creates a default template structure when loading a context that has no snapshots associated with it @params node_name: the name of the node to be created search_key: a search_key representing the sobject that this node belongs to @return the name of the tactic node created ''' # create the node type = "transform" node_name = self.app.add_node(node_name, type) # create the tactic node tactic_type = "transform" tactic_node_name = "tactic_%s" % node_name tactic_node_name = self.app.add_node(tactic_node_name, tactic_type) # add the tacticNodeData attribute and record the search type node_data = NodeData(tactic_node_name) if search_key: node_data.set_attr("ref", "search_key", search_key) if context: node_data.set_attr("ref", "context", context) node_data.commit() # attache the tactic node to the node self.mel("parent %s %s" % (tactic_node_name, node_name) ) return tactic_node_name
def add_snapshot_to_node(my, tactic_node_name, snapshot): snapshot_code = snapshot.get('code') search_type = snapshot.get('search_type') search_id = snapshot.get('search_id') context = snapshot.get('context') version = snapshot.get('version') revision = snapshot.get('revision') node_data = NodeData(tactic_node_name) node_data.set_attr("ref", "snapshot_code", snapshot_code) node_data.set_attr("ref", "search_type", search_type) node_data.set_attr("ref", "search_id", search_id) node_data.set_attr("ref", "context", context) node_data.set_attr("ref", "version", version) node_data.set_attr("ref", "revision", revision) node_data.commit()
def add_snapshot_to_node(self, tactic_node_name, snapshot): snapshot_code = snapshot.get('code') search_type = snapshot.get('search_type') search_id = snapshot.get('search_id') context = snapshot.get('context') version = snapshot.get('version') revision = snapshot.get('revision') node_data = NodeData(tactic_node_name) node_data.set_attr("ref", "snapshot_code", snapshot_code) node_data.set_attr("ref", "search_type", search_type) node_data.set_attr("ref", "search_id", search_id) node_data.set_attr("ref", "context", context) node_data.set_attr("ref", "version", version) node_data.set_attr("ref", "revision", revision) node_data.commit()