Example #1
0
def list_recents(request):
    results = utils.query("""  PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select * where { 
	?dn a  dn:Dataset.
    ?dn dct:issued ?date.
    ?dn dct:title ?title.
    ?dn dct:description ?desc.
    ?dn dn:hasSubject ?subj.
    ?subj dn:name ?subj_name.
  } order by DESC(?date)
    limit 6
    """)

    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["dn"]["value"],
            'title': result["title"]["value"],
            'description': result["desc"]["value"],
            'issued': result["date"]["value"],
            'subject': result["subj_name"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #2
0
def get_distributions(request):
    results = utils.query("""PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
   PREFIX dct: <http://purl.org/dc/terms/>
  select ?uri ?format ?download ?size where {{ 
  <{}> dcat:distribution ?uri.  
	?uri dn:hasFormat ?fm.
  ?uri dcat:byteSize ?size.
  ?uri dcat:downloadURL ?download.
  ?fm rdfs:label ?format.
  }}""".format(request.GET.get('uri')))
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri':
            result["uri"]["value"],
            'label':
            result["uri"]["value"][result["uri"]["value"].rindex('/') + 1:] +
            ", format " + result["format"]["value"] + ", size " +
            result["size"]["value"] + " bytes",
            'download':
            result["download"]["value"],
            'size':
            result["size"]["value"],
            'format':
            result["format"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #3
0
def get_dataset(request):
    if request.GET.get("search") == "title":
        filter = 'FILTER regex(str(?title), "' + request.GET.get(
            'value') + '", "i")'
    elif request.GET.get("search") == "keyword":
        filter = 'FILTER regex(str(?keyword), "' + request.GET.get(
            'value') + '" , "i")'

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select distinct ?dn ?title ?description ?issued ?subject where {{ 
	?dn a  dn:Dataset.
    ?dn dct:issued ?issued.
    ?dn dct:title ?title.
    ?dn dct:description ?description.
    ?dn dn:hasSubject ?subj.
    ?subj dn:name ?subject.
    ?dn dcat:keyword ?keyword.
    {}
    }}
    """.format(filter))

    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["dn"]["value"],
            'title': result["title"]["value"],
            'description': result["description"]["value"],
            'issued': result["issued"]["value"],
            'subject': result["subject"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #4
0
def get_stat_subj(request):
    results = utils.query("""select ?name (count (?name) as ?total) where { 
	?ds <http://melodi.irit.fr/ontologies/dn/hasSubject> ?subj .
    ?subj <http://melodi.irit.fr/ontologies/dn/name> ?name.    
    } group by ?name 
    """)
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'name': result["name"]["value"],
            'total': result["total"]["value"]
        })

    return JsonResponse({'rs': json}, safe=False)
Example #5
0
def get_pubs(request):
    results = utils.query("""
       PREFIX bibo: <http://purl.org/ontology/bibo/>
  PREFIX dct: <http://purl.org/dc/terms/>
  select ?uri ?doi ?title where {
	?uri a bibo:Document.
  ?uri dct:title ?title.
  ?uri dct:identifier ?doi.
  }
  """)
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["uri"]["value"],
            'title': result["title"]["value"],
            'DOI': result["doi"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #6
0
def get_stat_key(request):
    results = utils.query("""PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
select ?keyword (count(?keyword) as ?total) where { 
	?dn a <http://melodi.irit.fr/ontologies/dn/Dataset>.    
    ?dn dcat:keyword ?keyword. 
          
} 
group by ?keyword""")

    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'keyword': result["keyword"]["value"],
            'total': result["total"]["value"]
        })

    return JsonResponse({'rs': json}, safe=False)
Example #7
0
def get_pubs_title(request):
    results = utils.query("""
       PREFIX bibo: <http://purl.org/ontology/bibo/>
  PREFIX dct: <http://purl.org/dc/terms/>
  select ?uri ?title ?doi where {{ 
	?uri a bibo:Document.
  ?uri dct:title ?title.
  ?uri dct:identifier ?doi.
  FILTER regex(lcase(str(?title)), "{}", "i") }}""".format(
        request.GET.get('title', '')))
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["uri"]["value"],
            'title': result["title"]["value"],
            'doi': result["doi"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #8
0
def get_loc(request):
    results = utils.query("""  PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
select ?dn ?title ?geom where { 
	?dn a <http://melodi.irit.fr/ontologies/dn/Dataset>.    
    ?dn dct:spatial ?loc.
    ?dn dct:title ?title.
    ?loc <http://www.w3.org/ns/locn#geometry> ?geom.        
} 
    """)
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["dn"]["value"],
            'geom': result["geom"]["value"],
            'title': result["title"]["value"]
        })

    return JsonResponse({'rs': json}, safe=False)
Example #9
0
def get_operations(request):
    results = utils.query("""PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  select ?uri ?label where {
    ?uri a owl:Class. 
    filter(regex(str(?uri), "edamontology.org/operation")).
    ?uri rdfs:label ?label.
    }
    order by strlen(str(?label))  
    """)

    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'id': result["uri"]["value"],
            'name': result["label"]["value"]
        })

    return JsonResponse({'rs': json}, safe=False)
Example #10
0
def get_claim(request):
    results = utils.query("""
  PREFIX mp:  <http://purl.org/mp/>
  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX dct: <http://purl.org/dc/terms/>
  select ?uri ?statement  where {{
	?uri a mp:Claim.
  ?uri mp:statement ?statement.
  ?uri mp:supports ?ref.
  ?ref owl:sameAs {}.
  }}
  """.format(request.GET.get('uri', '')))

    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["uri"]["value"],
            'statement': result["statement"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #11
0
def get_claims(request):
    results = utils.query("""
  PREFIX mp:  <http://purl.org/mp/>
  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX dct: <http://purl.org/dc/terms/>
  select ?uri ?statement ?title where {
	?uri a mp:Claim.
  ?uri mp:statement ?statement.
  ?uri mp:supports ?ref.
  ?ref owl:sameAs ?pub.
  ?pub dct:title ?title.
  }
  """)
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'uri': result["uri"]["value"],
            'statement': result["statement"]["value"],
            'publication': result["title"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #12
0
def get_distribution(request):
    results = utils.query("""PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
   PREFIX dct: <http://purl.org/dc/terms/>
  select ?format ?download ?size ?title where {{ 
	<{}> dn:hasFormat ?fm.
  <{}> dcat:byteSize ?size.
  ?ds dcat:distribution <{}>.
  ?ds dct:title ?title.
  <{}> dcat:downloadURL ?download.
  ?fm rdfs:label ?format.
  }}""".format(request.GET.get('uri'), request.GET.get('uri'),
               request.GET.get('uri'), request.GET.get('uri')))
    json = []
    for result in results["results"]["bindings"]:
        json.append({
            'size': result["size"]["value"],
            'title': result["title"]["value"],
            'format': result["format"]["value"],
            'download': result["download"]["value"]
        })
    return JsonResponse({'rs': json}, safe=False)
Example #13
0
def get_agents(request):
    results = utils.query(""" PREFIX foaf: <http://xmlns.com/foaf/0.1/>
        SELECT ?uri ?name ?email 
        WHERE {{
           ?uri a foaf:Agent.
           ?uri foaf:name ?name.     
        OPTIONAL
          {{
            ?uri foaf:email ?email.
          }}
        }}""")

    json = []
    for result in results["results"]["bindings"]:
        ins = {'uri': result["uri"]["value"], 'name': result["name"]["value"]}

        if result.get("email"):
            ins['email'] = result["email"]["value"]
        else:
            ins['email'] = '-'
        json.append(ins)
    return JsonResponse({'rs': json}, safe=False)
Example #14
0
def get_services(request):
    results = utils.query("""
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select ?uri ?name ?desc ?input ?output ?operation where {{ 
	?uri a dn:Service.
  ?uri dn:description ?desc.
  ?uri dn:name ?name.
  ?uri dn:hasInputFormat ?if.
  ?if rdfs:label ?input.
  ?uri dn:hasOutputFormat ?of.
  ?of rdfs:label ?output.
  ?uri dn:performsOperation ?op.
  ?op rdfs:label ?operation.
  }}""".format())
    json = []
    rec = {}
    for result in results["results"]["bindings"]:
        rec = {}
        for label in results["head"]["vars"]:
            rec[label] = result[label]["value"]
        json.append(rec)

    return JsonResponse({'rs': json}, safe=False)
Example #15
0
def show_dataset(request):
    uri = "<" + request.GET.get("uri") + ">"

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  PREFIX locn: <http://www.w3.org/ns/locn#>
  PREFIX geo: <http://www.opengis.net/ont/geosparql#>
  select distinct ?dn ?title ?description ?issued ?subject ?note ?geom ?identifier ?page where {{ 
	  {} a  dn:Dataset.
    {} dct:issued ?issued.
    {} dct:identifier ?identifier.
    {} dcat:landingPage ?page.
    {} dct:title ?title.
    {} dct:description ?description.
    {} dn:hasSubject ?subj.
  OPTIONAL{{ {} dn:note ?note.}}
  OPTIONAL{{ {}  dct:spatial ?sp.
          ?sp locn:geometry ?geom.}}
    
    ?subj dn:name ?subject.}}""".format(uri, uri, uri, uri, uri, uri, uri, uri,
                                        uri))

    result = results["results"]["bindings"][0]
    json = {
        'title': result["title"]["value"],
        'description': result["description"]["value"],
        'issued': result["issued"]["value"],
        'identifier': result["identifier"]["value"],
        'page': result["page"]["value"],
        'subject': result["subject"]["value"]
    }
    if result.get("note"):
        json["note"] = result["note"]["value"]
    if result.get("geom"):
        json["geom"] = result["geom"]["value"]

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select distinct ?creator ?creator_name where {{ 
	  {} a  dn:Dataset.
    {} dct:creator ?creator.
    ?creator foaf:name ?creator_name.}}""".format(uri, uri))

    json2 = []
    for result in results["results"]["bindings"]:
        json2.append({
            'uri': result["creator"]["value"],
            'name': result["creator_name"]["value"]
        })
    json["creators"] = json2

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select distinct ?publisher ?publisher_name where {{ 
	  {} a  dn:Dataset.
    {} dct:publisher ?publisher.
    ?publisher foaf:name ?publisher_name.}}""".format(uri, uri))

    json21 = []
    for result in results["results"]["bindings"]:
        json21.append({
            'uri': result["publisher"]["value"],
            'name': result["publisher_name"]["value"]
        })
    json["publishers"] = json21

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select distinct ?depositor ?depositor where {{ 
	  {} a  dn:Dataset.
    {} dn:depositor ?depositor.
    ?depositor foaf:name ?depositor.}}""".format(uri, uri))

    json22 = []
    for result in results["results"]["bindings"]:
        json22.append({
            'uri': result["depositor"]["value"],
            'name': result["depositor_name"]["value"]
        })
    json["depositors"] = json22

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select distinct ?keyword where {{ 
	  {} a  dn:Dataset.
    {} dcat:keyword ?keyword.}}""".format(uri, uri))

    json3 = []
    for result in results["results"]["bindings"]:
        json3.append({'keyword': result["keyword"]["value"]})
    json["keywords"] = json3

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select ?article ?title ?issued ?identifier where {{ 
	  {} a  dn:Dataset.
    {} dn:presentedIn ?article.
    ?article dct:title ?title.
    ?article dct:issued ?issued.
    ?article dct:identifier ?identifier.}}
    """.format(uri, uri))

    json4 = []
    for result in results["results"]["bindings"]:
        json4.append({
            'uri': result["article"]["value"],
            'DOI': result["identifier"]["value"],
            'title': result["title"]["value"],
            'issued': result["issued"]["value"]
        })

    json["publication"] = json4

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select ?dist ?size ?downloadURL ?mediaType ?format where {{ 
	  {} a  dn:Dataset.
    {} dcat:distribution ?dist.  
    ?dist dcat:downloadURL ?downloadURL.  
    OPTIONAL{{   
    ?dist dcat:byteSize ?size.
    ?dist dcat:mediaType ?mediaType. 
    ?dist dn:hasFormat ?fo.
    ?fo rdfs:label ?format.}}
    }}
    """.format(uri, uri))
    json5 = []

    for result in results["results"]["bindings"]:
        json51 = {
            'uri': result["dist"]["value"],
            'downloadURL': result["downloadURL"]["value"]
        }
        if result.get("format"):
            json51["format"] = result["format"]["value"]
        else:
            json51["format"] = "Unknown"
        if result.get("size"):
            json51["size"] = result["size"]["value"]
        else:
            json51["size"] = "Unknown"
        if result.get("mediaType"):
            json51["mediaType"] = result["mediaType"]["value"]
        else:
            json51["mediaType"] = "Unknown"
        json5.append(json51)

    results = utils.query("""PREFIX dc: <http://purl.org/dc/elements/1.1/>
  PREFIX dct: <http://purl.org/dc/terms/>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dcat: <http://www.w3.org/ns/dcat#>
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  PREFIX prov-o: <http://www.w3.org/ns/prov#>
  select ?agent ?agent_name ?atTime ?source ?site where {{ 
	  {} a  dn:Dataset.  
    {} prov-o:wasDerivedFrom  ?source.
    {} prov-o:wasGeneratedBy ?act.
    ?act prov-o:atTime ?atTime.
    ?act dn:harvestSource ?site.
    ?act prov-o:wasAssociatedWith ?agent.
    ?agent foaf:name ?agent_name.}}
    """.format(uri, uri, uri))

    json6 = {}
    if len(results["results"]["bindings"]) > 0:
        result = results["results"]["bindings"][0]
        json6 = {
            'agent': result["agent"]["value"],
            'agentName': result["agent_name"]["value"],
            'atTime': result["atTime"]["value"],
            'source': result["source"]["value"],
            'site': result["site"]["value"]
        }

    json["provo"] = json6

    json["dists"] = json5

    return JsonResponse({'rs': json}, safe=False)
