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 get_context(my, tactic_node_name):
        '''gets the snapshot data on a particular tactic node
        <node>
          <ref context='model' version='3' search_type='prod/asset?project=bar' search_id='4'/>
        </node>

        '''
        node_data = NodeData(tactic_node_name)
        search_type = node_data.get_attr("ref", "context")
        return search_type
Exemple #3
0
    def execute(self):

        # create an xml document
        xml_impl = getDOMImplementation()
        doc = xml_impl.createDocument(None, "session", None)
        root = doc.documentElement

        # go through the tactic
        tactic_nodes = self.util.get_all_tactic_nodes()
        tactic_nodes.sort()
        for tactic_node in tactic_nodes:
            node_data = NodeData(tactic_node)
            ref_node = node_data.get_ref_node()
            root.appendChild(ref_node)

        self.xml = doc.toxml()
        return self.xml
    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()
Exemple #5
0
 def add_node(self, node_id: int, pos: tuple = None) -> bool:
     """
     Adds a node to the graph.
     @param node_id: The node ID.
     @param pos: The position of the node.
     @return: True if the node was added successfully, False o.w.
     If the node id already exists the node will not be added.
     """
     if node_id in self.__nodes:
         return False
     node = NodeData(node_id, pos)
     self.__nodes[node_id] = node
     self.edges[node_id] = {}
     self.end_edges[node_id] = {}
     self.__mc += 1
     self.__node_size += 1
     return True
Exemple #6
0
    def introspect(my):
        '''introspect the session and create a session xml from it'''
        # create an xml document
        xml_impl = getDOMImplementation()
        my.doc = xml_impl.createDocument(None, "session", None)
        my.root = my.doc.documentElement

        # go through the tactic
        tactic_nodes = my.util.get_all_tactic_nodes()
        tactic_nodes.sort()
        for tactic_node in tactic_nodes:

            node_data = NodeData(tactic_node)
            ref_node = node_data.get_ref_node()

            # set some more info on the ref node
            ref_node.setAttribute("tactic_node", tactic_node)
            my.root.appendChild(ref_node)

        my.xml = my.doc.toprettyxml()
        return my.xml
Exemple #7
0
 def get_node_data(my, node_name):
     return NodeData(node_name)
Exemple #8
0
 def get_node_data(self, node_name):
     return NodeData(node_name)