• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QueryLauncher.QueryLauncher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher的典型用法代码示例。如果您正苦于以下问题:Python QueryLauncher类的具体用法?Python QueryLauncher怎么用?Python QueryLauncher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了QueryLauncher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: positionable_attr

    def positionable_attr(self):
        """
        Return the positionable attributes in common between two positionable entity
        """
        #FIXEME: Rewrite this ugly method

        body = self.request.json_body
        data = {}

        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        ql = QueryLauncher(self.settings, self.request.session)

        # Check if the two entity are positionable
        positionable1 = ql.process_query(sqb.get_if_positionable(body['node']).query)
        positionable2 = ql.process_query(sqb.get_if_positionable(body['node']).query)

        if positionable1 == 0 or positionable2 == 0:
            data['error'] = 'not positionable nodes'
            return data

        results = ql.process_query(sqb.get_common_positionable_attributes(body['node'], body['second_node']).query)
        self.log.debug(results)

        data['results'] = {}

        list_pos_attr = []

        for elem in results:
            if elem['pos_attr'] not in list_pos_attr:
                list_pos_attr.append(elem['pos_attr'].replace("http://www.semanticweb.org/irisa/ontologies/2016/1/igepp-ontology#", ""))

        for elem in list_pos_attr:
            data['results'][elem] = False not in [bool(int(p['status'])) for p in results if p['pos_attr'] == "http://www.semanticweb.org/irisa/ontologies/2016/1/igepp-ontology#"+elem]

        return data
开发者ID:cbettemb,项目名称:askomics,代码行数:35,代码来源:ask_view.py


示例2: __init__

    def __init__(self, settings, session,lendpoints):
        QueryLauncher.__init__(self, settings, session)
        self.log = logging.getLogger(__name__)


        self.log.debug(" =================== Federation Request ====================")

        #comments added in sparql request to get all url endpoint.
        self.commentsForFed=""
        for endp in lendpoints:
            if 'askomics' not in endp:
                raise ValueError("endpoint var have to defined an 'askomics' key with a boolean value endp="+str(endp))
            if endp['askomics']:
                self.commentsForFed+="#endpoint,askomics,"+endp['name']+','+endp['endpoint']+',false\n'
            else:
                self.commentsForFed+="#endpoint,external,"+endp['name']+','+endp['endpoint']+',false\n'
        #add local TPS
        #self.commentsForFed+="#endpoint,local,"+self.get_param("askomics.endpoint")+',false\n'

        if not self.is_defined("askomics.fdendpoint") :
            raise ValueError("can not find askomics.fdendpoint property in the config file !")

        self.name = 'FederationEngine'
        self.endpoint = self.get_param("askomics.fdendpoint")
        self.username = None
        self.password = None
        self.urlupdate = None
        self.auth = 'Basic'
        self.allowUpdate = False
开发者ID:abretaud,项目名称:askomics,代码行数:29,代码来源:FederationQueryLauncher.py


