def search_leaf_node_id(nodePath, perspectiveId, parentNodeId, cookie):
    if nodePath:
        currentNode = nodePath.pop()
        registeredNodes = rest.get_nodes_from_parent(perspectiveId, parentNodeId, 'node', cookie)
        for registeredNode in registeredNodes:
            if registeredNode['text'] == currentNode:
                return search_leaf_node_id(nodePath, registeredPerspective['id'], registeredNode['id'], cookie)
    return parentNodeId
Пример #2
0
def search_leaf_node_id(nodePath, perspectiveId, parentNodeId, cookie):
    if nodePath:
        currentNode = nodePath.pop()
        registeredNodes = rest.get_nodes_from_parent(perspectiveId,
                                                     parentNodeId, 'node',
                                                     cookie)
        for registeredNode in registeredNodes:
            if registeredNode['text'] == currentNode:
                return search_leaf_node_id(nodePath,
                                           registeredPerspective['id'],
                                           registeredNode['id'], cookie)
    return parentNodeId
Пример #3
0
def handle_get_nodes_from_file_option():
    cookie = rest.login_holmes()
    parentNodeIdSet = Set()
    for data in nodes.DATA:
        if data['parentNodeId'] not in parentNodeIdSet:
            parentNodeIdSet.add(data['parentNodeId'])
            nodeList = rest.get_nodes_from_parent(data['perspectiveId'], data['parentNodeId'], 'root', cookie)
            print 'Total nodes: %s' % len(nodeList)
            if len(nodeList) > 0:
                print 'Nodes list:',
            for item in nodeList:
                print '"%s"' % item['text'], 
            print
Пример #4
0
def handle_get_nodes_from_file_option():
    cookie = rest.login_holmes()
    parentNodeIdSet = Set()
    for data in nodes.DATA:
        if data['parentNodeId'] not in parentNodeIdSet:
            parentNodeIdSet.add(data['parentNodeId'])
            nodeList = rest.get_nodes_from_parent(data['perspectiveId'],
                                                  data['parentNodeId'], 'root',
                                                  cookie)
            print 'Total nodes: %s' % len(nodeList)
            if len(nodeList) > 0:
                print 'Nodes list:',
            for item in nodeList:
                print '"%s"' % item['text'],
            print
    if debug: print "nodePath = %s " % nodePath

    queryPerspective = '-e select name from perspective where root_node_id =  %s' % rootNodeId
    perspectiveLine = subprocess.Popen(["mysql", '-B', '-uroot', '-Dglbsce', queryPerspective], stdout=subprocess.PIPE).stdout
    perspectiveLine.readline() #ignoring first line (column names)
    perspectiveName = perspectiveLine.readline().rstrip('\n')
        
    registeredPerspectives = rest.get_perspectives(cookie)
    for registeredPerspective in registeredPerspectives:
        if registeredPerspective['name'] == perspectiveName.decode('utf-8'):
            break
        
    if nodePath:
        currentNode = nodePath.pop()
        if debug: print "currentNode: %s" % currentNode
        registeredNodes = rest.get_nodes_from_parent(registeredPerspective['id'], registeredPerspective['rootnode_id'], 'root', cookie)
        for registeredNode in registeredNodes:
            if registeredNode['text'] == currentNode.decode('utf-8'):
                leafNodeId = search_leaf_node_id(nodePath, registeredPerspective['id'], registeredNode['id'], cookie)
    else:
        leafNodeId = rootNodeId

    if debug: print "leafNodeId = %s" % leafNodeId
    
#    if leafNodeId != -1:
    if nodeEntitiesDict.has_key(leafNodeId):
        nodeEntitiesDict[leafNodeId].add(entityId)
    else:
        nodeEntitiesDict[leafNodeId] = set([entityId])
    # going to next loop iteration    
    nodeEntityLine = nodeEntityFile.readline()
Пример #6
0
    perspectiveLine = subprocess.Popen(
        ["mysql", '-B', '-uroot', '-Dglbsce', queryPerspective],
        stdout=subprocess.PIPE).stdout
    perspectiveLine.readline()  #ignoring first line (column names)
    perspectiveName = perspectiveLine.readline().rstrip('\n')

    registeredPerspectives = rest.get_perspectives(cookie)
    for registeredPerspective in registeredPerspectives:
        if registeredPerspective['name'] == perspectiveName.decode('utf-8'):
            break

    if nodePath:
        currentNode = nodePath.pop()
        if debug: print "currentNode: %s" % currentNode
        registeredNodes = rest.get_nodes_from_parent(
            registeredPerspective['id'], registeredPerspective['rootnode_id'],
            'root', cookie)
        for registeredNode in registeredNodes:
            if registeredNode['text'] == currentNode.decode('utf-8'):
                leafNodeId = search_leaf_node_id(nodePath,
                                                 registeredPerspective['id'],
                                                 registeredNode['id'], cookie)
    else:
        leafNodeId = rootNodeId

    if debug: print "leafNodeId = %s" % leafNodeId

    #    if leafNodeId != -1:
    if nodeEntitiesDict.has_key(leafNodeId):
        nodeEntitiesDict[leafNodeId].add(entityId)
    else: