<s> from __future__ import division <EOL> from datetime import datetime <EOL> import sys <EOL> from vistrails . core . data_structures . graph import Graph <EOL> from vistrails . core . system import time_strptime <EOL> from vistrails . db . versions . v0_6_0 . domain import DBVistrail , DBAction , DBTag , DBModule , DBConnection , DBPortSpec , DBFunction , DBParameter , DBLocation , DBAdd , DBChange , DBDelete , DBAnnotation , DBPort <EOL> def convertDate ( date ) : <EOL> if date is not None and date != '<STR_LIT>' : <EOL> return datetime ( * time_strptime ( date , '<STR_LIT>' ) [ <NUM_LIT:0> : <NUM_LIT:6> ] ) <EOL> return datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> def translateVistrail ( _vistrail ) : <EOL> vistrail = DBVistrail ( ) <EOL> id_scope = vistrail . idScope <EOL> for _action in _vistrail . db_get_actions ( ) : <EOL> functionName = '<STR_LIT>' % ( _action . db_what [ <NUM_LIT:0> ] . upper ( ) , _action . db_what [ <NUM_LIT:1> : ] ) <EOL> thisModule = sys . modules [ __name__ ] <EOL> action = getattr ( thisModule , functionName ) ( _action , id_scope ) <EOL> vistrail . db_add_action ( action ) <EOL> for _tag in _vistrail . db_get_tags ( ) : <EOL> tag = DBTag ( id = _tag . db_time , <EOL> name = _tag . db_name ) <EOL> vistrail . db_add_tag ( tag ) <EOL> convertIds ( vistrail ) <EOL> vistrail . db_version = '<STR_LIT>' <EOL> return vistrail <EOL> def createAction ( _action , operations , id_scope ) : <EOL> annotations = { } <EOL> if _action . db_notes is not None and _action . db_notes . strip ( ) != '<STR_LIT>' : <EOL> annotations [ '<STR_LIT>' ] = DBAnnotation ( id = id_scope . getNewId ( DBAnnotation . vtType ) , <EOL> key = '<STR_LIT>' , <EOL> value = _action . db_notes . strip ( ) , <EOL> ) <EOL> return DBAction ( id = _action . db_time , <EOL> prevId = _action . db_parent , <EOL> date = convertDate ( _action . db_date ) , <EOL> user = _action . db_user , <EOL> operations = operations , <EOL> annotations = annotations , <EOL> ) <EOL> def translateAddModuleAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _module in _action . db_datas : <EOL> module = DBModule ( id = _module . db_id , <EOL> name = _module . db_name , <EOL> cache = <NUM_LIT:1> , <EOL> location = DBLocation ( id = _module . db_id , <EOL> x = _module . db_x , <EOL> y = _module . db_y ) ) <EOL> module . db_location . relative = False <EOL> operation = DBAdd ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _module . db_id , <EOL> data = module ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateAddConnectionAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _connection in _action . db_datas : <EOL> source = DBPort ( id = _connection . db_id , <EOL> type = '<STR_LIT:source>' , <EOL> moduleId = _connection . db_sourceId , <EOL> moduleName = _connection . db_sourceModule , <EOL> sig = _connection . db_sourcePort ) <EOL> destination = DBPort ( id = _connection . db_id , <EOL> type = '<STR_LIT>' , <EOL> moduleId = _connection . db_destinationId , <EOL> moduleName = _connection . db_destinationModule , <EOL> sig = _connection . db_destinationPort ) <EOL> connection = DBConnection ( id = _connection . db_id , <EOL> ports = [ source , destination ] ) <EOL> operation = DBAdd ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _connection . db_id , <EOL> data = connection ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateChangeParameterAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _set in _action . db_datas : <EOL> parameter = DBParameter ( id = _set . db_parameterId , <EOL> pos = _set . db_parameterId , <EOL> name = _set . db_parameter , <EOL> alias = _set . db_alias , <EOL> val = _set . db_value , <EOL> type = _set . db_type ) <EOL> function = DBFunction ( id = _set . db_functionId , <EOL> pos = _set . db_functionId , <EOL> name = _set . db_function , <EOL> parameters = [ parameter ] ) <EOL> operation = DBChange ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> oldObjId = _set . db_functionId , <EOL> parentObjId = _set . db_moduleId , <EOL> parentObjType = '<STR_LIT>' , <EOL> data = function ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateAddModulePortAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _portSpec in _action . db_datas : <EOL> portSpec = DBPortSpec ( id = _portSpec . db_moduleId , <EOL> name = _portSpec . db_portName , <EOL> type = _portSpec . db_portType , <EOL> spec = _portSpec . db_portSpec ) <EOL> operation = DBAdd ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = ( _portSpec . db_portName , <EOL> _portSpec . db_portType ) , <EOL> parentObjId = _portSpec . db_moduleId , <EOL> parentObjType = '<STR_LIT>' , <EOL> data = portSpec ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateChangeAnnotationAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _annotation in _action . db_datas : <EOL> if _annotation . db_key . strip ( ) != '<STR_LIT>' or _annotation . db_value . strip ( ) != '<STR_LIT>' : <EOL> annotation = DBAnnotation ( id = - <NUM_LIT:1> , <EOL> key = _annotation . db_key , <EOL> value = _annotation . db_value ) <EOL> operation = DBChange ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> oldObjId = _annotation . db_key , <EOL> parentObjId = _annotation . db_moduleId , <EOL> parentObjType = '<STR_LIT>' , <EOL> data = annotation ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateDeleteModuleAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _module in _action . db_datas : <EOL> operation = DBDelete ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _module . db_moduleId ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateDeleteConnectionAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _connection in _action . db_datas : <EOL> operation = DBDelete ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _connection . db_connectionId ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateDeleteFunctionAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _function in _action . db_datas : <EOL> operation = DBDelete ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _function . db_functionId , <EOL> parentObjId = _function . db_moduleId , <EOL> parentObjType = '<STR_LIT>' ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateDeleteAnnotationAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _annotation in _action . db_datas : <EOL> operation = DBDelete ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = _annotation . db_key ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateDeleteModulePortAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _portSpec in _action . db_datas : <EOL> operation = DBDelete ( id = _action . db_time , <EOL> what = '<STR_LIT>' , <EOL> objectId = ( _portSpec . db_portName , <EOL> _portSpec . db_portType ) , <EOL> parentObjId = _portSpec . db_moduleId , <EOL> parentObjType = '<STR_LIT>' ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def translateMoveModuleAction ( _action , id_scope ) : <EOL> operations = [ ] <EOL> for _location in _action . db_datas : <EOL> location = DBLocation ( id = _location . db_id , <EOL> x = _location . db_dx , <EOL> y = _location . db_dy ) <EOL> location . relative = True <EOL> operation = DBChange ( id = _action . db_time , <EOL> what = '<STR_LIT:location>' , <EOL> oldObjId = _location . db_id , <EOL> parentObjId = _location . db_id , <EOL> parentObjType = '<STR_LIT>' , <EOL> data = location ) <EOL> operations . append ( operation ) <EOL> return createAction ( _action , operations , id_scope ) <EOL> def convertIds ( vistrail ) : <EOL> actions = vistrail . db_get_actions ( ) <EOL> actions . sort ( key = lambda x : x . db_id ) <EOL> objectDict = { } <EOL> graph = Graph ( ) <EOL> for action in actions : <EOL> graph . add_vertex ( action . db_id ) <EOL> graph . add_edge ( action . db_prevId , action . db_id ) <EOL> def convertAction ( actionId ) : <EOL> if actionId == <NUM_LIT:0> : <EOL> return <EOL> allOps = [ ] <EOL> action = vistrail . db_get_action ( actionId ) <EOL> for operation in action . db_get_operations ( ) : <EOL> allOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> operation . vtType , <EOL> operation ) ) <EOL> action . db_operations = allOps <EOL> def removeObjects ( actionId ) : <EOL> if actionId == <NUM_LIT:0> : <EOL> return <EOL> action = vistrail . db_get_action ( actionId ) <EOL> reverseOps = action . db_get_operations ( ) <EOL> reverseOps . reverse ( ) <EOL> for operation in reverseOps : <EOL> parentList = getTypeIdList ( operation ) <EOL> removeObject ( operation . db_what , <EOL> operation . db_oldId , <EOL> objectDict , <EOL> parentList [ : - <NUM_LIT:1> ] ) <EOL> reverseOps . reverse ( ) <EOL> graph . dfs ( enter_vertex = convertAction , <EOL> leave_vertex = removeObjects ) <EOL> def getTypeIdList ( operation ) : <EOL> if operation . db_what in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> return [ ( operation . db_what , operation . db_oldId ) ] <EOL> elif operation . db_what in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:location>' , '<STR_LIT>' ) : <EOL> return [ ( '<STR_LIT>' , operation . db_oldParentId ) , <EOL> ( operation . db_what , operation . db_oldId ) ] <EOL> elif operation . db_what in ( '<STR_LIT:port>' ) : <EOL> return [ ( '<STR_LIT>' , operation . db_oldParentId ) , <EOL> ( operation . db_what , operation . db_oldId ) ] <EOL> elif operation . db_what in ( '<STR_LIT>' ) : <EOL> return [ ( '<STR_LIT>' , operation . db_moduleId ) , <EOL> ( '<STR_LIT>' , operation . db_oldParentId ) , <EOL> ( '<STR_LIT>' , operation . db_oldId ) ] <EOL> else : <EOL> print "<STR_LIT>" % operation . db_what <EOL> return [ ( operation . db_what , operation . db_oldId ) ] <EOL> def getOldId ( object ) : <EOL> if object . vtType == '<STR_LIT>' : <EOL> return object . db_key <EOL> elif object . vtType == '<STR_LIT:port>' : <EOL> return object . db_type <EOL> elif object . vtType == '<STR_LIT>' : <EOL> return ( object . db_name , object . db_type ) <EOL> else : <EOL> return object . getPrimaryKey ( ) <EOL> def getChildren ( object ) : <EOL> childList = [ ] <EOL> if object . vtType == '<STR_LIT>' : <EOL> childList = object . db_get_functions ( ) + object . db_get_portSpecs ( ) + object . db_get_annotations ( ) <EOL> childList . append ( object . db_location ) <EOL> object . db_functions = [ ] <EOL> object . db_portSpecs = { } <EOL> object . db_annotations = { } <EOL> object . db_location = None <EOL> elif object . vtType == '<STR_LIT>' : <EOL> childList = object . db_get_ports ( ) <EOL> object . db_ports = [ ] <EOL> elif object . vtType == '<STR_LIT>' : <EOL> childList = object . db_get_parameters ( ) <EOL> object . db_parameters = [ ] <EOL> return childList <EOL> def captureObject ( object , objectDict , newId , parentList ) : <EOL> currentDict = objectDict <EOL> for key in parentList : <EOL> ( objType , objId ) = key <EOL> ( objList , curIdx ) = currentDict [ ( objType , objId ) ] <EOL> currentDict = objList [ curIdx ] [ <NUM_LIT:1> ] <EOL> oldId = getOldId ( object ) <EOL> if not currentDict . has_key ( ( object . vtType , oldId ) ) : <EOL> currentDict [ ( object . vtType , oldId ) ] = ( [ ] , - <NUM_LIT:1> ) <EOL> ( curList , curIdx ) = currentDict [ ( object . vtType , oldId ) ] <EOL> curList . append ( ( newId , { } , object , curIdx ) ) <EOL> currentDict [ ( object . vtType , oldId ) ] = ( curList , len ( curList ) - <NUM_LIT:1> ) <EOL> def captureDelete ( objType , objId , objectDict , parentList ) : <EOL> currentDict = objectDict <EOL> for ( aType , aId ) in parentList : <EOL> ( objList , curIdx ) = currentDict [ ( aType , aId ) ] <EOL> currentDict = objList [ curIdx ] [ <NUM_LIT:1> ] <EOL> if not currentDict . has_key ( ( objType , objId ) ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> ( curList , curIdx ) = currentDict [ ( objType , objId ) ] <EOL> curList . append ( ( - <NUM_LIT:1> , { } , None , curIdx ) ) <EOL> currentDict [ ( objType , objId ) ] = ( curList , len ( curList ) - <NUM_LIT:1> ) <EOL> def removeObject ( oldObjType , oldId , objectDict , parentList ) : <EOL> try : <EOL> currentDict = objectDict <EOL> for key in parentList : <EOL> ( objType , objId ) = key <EOL> ( objList , objIdx ) = currentDict [ ( objType , objId ) ] <EOL> currentDict = objList [ objIdx ] [ <NUM_LIT:1> ] <EOL> ( curList , curIdx ) = currentDict [ ( oldObjType , oldId ) ] <EOL> newIdx = curList [ curIdx ] [ <NUM_LIT:3> ] <EOL> currentDict [ ( oldObjType , oldId ) ] = ( curList , newIdx ) <EOL> except KeyError : <EOL> print "<STR_LIT>" % ( oldObjType , oldId ) <EOL> print parentList <EOL> print objList <EOL> print "<STR_LIT>" % objIdx <EOL> def findNewId ( typeIdList , objectDict ) : <EOL> try : <EOL> currentDict = objectDict <EOL> for key in typeIdList : <EOL> ( objList , curIdx ) = currentDict [ key ] <EOL> if curIdx == - <NUM_LIT:1> : <EOL> return ( None , None ) <EOL> ( currentId , currentDict , currentObj , _ ) = objList [ curIdx ] <EOL> if currentId == - <NUM_LIT:1> : <EOL> return ( None , None ) <EOL> return ( currentId , currentObj ) <EOL> except KeyError : <EOL> pass <EOL> return ( None , None ) <EOL> def getChildList ( typeIdList , objectDict ) : <EOL> try : <EOL> currentDict = objectDict <EOL> for ( objType , objOldId ) in typeIdList : <EOL> ( objList , curIdx ) = currentDict [ ( objType , objOldId ) ] <EOL> if curIdx == - <NUM_LIT:1> : <EOL> return { } <EOL> currentDict = objList [ curIdx ] [ <NUM_LIT:1> ] <EOL> return currentDict <EOL> except KeyError : <EOL> pass <EOL> return { } <EOL> def createOperation ( actionType , objId , objType , parentId , parentType , <EOL> object = None ) : <EOL> if actionType == '<STR_LIT>' : <EOL> operation = DBAdd ( what = objType , <EOL> objectId = objId , <EOL> parentObjId = parentId , <EOL> parentObjType = parentType , <EOL> data = object ) <EOL> elif actionType == '<STR_LIT>' : <EOL> operation = DBChange ( what = objType , <EOL> oldObjId = objId , <EOL> parentObjId = parentId , <EOL> parentObjType = parentType , <EOL> data = object ) <EOL> elif actionType == '<STR_LIT>' : <EOL> operation = DBDelete ( what = objType , <EOL> objectId = objId , <EOL> parentObjId = parentId , <EOL> parentObjType = parentType ) <EOL> else : <EOL> msg = "<STR_LIT>" % actionType <EOL> raise Exception ( msg ) <EOL> return operation <EOL> def convertChangeToAdd ( operation ) : <EOL> return DBAdd ( what = operation . db_what , <EOL> objectId = operation . db_newObjId , <EOL> parentObjId = operation . db_parentObjId , <EOL> parentObjType = operation . db_parentObjType , <EOL> data = operation . db_data ) <EOL> def convertOperation ( vistrail , objectDict , actionType , operation ) : <EOL> newOps = [ ] <EOL> if actionType == '<STR_LIT>' : <EOL> object = operation . db_data <EOL> if object . vtType == '<STR_LIT>' and object . db_pos == - <NUM_LIT:1> : <EOL> return newOps <EOL> operation . db_oldId = operation . db_objectId <EOL> if operation . db_what == '<STR_LIT>' : <EOL> operation . db_oldId = object . db_key <EOL> elif operation . db_what == '<STR_LIT:port>' : <EOL> operation . db_oldId = object . db_type <EOL> operation . db_oldParentId = operation . db_parentObjId <EOL> parentList = getTypeIdList ( operation ) <EOL> newId = vistrail . idScope . getNewId ( object . vtType ) <EOL> captureObject ( object , objectDict , newId , parentList [ : - <NUM_LIT:1> ] ) <EOL> operation . db_objectId = newId <EOL> oldId = object . getPrimaryKey ( ) <EOL> if object . vtType == '<STR_LIT>' : <EOL> oldId = object . db_key <EOL> elif object . vtType == '<STR_LIT:port>' : <EOL> oldId = object . db_type <EOL> if hasattr ( object , '<STR_LIT>' ) : <EOL> object . db_id = newId <EOL> operation . db_id = vistrail . idScope . getNewId ( '<STR_LIT>' ) <EOL> if operation . db_parentObjId is not None : <EOL> oldParentObjId = operation . db_parentObjId <EOL> operation . db_parentObjId = findNewId ( parentList [ : - <NUM_LIT:1> ] , objectDict ) [ <NUM_LIT:0> ] <EOL> if object . vtType == '<STR_LIT:port>' : <EOL> object . db_moduleId = findNewId ( [ ( '<STR_LIT>' , object . db_moduleId ) ] , objectDict ) [ <NUM_LIT:0> ] <EOL> newOps . append ( operation ) <EOL> children = getChildren ( object ) <EOL> for child in children : <EOL> if child . vtType == '<STR_LIT:location>' : <EOL> child . db_id = oldId <EOL> newOp = createOperation ( '<STR_LIT>' , <EOL> child . getPrimaryKey ( ) , <EOL> child . vtType , <EOL> oldId , <EOL> object . vtType , <EOL> child ) <EOL> if child . vtType == '<STR_LIT>' : <EOL> newOp . db_moduleId = oldParentObjId <EOL> newOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> '<STR_LIT>' , <EOL> newOp ) ) <EOL> newOp . db_parentObjId = newId <EOL> elif actionType == '<STR_LIT>' : <EOL> object = operation . db_data <EOL> if object . vtType == '<STR_LIT>' and object . db_pos == - <NUM_LIT:1> : <EOL> return newOps <EOL> operation . db_oldId = operation . db_oldObjId <EOL> if operation . db_what == '<STR_LIT>' : <EOL> operation . db_oldId = object . db_key <EOL> elif operation . db_what == '<STR_LIT:port>' : <EOL> operation . db_oldId = object . db_type <EOL> operation . db_oldParentId = operation . db_parentObjId <EOL> parentList = getTypeIdList ( operation ) <EOL> ( foundId , foundObj ) = findNewId ( parentList , objectDict ) <EOL> if foundId is not None : <EOL> if foundObj . vtType == '<STR_LIT>' and foundObj . db_pos == object . db_pos and foundObj . db_name == object . db_name : <EOL> for parameter in object . db_parameters : <EOL> newOp = createOperation ( '<STR_LIT>' , <EOL> parameter . getPrimaryKey ( ) , <EOL> parameter . vtType , <EOL> object . getPrimaryKey ( ) , <EOL> object . vtType , <EOL> parameter ) <EOL> newOp . db_moduleId = operation . db_parentObjId <EOL> newOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> '<STR_LIT>' , <EOL> newOp ) ) <EOL> newOp . db_parentObjId = foundId <EOL> return newOps <EOL> else : <EOL> if foundObj . vtType == '<STR_LIT:location>' and object . relative == True : <EOL> object . db_x += foundObj . db_x <EOL> object . db_y += foundObj . db_y <EOL> object . relative = False <EOL> newId = vistrail . idScope . getNewId ( object . vtType ) <EOL> operation . db_oldObjId = foundId <EOL> operation . db_newObjId = newId <EOL> else : <EOL> newId = vistrail . idScope . getNewId ( object . vtType ) <EOL> operation . db_oldObjId = - <NUM_LIT:1> <EOL> operation . db_newObjId = newId <EOL> anOldId = operation . db_oldId <EOL> anOldParentId = operation . db_parentObjId <EOL> if hasattr ( operation , '<STR_LIT>' ) : <EOL> aModuleId = operation . db_moduleId <EOL> else : <EOL> aModuleId = None <EOL> operation = convertChangeToAdd ( operation ) <EOL> operation . db_oldId = anOldId <EOL> operation . db_oldParentId = operation . db_parentObjId <EOL> operation . db_moduleId = aModuleId <EOL> childDict = getChildList ( parentList , objectDict ) <EOL> for k , v in childDict . items ( ) : <EOL> ( objType , objId ) = k <EOL> newOp = createOperation ( '<STR_LIT>' , <EOL> objId , <EOL> objType , <EOL> object . getPrimaryKey ( ) , <EOL> object . vtType ) <EOL> if objType == '<STR_LIT>' : <EOL> newOp . db_moduleId = operation . db_parentObjId <EOL> newOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> '<STR_LIT>' , <EOL> newOp ) ) <EOL> newOp . db_parentObjId = newId <EOL> captureObject ( object , objectDict , newId , parentList [ : - <NUM_LIT:1> ] ) <EOL> oldId = object . getPrimaryKey ( ) <EOL> if object . vtType == '<STR_LIT>' : <EOL> oldId = object . db_key <EOL> elif object . vtType == '<STR_LIT:port>' : <EOL> oldId = object . db_type <EOL> if hasattr ( object , '<STR_LIT>' ) : <EOL> object . db_id = newId <EOL> operation . db_id = vistrail . idScope . getNewId ( '<STR_LIT>' ) <EOL> if operation . db_parentObjId is not None : <EOL> oldParentObjId = operation . db_parentObjId <EOL> operation . db_parentObjId = findNewId ( parentList [ : - <NUM_LIT:1> ] , objectDict ) [ <NUM_LIT:0> ] <EOL> if object . vtType == '<STR_LIT:port>' : <EOL> object . db_moduleId = findNewId ( [ ( '<STR_LIT>' , object . db_moduleId ) ] , objectDict ) [ <NUM_LIT:0> ] <EOL> newOps . append ( operation ) <EOL> children = getChildren ( operation . db_data ) <EOL> for child in children : <EOL> newOp = createOperation ( '<STR_LIT>' , <EOL> child . getPrimaryKey ( ) , <EOL> child . vtType , <EOL> oldId , <EOL> object . vtType , <EOL> child ) <EOL> if child . vtType == '<STR_LIT>' : <EOL> newOp . db_moduleId = oldParentObjId <EOL> newOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> '<STR_LIT>' , <EOL> newOp ) ) <EOL> newOp . db_parentObjId = newId <EOL> elif actionType == '<STR_LIT>' : <EOL> operation . db_oldId = operation . db_objectId <EOL> operation . db_oldParentId = operation . db_parentObjId <EOL> parentList = getTypeIdList ( operation ) <EOL> ( newId , _ ) = findNewId ( parentList , objectDict ) <EOL> if newId is None : <EOL> msg = "<STR_LIT>" % parentList <EOL> print msg <EOL> return [ ] <EOL> childDict = getChildList ( parentList , objectDict ) <EOL> for k , v in childDict . items ( ) : <EOL> ( objType , objId ) = k <EOL> newOp = createOperation ( '<STR_LIT>' , <EOL> objId , <EOL> objType , <EOL> operation . db_objectId , <EOL> operation . db_what ) <EOL> if objType == '<STR_LIT>' : <EOL> newOp . db_moduleId = operation . db_parentObjId <EOL> newOps . extend ( convertOperation ( vistrail , <EOL> objectDict , <EOL> '<STR_LIT>' , <EOL> newOp ) ) <EOL> newOp . db_parentObjId = newId <EOL> captureDelete ( operation . db_what , operation . db_objectId , objectDict , <EOL> parentList [ : - <NUM_LIT:1> ] ) <EOL> operation . db_objectId = newId <EOL> operation . db_id = vistrail . idScope . getNewId ( '<STR_LIT>' ) <EOL> if operation . db_parentObjId is not None : <EOL> operation . db_parentObjId = findNewId ( parentList [ : - <NUM_LIT:1> ] , objectDict ) [ <NUM_LIT:0> ] <EOL> newOps . append ( operation ) <EOL> return newOps </s>