Example #16
0
def execute_workflow(request):
    python_path = sys.executable
    time.sleep(1)  # sleep 1s before executing the process
    ts = round(
        time.time())  # get the epoch and use it for the result file name
    files_path = os.path.join(settings.BASE_DIR, 'public', 'static', 'scripts')
    input_file = "" if request.GET.get(
        'in', '') == "" else os.path.join(files_path, request.GET.get(
            'in',
            ''))  # get the input file name (if given) sent by the frontend
    print("input file: " + input_file)
    uri = request.GET.get('uri', '')  # get the service/or function URI
    print("service: " + uri)
    q = """
  PREFIX dn: <http://melodi.irit.fr/ontologies/dn/>
  select ?url ?output where {{ 
	<{}> dn:accessURL ?url.
  OPTIONAL
  {{
  <{}> dn:hasOutputFormat ?of.
  ?of rdfs:label ?output.
  }}
  }}""".format(uri, uri)
    #print(q)
    results = utils.query(
        q
    )  # query the triplestore to get the corresponding script file name and the output file format

    url = results["results"]["bindings"][0]["url"]["value"]
    print("url: " + url)
    out_format = "" if not results["results"]["bindings"][0].get(
        "output") else ("." +
                        results["results"]["bindings"][0]["output"]["value"])
    params = "" if request.GET.get('params') == "None" else request.GET.get(
        'params')  # get the parameters (if given) sent by the frontend
    output_file = os.path.join(files_path, str(ts) + out_format)
    print("output file:" + output_file)
    call = ["python3", url]
    if input_file != "":
        call.append(input_file)
    if params != "":
        call.extend(params.split(" "))
    call.append(output_file)
    print(params)
    try:
        subprocess.call(
            call
        )  # use subprocess to execute the (python) script with the parameters and the output file name
        return JsonResponse({'rs': {
            'rs': 'OK',
            'file': str(ts) + out_format
        }},
                            safe=False)
    except subprocess.CalledProcessError as e:
        print(e.returncode)
        print(e.cmd)
        print(e.output)
        return JsonResponse({'rs': {
            'rs': 'Error',
            'file': 'None'
        }},
                            safe=False)
