Skip to content

Commit

Permalink
ontdoc update and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Apr 17, 2024
1 parent 19bf580 commit 2c1bae1
Show file tree
Hide file tree
Showing 37 changed files with 2,303 additions and 1,729 deletions.
8 changes: 4 additions & 4 deletions dialogs/tool/convertlayerdialog.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from qgis.PyQt import uic
from qgis.PyQt import QtWidgets
from qgis.core import QgsProject,QgsMapLayerProxyModel, Qgis
from qgis.PyQt.QtWidgets import QProgressDialog, QFileDialog,QMessageBox
from qgis.core import QgsMapLayerProxyModel
from qgis.PyQt.QtWidgets import QProgressDialog, QFileDialog
from qgis.core import QgsApplication
from qgis.core import Qgis,QgsTask, QgsMessageLog
from qgis.core import Qgis, QgsMessageLog
from qgis.PyQt.QtCore import Qt

from ...util.export.data.exporter.exporterutils import ExporterUtils
from ...util.export.exporterutils import ExporterUtils
from ...util.ui.uiutils import UIUtils
from ...tasks.processing.convertlayertask import ConvertLayerTask
import os.path
Expand Down
10 changes: 5 additions & 5 deletions tabs/interlinkingtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..util.interlinkutils import InterlinkUtils
from ..util.ui.uiutils import UIUtils
from ..util.export.data.exporter.exporterutils import ExporterUtils
from ..util.export.exporterutils import ExporterUtils
from ..tasks.processing.convertlayertask import ConvertLayerTask

