Exemplo n.º 1
0
 def get_where_tree(self, res):
   # if res.subject == rdflib.term.URIRef('http://www.corila.it/cigno/researchareas/'):
   if cigno_ras in res.rdf_type:
     where1 = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?key"),
              ("?cc", member, "?key"),
              ("?c", member, "?cc"),
              (res.subject, member, "?c")]
     where2 = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?key"),
              ("?c", member, "?key"),
              (res.subject, member, "?c")]
     where = [union(group(*where1),group(*where2))]
   elif cigno_ra in res.rdf_type:
     where1 = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?key"),
              ("?c", member, "?key"),
              (res.subject, member, "?c")
              ]
     where2 = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?c"),
              (res.subject, member, "?c")
              ]
     where = [union(group(*where1),group(*where2))]
   elif res.subject == rdflib.term.URIRef('http://www.eionet.europa.eu/gemet/supergroup/'):
     where = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?key"),
              ("?cc", member, "?key"),
              ("?c", member, "?cc"),
              (res.subject, member, "?c")
              ]
   elif gemet_sg in res.rdf_type:
     where = [("?s", a, surf.ns.CIGNO['Resource']),
              ("?s", surf.ns.DCTERMS['subject'], "?key"),
              ("?c", member, "?key"),
              (res.subject, member, "?c")]
   elif gemet_g in res.rdf_type:
     # key = child
     where = [("?s", a, cigno_r),
              ("?s", surf.ns.DCTERMS['subject'], "?c"),
              (res.subject, member, "?c")
              ]
   elif gemet_t in res.rdf_type:
     # key = child
     where = [("?s", a, cigno_r),
              ("?s", surf.ns.DCTERMS['subject'], "?c"),
              (res.subject, member, "?c")
              ]
   elif skos_c in res.rdf_type:
     where = [("?s", a, cigno_r),
              ("?s", surf.ns.DCTERMS['subject'], res.subject)
              ]
   import sys
   return where
Exemplo n.º 2
0
  def get_resources_by_classification(self,res):
    # s = s if isinstance(s, URIRef) else URIRef(s)
    where = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource'])
             ]

    if surf.ns.CIGNO['ResearchArea'] in res.rdf_type:
      where1 = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource']),
               ("?s", surf.ns.DCTERMS['subject'], "?key"),
               ("?theme", member, "?key"),
               (res.subject, member, "?theme")
               ]
      where2 = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource']),
               ("?s", surf.ns.DCTERMS['subject'], "?key"),
               (res.subject, member, "?key")
               ]
      where = [union(group(*where1),group(*where2))]
    elif surf.ns.GEMET['Theme'] in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append((res.subject, member, "?key"))
    elif surf.namespace.SKOS['Concept'] in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], res.subject)) 
    elif gemet_sg in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append(("?group", member, "?key"))
      where.append((res.subject, member, "?group"))
    elif gemet_g in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append((res.subject, member, "?key"))
                 
    query = surf.query.select("?s").where(*where).distinct()
  
    a =res.rdf_type
    # a.aa

    result = self.session.default_store.execute_sparql(sanitize_sparql("%s" % query))
    return result['results']['bindings']
Exemplo n.º 3
0
  def get_resources_by_classification(self,res):
    # s = s if isinstance(s, URIRef) else URIRef(s)
    where = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource'])
             ]

    if surf.ns.CIGNO['ResearchArea'] in res.rdf_type:
      where1 = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource']),
               ("?s", surf.ns.DCTERMS['subject'], "?key"),
               ("?theme", member, "?key"),
               (res.subject, member, "?theme")
               ]
      where2 = [("?s", surf.ns.RDF['type'], surf.ns.CIGNO['Resource']),
               ("?s", surf.ns.DCTERMS['subject'], "?key"),
               (res.subject, member, "?key")
               ]
      where = [union(group(*where1),group(*where2))]
    elif surf.ns.GEMET['Theme'] in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append((res.subject, member, "?key"))
    elif surf.namespace.SKOS['Concept'] in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], res.subject)) 
    elif gemet_sg in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append(("?group", member, "?key"))
      where.append((res.subject, member, "?group"))
    elif gemet_g in res.rdf_type:
      where.append(("?s", surf.ns.DCTERMS['subject'], "?key"))
      where.append((res.subject, member, "?key"))
                 
    query = surf.query.select("?s").where(*where).distinct()
  
    a =res.rdf_type
    # a.aa

    result = self.session.default_store.execute_sparql(sanitize_sparql("%s" % query))
    return result['results']['bindings']