Example #17
0
def get_data_props(request):
    classes = []
    #get the corresponding classes (includes aligment/equivalent class/subclass..) of the instances
    results = utils.query(
        """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
        SELECT distinct ?uri ?label ?comment ?onto
        WHERE {{
           <{}> a ?uri.           
           ?uri rdfs:label ?label.
           FILTER (lang(?label)= "en" || lang(?label)="") 
        OPTIONAL
           {{
           ?uri rdfs:comment ?comment.
           FILTER (lang(?comment)= "en" || lang(?comment)="")
           }}
        ?uri rdfs:isDefinedBy ?onto.
        }}""".format(request.GET.get('uri')))

    for result in results["results"]["bindings"]:
        cls = {'uri': result["uri"]["value"], 'onto': result["onto"]["value"]}
        if result.get("label"):
            cls['label'] = result["label"]["value"]
        else:
            cls['label'] = ''
        if result.get("comment"):
            cls["comment"] = result["comment"]["value"]
        else:
            cls["comment"] = '-'
        classes.append(cls)

    # consider also that the instance is a rdfs:Resource and owl:Thing, that aren't explicitly declared.
    classes.append({
        'uri': 'http://www.w3.org/2000/01/rdf-schema#Resource',
        'onto': 'http://www.w3.org/2000/01/rdf-schema#',
        'label': 'Resource',
        'comment': 'The class resource, everything'
    })
    classes.append({
        'uri': 'http://www.w3.org/2002/07/owl#Thing',
        'onto': ' http://www.w3.org/2002/07/owl#',
        'label': 'Thing',
        'comment': 'The class of OWL individuals'
    })

    # for each classes above, get all properties. They will be used for new metadata insertion
    for clss in classes:

        json = []
        results = utils.query(
            """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
        SELECT distinct ?uri ?label ?comment ?range 
        WHERE {{
           ?uri rdfs:domain <{}>.               
           ?uri rdfs:label ?label.
           FILTER (lang(?label)= "en" || lang(?label)="") 
        OPTIONAL
           {{
           ?uri rdfs:comment ?comment.
           FILTER (lang(?comment)= "en" || lang(?comment)="")
           }}
        ?uri rdfs:range ?range.
        }} order by ?label""".format(clss["uri"]))

        for result in results["results"]["bindings"]:
            cls = {
                'uri': result["uri"]["value"],
                'range': result["range"]["value"]
            }
            if result.get("label"):
                cls['label'] = result["label"]["value"]
            else:
                cls['label'] = '-'
            if result.get("comment"):
                cls["comment"] = result["comment"]["value"]
            else:
                cls["comment"] = '-'
            json.append(cls)

        clss["props"] = json

        #Consider also properties from DCT that are declared in a different manner
        json = []
        results = utils.query(
            """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
        SELECT ?uri ?label ?comment  ?range
        WHERE {      
           ?uri rdfs:label ?label.
           FILTER (lang(?label)= "en" || lang(?label)="") 
        OPTIONAL
           {
           ?uri rdfs:comment ?comment.
           FILTER (lang(?comment)= "en" || lang(?comment)="")
           }
        ?uri rdfs:isDefinedBy <http://purl.org/dc/terms/>.
        ?uri rdfs:range ?range.
   
        } order by ?label""")
        #FILTER(?range = <http://www.w3.org/2000/01/rdf-schema#Literal>)

        for result in results["results"]["bindings"]:
            cls = {
                'uri': result["uri"]["value"],
                'range': result["range"]["value"]
            }
            if result.get("label"):
                cls['label'] = result["label"]["value"]
            else:
                cls['label'] = '-'
            if result.get("comment"):
                cls["comment"] = result["comment"]["value"]
            else:
                cls["comment"] = '-'
            json.append(cls)

    json.append({
        'uri': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
        'label': 'type',
        'comment': 'The subject is an instance of a class',
        'range': 'rdfs:Class'
    })

    classes.append({
        'uri': 'http://purl.org/dc/terms/Thing',
        'onto': 'http://purl.org/dc/terms/',
        'label': 'Thing',
        'comment': 'A blank class',
        'props': json
    })

    return JsonResponse({'rs': classes}, safe=False)