示例3: delete_apikey

    def delete_apikey(self, key):
        """delete an apikey"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.execute_query(sqa.delete_apikey(key).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:7,代码来源:Security.py


示例4: insert_metadatas

    def insert_metadatas(self,accessL):
        """
        Insert the metadatas into the parent graph
        """

        self.log.debug('--- insert_metadatas ---')

        sqb = SparqlQueryBuilder(self.settings, self.session)
        query_laucher = QueryLauncher(self.settings, self.session)

        valAcces = 'public' if accessL else 'private'

        ttl = '<' + self.graph + '> prov:generatedAtTime "' + self.timestamp + '"^^xsd:dateTime .\n'
        ttl += '<' + self.graph + '> dc:creator "' + self.session['username'] + '" .\n'
        ttl += '<' + self.graph + '> :accessLevel "' +  valAcces + '" .\n'
        ttl += '<' + self.graph + '> foaf:Group "' +  self.session['group']  + '" .\n'
        ttl += '<' + self.graph + '> prov:wasDerivedFrom "' + self.name + '" .\n'
        ttl += '<' + self.graph + '> dc:hasVersion "' + get_distribution('Askomics').version + '" .\n'
        ttl += '<' + self.graph + '> prov:describesService "' + os.uname()[1] + '" .\n'

        if self.is_defined("askomics.endpoint"):
            ttl += '<' + self.graph + '> prov:atLocation "' + self.get_param("askomics.endpoint") + '" .\n'
        else:
            raise ValueError("askomics.endpoint does not exit.")

        sparql_header = sqb.header_sparql_config('')

        query_laucher.insert_data(ttl, self.graph, sparql_header)
开发者ID:askomics,项目名称:askomics,代码行数:28,代码来源:SourceFile.py


示例5: delete_askograph

    def delete_askograph(self):
        """Delete the askomics graph"""

        sqb = SparqlQueryGraph(self.settings, self.request.session)
        query_laucher = QueryLauncher(self.settings, self.request.session)

        query_laucher.process_query(sqb.get_drop_named_graph('urn:sparql:test_askomics'))
开发者ID:askomics,项目名称:askomics,代码行数:7,代码来源:interface_tps_db.py


示例6: compare_file_to_database

    def compare_file_to_database(self, headers):
        """ Ask the database to compare the headers of a file to convert to the corresponding class in the database """
        curr_entity = headers[0]
        sqb = SparqlQueryBuilder(self.settings, self.session)
        ql = QueryLauncher(self.settings, self.session)
        sparql_template = self.get_template_sparql(self.ASKOMICS_get_class_info_from_abstraction_queryFile)
        query = sqb.load_from_file(sparql_template, {"#nodeClass#": curr_entity}).query

        results = ql.process_query(query)
        if results == []:
            return [], headers, []
        bdd_relations, new_headers, missing_headers, present_headers = [], [], [], []
        for result in results:
            bdd_relation = result["relation"].replace(self.get_param("askomics.prefix"), "").replace("has_", "")
            bdd_relations.append(bdd_relation)
            if bdd_relation not in headers:
                self.log.warning('Relation "%s" not found in tables columns: %s.', bdd_relation, repr(headers))
                missing_headers.append(bdd_relation)
        for header in headers:
            if header != curr_entity:
                if header not in bdd_relations:
                    self.log.info('Adding column "%s".', header)
                    new_headers.append(header)
                elif header not in missing_headers:
                    present_headers.append(header)
        return missing_headers, new_headers, present_headers
开发者ID:odameron,项目名称:askomics,代码行数:26,代码来源:SourceFileConvertor.py


示例7: load_data_from_file

    def load_data_from_file(self, fp, urlbase):
        """
        Load a locally created ttl file in the triplestore using http (with load_data(url)) or with the filename for Fuseki (with fuseki_load_data(fp.name)).

        :param fp: a file handle for the file to load
        :param urlbase:the base URL of current askomics instance. It is used to let triple stores access some askomics temporary ttl files using http.
        :return: a dictionnary with information on the success or failure of the operation
        """
        if not fp.closed:
            fp.flush() # This is required as otherwise, data might not be really written to the file before being sent to triplestore

        ql = QueryLauncher(self.settings, self.session)

        if self.is_defined('askomics.load_url'):
            urlbase = self.settings['askomics.load_url']

        url = urlbase+"/ttl/"+ self.session['username'] + '/' + os.path.basename(fp.name)

        data = {}
        data["status"] = "ok"
        try:
            if self.is_defined("askomics.file_upload_url"):
                queryResults = ql.upload_data(fp.name, self.graph)
            else:
                queryResults = ql.load_data(url, self.graph)
        except Exception as e:
            self.log.error(self._format_exception(e))
            raise e

        finally:
            if self.settings['askomics.debug_ttl'] != 'true':
                os.remove(fp.name)

        return data
开发者ID:askomics,项目名称:askomics,代码行数:34,代码来源:SourceFile.py


示例8: empty

 def empty(self):
     #empty database
     sqb = SparqlQueryBuilder(self.settings, self.request.session)
     ql = QueryLauncher(self.settings, self.request.session)
     namedGraphs = self.list_named_graphs()
     for graph in namedGraphs:
         ql.execute_query(sqb.get_delete_query_string(graph).query)
开发者ID:cbettemb,项目名称:askomics,代码行数:7,代码来源:interface_tps.py


示例9: get_start_points

    def get_start_points(self):
        """
        Get the possible starting points for your graph.

        :return: List of starting points
        :rtype: Node list
        """
        self.log.debug(" =========== TripleStoreExplorer:get_start_points ===========")
        nodes = []

        sqg = SparqlQueryGraph(self.settings, self.session)
        ql = QueryLauncher(self.settings, self.session)
        results = ql.process_query(sqg.get_start_point().query)

        for result in results:
            g  = result["g"]
            uri = result["nodeUri"]
            label = result["nodeLabel"]

            if 'private' in result['accesLevel']:
                public = False
                private = True
            else:
                public = True
                private = False

            nodes.append({'g': g, 'uri': uri, 'label': label, 'public': public, 'private': private})

        return nodes
开发者ID:ofilangi,项目名称:askomics,代码行数:29,代码来源:TripleStoreExplorer.py


示例10: get_value

    def get_value(self):
        """ Build a request from a json whith the following contents :variates,constraintesRelations,constraintesFilters"""
        self.log.debug("== Attribute Value ==")
        data = {}

        tse = TripleStoreExplorer(self.settings, self.request.session)

        body = self.request.json_body
        try:
            results,query = tse.build_sparql_query_from_json(body["variates"],body["constraintesRelations"],body["limit"],True)

            # Remove prefixes in the results table
            data['values'] = results

            if not body['export']:
                return data


            # Provide results file
            ql = QueryLauncher(self.settings, self.request.session)
            rb = ResultsBuilder(self.settings, self.request.session)
            data['file'] = ql.format_results_csv(rb.build_csv_table(results))
        except Exception as e:
            #exc_type, exc_value, exc_traceback = sys.exc_info()
            #traceback.print_exc(limit=8)
            traceback.print_exc(file=sys.stdout)
            data['values'] = ""
            data['file'] = ""
            data['error'] = traceback.format_exc(limit=8)+"\n\n\n"+str(e)
            self.log.error(str(e))

        return data
开发者ID:cbettemb,项目名称:askomics,代码行数:32,代码来源:ask_view.py


示例11: test_triple_presence

    def test_triple_presence(self, graph, triple):
        """Test the presence of a triple in the triplestore

        get if a triple is present in a specific graph of the triplestore
        :param graph: the named graph
        :type graph: string
        :param triple: the triple to test
        :type triple: string
        :returns: Result of the test
        :rtype: bool
        """

        sqb = SparqlQueryGraph(self.settings, self.request.session)
        query_laucher = QueryLauncher(self.settings, self.request.session)


        query = sqb.prepare_query("""
            SELECT count(*) AS ?count
            WHERE {
                GRAPH <""" + graph + """> {
                    """ + triple + """ .
                }
            }
            """)

        res = query_laucher.process_query(query)

        print(bool(int(res[0]['count'])))

        return bool(int(res[0]['count']))
开发者ID:askomics,项目名称:askomics,代码行数:30,代码来源:interface_tps_db.py


示例12: update_passwd

    def update_passwd(self):
        """
        Change the password of a user, and his randomsalt
        """
        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.process_query(sqa.update_passwd(self.username, self.sha256_pw, self.randomsalt).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:8,代码来源:Security.py


示例13: delete_galaxy

    def delete_galaxy(self):
        """Delete galaxy triple for the user"""


        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.execute_query(sqa.delete_galaxy(self.username).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:8,代码来源:Security.py


示例14: update_email

    def update_email(self):
        """
        change the mail of a user
        """
        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.process_query(sqa.update_mail(self.username, self.email).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:8,代码来源:Security.py


示例15: check_galaxy

    def check_galaxy(self):
        """Check if user have galaxy triples"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(sqa.check_galaxy(self.username).query)

        return ParamManager.Bool(result[0]['status'])