## Provides implementations for functions accessible from the interlinking tab
Expand Down Expand Up @@ -83,8 +83,8 @@ def suggestSchema(self):
for col in columntypes:
if "id" in col and col["id"] and not col["geotype"]:
self.dlg.interlinkTable.item(counter,1).setCheckState(col["id"])
item = QTableWidgetItem("rdf:type")
item.setText("rdf:type")
item = QTableWidgetItem("data:type")
item.setText("data:type")
item.setData(1, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
self.dlg.interlinkTable.setItem(counter, 4,item)
if col["geotype"]:
Expand Down Expand Up @@ -199,8 +199,8 @@ def readMapping(self, filename):
if columnname not in filedata["columns"]:
if "indid" in filedata and filedata["indid"]==columnname:
self.dlg.interlinkTable.item(row, 1).setCheckState(True)
item = QTableWidgetItem("rdf:type")
item.setText("rdf:type")
item = QTableWidgetItem("data:type")
item.setText("data:type")
item.setData(1, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
self.dlg.interlinkTable.setItem(row, 4, item)
comboboxx = self.dlg.interlinkTable.cellWidget(row, 5)
Expand Down
2 changes: 1 addition & 1 deletion tasks/processing/convertlayertask.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from ...util.export.data.exporter.layer.layerexporter import LayerExporter
from ...util.export.layer.layerexporter import LayerExporter
from qgis.utils import iface
from qgis.core import Qgis,QgsTask, QgsMessageLog
from qgis.PyQt.QtWidgets import QMessageBox
Expand Down
6 changes: 2 additions & 4 deletions tasks/processing/ontdoctask.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ def __init__(self, description, graphname, namespace,prefixes,license,labellang,
self.startconcept=startconcept
self.offlinecompat=offlinecompat
self.exports=exports
self.ogcapifeatures=ogcapifeatures
self.iiif=iiif
self.imagemetadata=imagemetadata
self.ckan=ckan
self.apis={"ogcapifeatures":ogcapifeatures,"iiif":iiif,"ckan":ckan,"solidexport":False}
self.createVOWL=createVOWL
self.createMetadataTable=createMetadataTable
self.nonNSPagesCBox=nonNSPagesCBox
Expand Down Expand Up @@ -55,7 +53,7 @@ def run(self):
else:
nsshort=self.namespace[self.namespace.rfind('/') + 1:]
#try:
ontdoc=OntDocGeneration(self.prefixes, self.namespace, nsshort,self.license,self.labellang, self.outpath, self.graph,self.createcollections,self.baselayers,self.tobeaddedperInd,self.maincolor,self.titlecolor,self.progress,self.createIndexPages,self.nonNSPagesCBox,self.createMetadataTable,self.createVOWL,self.ogcapifeatures,self.iiif,self.ckan,self.imagemetadata,self.startconcept,self.deploymenturl,self.logopath,self.offlinecompat,self.exports)
ontdoc=OntDocGeneration(self.prefixes, self.namespace, nsshort,self.license,self.labellang, self.outpath, self.graph,self.createcollections,self.baselayers,self.tobeaddedperInd,self.maincolor,self.titlecolor,self.progress,self.createIndexPages,self.nonNSPagesCBox,self.createMetadataTable,self.createVOWL,self.apis,self.imagemetadata,self.startconcept,self.deploymenturl,self.logopath,self.offlinecompat,self.exports)
ontdoc.generateOntDocForNameSpace(self.namespace)
#except Exception as e:
# self.exception=e
Expand Down
2 changes: 1 addition & 1 deletion tasks/query/data/querysubgraphtask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rdflib import Graph

from ....util.export.data.exporter.exporterutils import ExporterUtils
from ....util.export.exporterutils import ExporterUtils
from ....util.sparqlutils import SPARQLUtils
from qgis.core import Qgis,QgsTask, QgsMessageLog
from qgis.PyQt.QtWidgets import QFileDialog
Expand Down
67 changes: 2 additions & 65 deletions tasks/query/discovery/classtreequerytask.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,75 +37,12 @@ def __init__(self, description, triplestoreurl,dlg,treeNode,triplestoreconf,pref
self.classtreemap=None
self.subclassmap=None
self.query="""PREFIX owl: <http://www.w3.org/2002/07/owl#>\n
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n
PREFIX data: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n
SELECT DISTINCT ?subject ?label ?supertype \n
WHERE {\n"""
self.query += "{ ?individual <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> ?subject . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> owl:Class . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> rdfs:Class . } \n"
self.query += "{ ?individual <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> ?subject . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> owl:Class . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> rdfs:Class . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["subclassproperty"]) + "> ?supertype . } \n"
self.query += """OPTIONAL { ?subject <""" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["subclassproperty"]) + """> ?supertype . }\n""" + SPARQLUtils.resolvePropertyToTriplePattern("%%labelproperty%%", "?label", "?subject",self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()],"OPTIONAL", "")+ """ }"""
"""
self.geoquery=PREFIX owl: <http://www.w3.org/2002/07/owl#>\n
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n
SELECT DISTINCT ?subject ?label ?supertype (Bound(?hasgeo) AS ?hgeo)\n
self.optionalpart=""
if "geotriplepattern" in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]:
geotriplepattern=""
if len(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geotriplepattern"])>1:
geotriplepattern+="OPTIONAL {"
first=True
for geopat in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geotriplepattern"]:
if first:
first=False
else:
geotriplepattern+=" UNION "
geotriplepattern += " { " + geopat.replace("?geo", "?hasgeo").replace("?lat", "?hasgeo").replace("?item","?individual") + " }\n"
geotriplepattern+="}\n"
elif len(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geotriplepattern"])>0:
geotriplepattern += "OPTIONAL { " + self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geotriplepattern"][0].replace("?geo", "?hasgeo").replace("?item","?individual")+" }\n"
self.optionalpart=geotriplepattern
if "highload" in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()] and self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["highload"]:
self.query+="{ ?individual <"+self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]+"> ?subject . } UNION { ?subject <"+str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"])+"> owl:Class . } \n"
elif self.optionalpart=="" and "geometryproperty" in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()] \
and (self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]=="http://www.opengis.net/ont/geosparql#asWKT"
or self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]=="http://www.opengis.net/ont/geosparql#asGML"
or self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]=="http://www.opengis.net/ont/geosparql#asGeoJSON"
or self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]=="http://www.opengis.net/ont/geosparql#asKML"
):
if isinstance(self.triplestoreconf["geometryproperty"], str):
self.optionalpart = "OPTIONAL {BIND(EXISTS {?individual ?a ?lit . ?lit <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"]) + "> ?wkt } AS ?hasgeo)}"
else:
self.optionalpart = "OPTIONAL {?individual ?a ?lit . ?lit <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"][0]) + "> ?hasgeo }"
#self.query+="{ ?individual <"+str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"])+"> ?subject . "+str(self.optionalpart)+"} UNION { ?subject <"+str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"])+"> owl:Class . } \n"
elif self.optionalpart=="" and "geometryproperty" in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()] and self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]=="http://www.opengis.net/ont/geosparql#hasGeometry":
if isinstance(self.triplestoreconf["geometryproperty"], str):
self.optionalpart = "OPTIONAL {BIND(EXISTS {?individual <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"]) + "> ?lit . ?lit ?a ?wkt } AS ?hasgeo)}"
else:
self.optionalpart = "OPTIONAL {?individual <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"][0]) + "> ?lit . ?lit ?a ?hasgeo }"
elif self.optionalpart=="" and "geometryproperty" in self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()] and self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["geometryproperty"]!="":
if isinstance(self.triplestoreconf["geometryproperty"],str):
self.optionalpart = "OPTIONAL {BIND(EXISTS {?individual <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"]) + "> ?wkt } AS ?hasgeo)}"
elif isinstance(self.triplestoreconf["geometryproperty"],list):
self.optionalpart = "OPTIONAL {?individual <" + str(
self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()][
"geometryproperty"][0]) + "> ?hasgeo }"
#self.query+="{ ?individual <"+self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]+"> ?subject . "+str(self.optionalpart)+"} UNION { ?subject <"+str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"])+"> owl:Class . } \n"
elif self.optionalpart=="":
#self.query += "{ ?individual <" + self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"] + "> ?subject . } UNION { ?subject <" + str(self.dlg.triplestoreconf[self.dlg.comboBox.currentIndex()]["typeproperty"]) + "> owl:Class . } .\n"
self.query=self.query.replace("(Bound(?hasgeo) AS ?hgeo)","").replace("?hasgeo","")
"""


def run(self):
Expand Down
2 changes: 1 addition & 1 deletion tasks/query/enrichment/enrichmentquerytask.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def run(self):
if self.table.item(self.row, 7).text() != "" and "wikidata" in curtriplestoreconf["resource"]["url"]:
query += "?item wdt:P31 <" + str(self.table.item(self.row, 7).text()) + "> .\n"
else:
query += "?item rdf:type <" + str(self.table.item(self.row, 7).text()) + "> .\n"
query += "?item data:type <" + str(self.table.item(self.row, 7).text()) + "> .\n"
query += "?item <" + str(self.idprop) + "> ?vals .\n"
query += "?item <" + str(proppp) + "> ?val . \n"
if (self.content == "Enrich Value" or self.content == "Enrich Both") and not "wikidata" in curtriplestoreconf["resource"]["url"]:
Expand Down
Loading

0 comments on commit 2c1bae1

Please sign in to comment.