本文整理汇总了Python中askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher类的典型用法代码示例。如果您正苦于以下问题:Python QueryLauncher类的具体用法?Python QueryLauncher怎么用?Python QueryLauncher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QueryLauncher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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)
示例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'))
示例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
示例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
示例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)
示例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
示例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
示例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']))
示例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)
示例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)
示例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)
示例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'])