def convertIds(vistrail): actions = vistrail.db_get_actions() actions.sort(key=lambda x: x.db_id) objectDict = {} # refDict = {'objectDict': objectDict} graph = Graph() for action in actions: graph.add_vertex(action.db_id) graph.add_edge(action.db_prevId, action.db_id) def convertAction(actionId): # print 'converting %s' % actionId if actionId == 0: return allOps = [] action = vistrail.db_get_action(actionId) # objectDict = refDict['objectDict'] # if action.actionType == 'delete' or action.actionType == 'change': # action.objectDict = copy.deepcopy(objectDict) # else: # action.objectDict = objectDict for operation in action.db_get_operations(): allOps.extend(convertOperation(vistrail, objectDict, operation.vtType, operation)) action.db_operations = allOps def removeObjects(actionId): if actionId == 0: return # print "removeObjects(%s)" % actionId action = vistrail.db_get_action(actionId) # need to reverse ops here reverseOps = action.db_get_operations() reverseOps.reverse() for operation in reverseOps: parentList = getTypeIdList(operation) removeObject(operation.db_what, operation.db_oldId, objectDict, parentList[:-1]) reverseOps.reverse() graph.dfs(enter_vertex=convertAction, leave_vertex=removeObjects)
def getVersionGraph(self): """getVersionGraph() -> Graph Returns the version graph """ result = Graph() result.add_vertex(0) # the sorting is for the display using graphviz # we want to always add nodes from left to right for action in sorted(self.actionMap.itervalues(), key=lambda x: x.timestep): # We need to check the presence of the parent's timestep # on the graph because it might have been previously # pruned. Remember that pruning is only marked for the # topmost invisible action. if (action.parent in result.vertices and not self.is_pruned(action.id)): result.add_edge(action.parent, action.timestep, 0) return result
def convertIds(vistrail): actions = vistrail.db_get_actions() actions.sort(key=lambda x: x.db_id) objectDict = {} # refDict = {'objectDict': objectDict} graph = Graph() for action in actions: graph.add_vertex(action.db_id) graph.add_edge(action.db_prevId, action.db_id) def convertAction(actionId): if actionId == 0: return allOps = [] action = vistrail.db_get_action(actionId) # objectDict = refDict['objectDict'] # if action.actionType == 'delete' or action.actionType == 'change': # action.objectDict = copy.deepcopy(objectDict) # else: # action.objectDict = objectDict for operation in action.db_get_operations(): allOps.extend(convertOperation(vistrail, objectDict, operation.vtType, operation)) action.db_operations = allOps def removeObjects(actionId): if actionId == 0: return # print "removeObjects(%s)" % actionId action = vistrail.db_get_action(actionId) # need to reverse ops here reverseOps = action.db_get_operations() reverseOps.reverse() for operation in reverseOps: parentList = getTypeIdList(operation) removeObject(operation.db_what, operation.db_oldId, objectDict, parentList[:-1]) reverseOps.reverse() graph.dfs(enter_vertex=convertAction, leave_vertex=removeObjects)
class ExplicitExpandedVersionTree(object): """ Keep explicit expanded and tersed version trees. """ def __init__(self, vistrail): self.vistrail = vistrail self.expandedVersionTree = Graph() self.expandedVersionTree.add_vertex(0) self.tersedVersionTree = Graph() def addVersion(self, id, prevId): # print "add version %d child of %d" % (id, prevId) self.expandedVersionTree.add_vertex(id) self.expandedVersionTree.add_edge(prevId,id,0) def getVersionTree(self): return self.expandedVersionTree
class ExplicitExpandedVersionTree(object): """ Keep explicit expanded and tersed version trees. """ def __init__(self, vistrail): self.vistrail = vistrail self.expandedVersionTree = Graph() self.expandedVersionTree.add_vertex(0) self.tersedVersionTree = Graph() def addVersion(self, id, prevId): # print "add version %d child of %d" % (id, prevId) self.expandedVersionTree.add_vertex(id) self.expandedVersionTree.add_edge(prevId, id, 0) def getVersionTree(self): return self.expandedVersionTree
def __init__(self, vistrail): self.vistrail = vistrail self.expandedVersionTree = Graph() self.expandedVersionTree.add_vertex(0) self.tersedVersionTree = Graph()