Skip to content

Commit

Permalink
fix: enable pagination
Browse files Browse the repository at this point in the history
the default queries has been modified
  • Loading branch information
mosoriob committed Apr 24, 2020
1 parent a44f735 commit 210cd7a
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 371 deletions.
18 changes: 10 additions & 8 deletions src/main/resources/queries/get_all.rq
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ CONSTRUCT {
?prop a ?type
}
WHERE {
{
SELECT DISTINCT ?item where {
?item a ?_type_iri .
}
}
?item ?predicate ?prop
OPTIONAL {
?prop a ?type
{
SELECT DISTINCT ?item where {
?item a ?_type_iri .
}
LIMIT 100
OFFSET 0
}
?item ?predicate ?prop
OPTIONAL {
?prop a ?type
}
}
16 changes: 10 additions & 6 deletions src/main/resources/queries/get_all_search.rq
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#+ summary: Given a rdf type, returns all the resources related to a list of property {rdfs:label}
#+ summary: Given a rdf type, returns all the resources related to the type

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
?item ?predicate ?prop .
?prop a ?type
?item ?predicate ?prop .
?prop a ?type
}
WHERE {
{
SELECT DISTINCT ?item where {
?item a ?_type_iri .
?item ?prop ?desc .
VALUES ?prop { rdfs:label }
VALUES ?property { rdfs:label }
filter regex(str(?desc),?_text,"i")
}
LIMIT 100
OFFSET 0
}
?item ?predicate ?prop
?item ?property ?desc.
OPTIONAL {
?prop a ?type
}
}
}
8 changes: 5 additions & 3 deletions src/main/resources/queries/get_all_search_user.rq
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+ summary: Given a rdf type, returns all the resources related to a list of property {rdfs:label}
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
?item ?predicate ?prop .
?prop a ?type
Expand All @@ -10,11 +10,13 @@ WHERE {
SELECT DISTINCT ?item where {
?item a ?_type_iri .
?item ?prop ?desc .
VALUES ?prop { rdfs:label }
VALUES ?property { rdfs:label }
filter regex(str(?desc),?_text,"i")
}
LIMIT 100
OFFSET 0
}
?item ?predicate ?prop
?item ?property ?desc.
OPTIONAL {
?prop a ?type
}
Expand Down
28 changes: 15 additions & 13 deletions src/main/resources/queries/get_all_user.rq
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#+ summary: Given a rdf type, returns all the resources related to the type
CONSTRUCT {
?item ?predicate ?prop .
?prop a ?type
?item ?predicate ?prop .
?prop a ?type
}
WHERE {
GRAPH ?_g_iri {
{
SELECT DISTINCT ?item where {
?item a ?_type_iri .
}
}
?item ?predicate ?prop
OPTIONAL {
?prop a ?type
}
}
GRAPH ?_g_iri {
{
SELECT DISTINCT ?item where {
?item a ?_type_iri .
}
LIMIT 100
OFFSET 0
}
?item ?predicate ?prop
OPTIONAL {
?prop a ?type
}
}
}
Binary file modified src/main/resources/servers.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from obasparql import QueryManager
from {{packageName}}.settings import CONTEXT_DIRECTORY, QUERY_DIRECTORY, QUERIES_TYPES, logging_file
import logging.config
from {{packageName}}.settings import *
import logging

try:
Expand All @@ -13,7 +12,12 @@ logger = logging.getLogger(__name__)

query_manager = QueryManager(queries_dir=QUERY_DIRECTORY,
context_dir=CONTEXT_DIRECTORY,
queries_types=QUERIES_TYPES)
queries_types=QUERIES_TYPES,
endpoint=ENDPOINT,
endpoint_username=ENDPOINT_USERNAME,
endpoint_password=ENDPOINT_PASSWORD,
graph_base=ENDPOINT_GRAPH_BASE,
prefix=ENDPOINT_RESOURCE_PREFIX)



Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import connexion
import six
from openapi_server.utils.request import get_resource, get_all_resource, put_resource, post_resource, delete_resource
from openapi_server import query_manager
from openapi_server.utils.vars import {{#lambda.uppercase}}{{baseName}}_type_name{{/lambda.uppercase}}, {{#lambda.uppercase}}{{baseName}}_type_uri{{/lambda.uppercase}}

{{#imports}}{{import}} # noqa: E501
Expand Down Expand Up @@ -110,7 +110,7 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
{{/isMapContainer}}
{{/allParams}}

return {{#lambda.lowercase}}{{httpMethod}}_resource{{/lambda.lowercase}}({{#pathParams}}{{paramName}}={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/pathParams}}{{#queryParams}}
return query_manager.{{#lambda.lowercase}}{{httpMethod}}_resource{{/lambda.lowercase}}({{#pathParams}}{{paramName}}={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/pathParams}}{{#queryParams}}
{{paramName}}={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/queryParams}}{{#bodyParams}}
body={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/bodyParams}}
rdf_type_uri={{#lambda.uppercase}}{{baseName}}_type_uri{{/lambda.uppercase}},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pythonql3==0.9.61
connexion >= 2.6.0
obasparql >= 2.0.2
obasparql >= 3.0.1
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

# Default endpoint, if none specified elsewhere
ENDPOINT = config.get('defaults', 'endpoint')
ENDPOINT_USER = config.get('defaults', 'user')
ENDPOINT_USERNAME = config.get('defaults', 'user')
ENDPOINT_PASSWORD = config.get('defaults', 'password')
PREFIX = config.get('defaults', 'prefix')
GRAPH_BASE = config.get('defaults', 'graph_base')
ENDPOINT_RESOURCE_PREFIX = config.get('defaults', 'prefix')
ENDPOINT_GRAPH_BASE = config.get('defaults', 'graph_base')
FIREBASE_KEY = config.get('defaults', 'firebase_key')

QUERY_DIRECTORY = path/config.get('defaults', 'queries_dir')
Expand Down
Loading

0 comments on commit 210cd7a

Please sign in to comment.