def generate_vtl(locator, version, pipeline, execute=False, forceDB=False, showSpreadsheetOnly=False, embedWorkflow=False): """generate_vtl(locator:DBLocator or XMLLocator, version: str, pipeline:Pipeline, execute:boolean, forceDB:boolean, showspreadsheetOnly:boolean, embedWorkflow: boolean) -> str It generates the contents of a .vtl file with the information given. """ node = ElementTree.Element('vtlink') if isinstance(locator, DBLocator): node.set('host', str(locator.host)) node.set('port', str(locator.port)) node.set('database', str(locator.db)) node.set('vtid', str(locator.obj_id)) elif locator is not None: node.set('filename', str(locator.name)) node.set('version', str(version)) node.set('execute', str(execute)) node.set('forceDB', str(forceDB)) node.set('showSpreadsheetOnly', str(showSpreadsheetOnly)) if embedWorkflow == True: vistrail = Vistrail() action_list = [] for module in pipeline.module_list: action_list.append(('add', module)) for connection in pipeline.connection_list: action_list.append(('add', connection)) action = core.db.action.create_action(action_list) vistrail.add_action(action, 0L) vistrail.addTag("Imported workflow", action.id) if not forceDB: node.set('version', str(action.id)) if not vistrail.db_version: vistrail.db_version = currentVersion pipxmlstr = io.serialize(vistrail) vtcontent = base64.b64encode(pipxmlstr) node.set('vtcontent', vtcontent) return ElementTree.tostring(node)
def generate_vtl(locator,version,pipeline,execute=False,forceDB=False, showSpreadsheetOnly=False,embedWorkflow=False): """generate_vtl(locator:DBLocator or XMLLocator, version: str, pipeline:Pipeline, execute:boolean, forceDB:boolean, showspreadsheetOnly:boolean, embedWorkflow: boolean) -> str It generates the contents of a .vtl file with the information given. """ node = ElementTree.Element('vtlink') if isinstance(locator, DBLocator): node.set('host', str(locator.host)) node.set('port', str(locator.port)) node.set('database', str(locator.db)) node.set('vtid', str(locator.obj_id)) elif locator is not None: node.set('filename', str(locator.name)) node.set('version', str(version)) node.set('execute', str(execute)) node.set('forceDB', str(forceDB)) node.set('showSpreadsheetOnly', str(showSpreadsheetOnly)) if embedWorkflow == True: vistrail = Vistrail() action_list = [] for module in pipeline.module_list: action_list.append(('add', module)) for connection in pipeline.connection_list: action_list.append(('add', connection)) action = core.db.action.create_action(action_list) vistrail.add_action(action, 0L) vistrail.addTag("Imported workflow", action.id) if not forceDB: node.set('version', str(action.id)) if not vistrail.db_version: vistrail.db_version = currentVersion pipxmlstr = io.serialize(vistrail) vtcontent = base64.b64encode(pipxmlstr) node.set('vtcontent',vtcontent) return ElementTree.tostring(node)