Example #1
0
    def save_vistrail(self, locator_class,
                      vistrailView=None,
                      force_choose_locator=False):
        """

        force_choose_locator=True triggers 'save as' behavior
        """
        global bobo

        if not vistrailView:
            vistrailView = self.currentWidget()
        vistrailView.flush_changes()
        if vistrailView:
            gui_get = locator_class.save_from_gui
            # get a locator to write to
            if force_choose_locator:
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            else:
                locator = (vistrailView.controller.locator or
                           gui_get(self, Vistrail.vtType,
                                   vistrailView.controller.locator))
            if locator == untitled_locator():
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            # if couldn't get one, ignore the request
            if not locator:
                return False
            # update collection
            try:
                vistrailView.controller.write_vistrail(locator)
            except Exception, e:
                debug.critical('An error has occurred', str(e))
                raise
                return False
            try:
                thumb_cache = ThumbnailCache.getInstance()
                vistrailView.controller.vistrail.thumbnails = \
                    vistrailView.controller.find_thumbnails(
                        tags_only=thumb_cache.conf.tagsOnly)
                vistrailView.controller.vistrail.abstractions = \
                    vistrailView.controller.find_abstractions(
                        vistrailView.controller.vistrail, True)

                collection = Collection.getInstance()
                url = locator.to_url()
                # create index if not exist
                entity = collection.fromUrl(url)
                if entity:
                    # find parent vistrail
                    while entity.parent:
                        entity = entity.parent 
                else:
                    entity = collection.updateVistrail(url, vistrailView.controller.vistrail)
                # add to relevant workspace categories
                collection.add_to_workspace(entity)
                collection.commit()
            except Exception, e:
                debug.critical('Failed to index vistrail', str(e))
Example #2
0
    def open_vistrail(self, locator, version=None, is_abstraction=False):
        """open_vistrail(locator: Locator, version = None: int or str,
                         is_abstraction: bool)

        opens a new vistrail from the given locator, selecting the
        given version.

        """
        self.close_first_vistrail_if_necessary()
        if self.single_document_mode and self.currentView():
            self.closeVistrail()
        view = self.ensureVistrail(locator)
        if view:
            if version is not None:
                if type(version) == type(""):
                    try:
                        version = view.vistrail.get_version_number(version)
                    except:
                        version = None
                if version is not None:
                    view.setup_view(version)
            return view
        try:
            (vistrail, abstraction_files, thumbnail_files, _) = \
                                        load_vistrail(locator, is_abstraction)
            result = self.set_vistrail_view(vistrail, locator, 
                                            abstraction_files, thumbnail_files,
                                            version)
            # update collection
            try:
                vistrail.thumbnails = thumbnail_files
                vistrail.abstractions = abstraction_files
                collection = Collection.getInstance()
                url = locator.to_url()
                # create index if not exist
                entity = collection.fromUrl(url)
                if entity:
                    # find parent vistrail
                    while entity.parent:
                        entity = entity.parent 
                else:
                    entity = collection.updateVistrail(url, vistrail)
                # add to relevant workspace categories
                collection.add_to_workspace(entity)
                collection.commit()
            except Exception, e:
                import traceback
                debug.critical('Failed to index vistrail', str(e) + traceback.format_exc())
            return result
Example #3
0
 def do_search(only_current_vistrail=False, 
               only_current_workflow=False):
     entities_to_check = {}
     open_col = Collection.getInstance()
     
     for entity in open_col.get_current_entities():
         if entity.type_id == VistrailEntity.type_id and \
                 entity.is_open:
             controller = entity._window.controller
             if only_current_vistrail and \
                     controller.vistrail != vt_controller.vistrail:
                 continue
             if only_current_workflow:
                 versions_to_check = controller.current_version
             else:
                 graph = controller._current_terse_graph
                 versions_to_check = set(graph.vertices.iterkeys())
             entities_to_check[entity] = versions_to_check
     self.set_search(MultipleSearch(search_str, search_pipeline,
                                    entities_to_check))
     self.search.run()
     return self.search.getResultEntities()