开发者ID:ofilangi,项目名称:askomics,代码行数:9,代码来源:Security.py


示例16: deleteMoState

    def deleteMoState(self,urimo):
        self.log.debug(' ***** Delete module '+urimo+' on TPS ***** ')
        sqb = SparqlQueryBuilder(self.settings, self.session)
        ql = QueryLauncher(self.settings, self.session)

        ql.execute_query(sqb.prepare_query(
        """
        DELETE WHERE { GRAPH <"""+self.graph_modules+"""> { <"""+urimo+"""> ?p ?o } }
        """
        ).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:10,代码来源:ModulesManager.py


示例17: set_username_by_email

    def set_username_by_email(self):
        """Get the username of a user by his email"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(sqa.get_username_by_email(self.email).query)

        # return result[0]['username']
        self.username = result[0]['username']
开发者ID:ofilangi,项目名称:askomics,代码行数:10,代码来源:Security.py


示例18: get_galaxy_infos

    def get_galaxy_infos(self):
        """Get Galaxy url and apikey of a user"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(sqa.get_galaxy_infos(self.username).query)

        if result:
            return result[0]
        return []
开发者ID:ofilangi,项目名称:askomics,代码行数:11,代码来源:Security.py


示例19: add_apikey

    def add_apikey(self, keyname):
        """Add an api key

        :param keyname: the keyname
        :type keyname: string
        """

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.execute_query(sqa.add_apikey(self.username, keyname).query)
开发者ID:ofilangi,项目名称:askomics,代码行数:11,代码来源:Security.py


示例20: empty_database

    def empty_database(self):
        """
        Delete all triples in the triplestore
        """

        self.log.debug("=== DELETE ALL TRIPLES ===")

        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        ql = QueryLauncher(self.settings, self.request.session)

        ql.execute_query(sqb.get_delete_query_string().query)
开发者ID:Piezoid,项目名称:askomics,代码行数:11,代码来源:ask_view.py



注:本文中的askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python SparqlQueryBuilder.SparqlQueryBuilder类代码示例发布时间:2022-05-24
下一篇:
Python ParamManager.ParamManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap