Ejemplo n.º 1
0
    def connection_info(self):
        """show connection info"""

        current_text = self.cmbConnectionsServices.currentText()
        key = '/MetaSearch/%s' % current_text
        self.catalog_url = self.settings.value('%s/url' % key)
        self.catalog_username = self.settings.value('%s/username' % key)
        self.catalog_password = self.settings.value('%s/password' % key)
        self.catalog_type = self.settings.value('%s/catalog-type' % key)

        # connect to the server
        if not self._get_catalog():
            return

        if self.catalog:  # display service metadata
            self.btnRawAPIResponse.setEnabled(True)
            metadata = render_template('en', self.context, self.catalog.conn,
                                       self.catalog.service_info_template)
            style = QgsApplication.reportStyleSheet()
            self.textMetadata.clear()
            self.textMetadata.document().setDefaultStyleSheet(style)
            self.textMetadata.setHtml(metadata)

            # clear results and disable buttons in Search tab
            self.clear_results()
Ejemplo n.º 2
0
    def __init__(self, parent=None, iface = None):
        """Constructor
        :param parent: Parent object
        :type parent: QWidget
        :param iface: A QGIS interface instance.
        :type iface: QgsInterface
        """
        super(SOSClientDialog, self).__init__(parent)
        
        settings = QtCore.QSettings ()
                
        self.iface = iface
        self.reply = None
        self.service = None
        self.filterRequest = None
        self.createTimeManagerLayer = False
        self.addLayerToTimeManager = lambda *a,**k: None
        
        # Set up the user interface from Designer.
        self.setupUi(self)
        
        #Ayuda
        self.btnBox.helpRequested.connect(lambda: showPluginHelp(filename="help/index"))
        # Botón Añadir y Editar y añadir
        self.btnAdd.setDefaultAction (self.actionAdd)
        self.btnAdd.addAction(self.actionEditRequest)
        self.btnBox.addButton(self.btnAdd, QtGui.QDialogButtonBox.ActionRole)
        self.btnAdd.setEnabled(False)
        
        #Guardar y cargar lista de servidores
        self.btnSave.setVisible (False)
        self.btnLoad.setVisible (False)

        #Visor de información del servidor
        self.htmlView.document().setDefaultStyleSheet(QgsApplication.reportStyleSheet())
        self.htmlView.customContextMenuRequested.connect (lambda point, widget=self.htmlView, actions = [self.actionShowXML]: addContextMenuActions (point,widget, actions))
        
        #Acciones de selección para listas
        self.lstProperties.addAction(self.actionSelectAllProperties)
        self.lstProperties.addAction(self.actionSelectNoneProperties)
        self.lstProperties.addAction(self.actionSelectInvertProperties)
        self.lstFeatures.addAction(self.actionSelectAllFeatures)
        self.lstFeatures.addAction(self.actionSelectNoneFeatures)
        self.lstFeatures.addAction(self.actionSelectInvertFeatures)
        self.lstProcedures.addAction(self.actionSelectAllProcedures)
        self.lstProcedures.addAction(self.actionSelectNoneProcedures)
        self.lstProcedures.addAction(self.actionSelectInvertProcedures)

        #Filtros
        self.grpFilterSpatial.setEnabled (False)
        self.lblSpatialFilterWarning.setVisible (False)
        self.grpFilterTemporal.setEnabled (False)
        self.grpFilterScalar.setEnabled (False)
        
        #Listar conexiones
        self.populateConnectionList ()
        
        #Directorio de trabajo
        self.workDirName.setText(settings.value("SOSClient/workDir", QtCore.QDir.tempPath(), type=str))
        self.workDirName.textChanged.connect (lambda value : settings.setValue("SOSClient/workDir", value))
Ejemplo n.º 3
0
    def show_metadata(self):
        """show record metadata"""

        if not self.treeRecords.selectedItems():
            return

        item = self.treeRecords.currentItem()
        if not item:
            return

        identifier = get_item_data(item, 'identifier')

        self.disable_ssl_verification = self.disableSSLVerification.isChecked()
        auth = None

        if self.disable_ssl_verification:
            try:
                auth = Authentication(verify=False)
            except NameError:
                pass

        try:
            with OverrideCursor(Qt.WaitCursor):
                cat = get_catalog_service(
                    self.catalog_url,  # spellok
                    catalog_type=self.catalog_type,
                    timeout=self.timeout,
                    username=self.catalog_username,
                    password=self.catalog_password,
                    auth=auth)
                record = cat.get_record(identifier)
                if cat.type == 'OGC API - Records':
                    record['url'] = cat.conn.request
                elif cat.type == 'OGC CSW 2.0.2':
                    record.url = cat.conn.request

        except Exception as err:
            QMessageBox.warning(
                self, self.tr('GetRecords error'),
                self.tr('Error getting response: {0}').format(err))
            return
        except KeyError as err:
            QMessageBox.warning(
                self, self.tr('Record parsing error'),
                self.tr('Unable to locate record identifier: {0}').format(err))
            return

        crd = RecordDialog()
        metadata = render_template('en', self.context, record,
                                   self.catalog.record_info_template)

        style = QgsApplication.reportStyleSheet()
        crd.textMetadata.document().setDefaultStyleSheet(style)
        crd.textMetadata.setHtml(metadata)
        crd.exec_()
Ejemplo n.º 4
0
    def show_metadata(self):
        """show record metadata"""

        if not self.treeRecords.selectedItems():
            return

        item = self.treeRecords.currentItem()
        if not item:
            return

        identifier = get_item_data(item, 'identifier')

        self.disable_ssl_verification = self.disableSSLVerification.isChecked()
        auth = None

        if self.disable_ssl_verification:
            try:
                auth = Authentication(verify=False)
            except NameError:
                pass

        try:
            with OverrideCursor(Qt.WaitCursor):
                cat = CatalogueServiceWeb(
                    self.catalog_url,
                    timeout=self.timeout,  # spellok
                    username=self.catalog_username,
                    password=self.catalog_password,
                    auth=auth)
                cat.getrecordbyid(
                    [self.catalog.records[identifier].identifier])
        except ExceptionReport as err:
            QMessageBox.warning(
                self, self.tr('GetRecords error'),
                self.tr('Error getting response: {0}').format(err))
            return
        except KeyError as err:
            QMessageBox.warning(self, self.tr('Record parsing error'),
                                self.tr('Unable to locate record identifier'))
            return

        record = cat.records[identifier]
        record.xml_url = cat.request

        crd = RecordDialog()
        metadata = render_template('en', self.context, record,
                                   'record_metadata_dc.html')

        style = QgsApplication.reportStyleSheet()
        crd.textMetadata.document().setDefaultStyleSheet(style)
        crd.textMetadata.setHtml(metadata)
        crd.exec_()
Ejemplo n.º 5
0
    def show_xml(self):
        """show XML request / response"""

        crd = XMLDialog()
        request_html = highlight_xml(self.context, self.catalog.request)
        response_html = highlight_xml(self.context, self.catalog.response)
        style = QgsApplication.reportStyleSheet()
        crd.txtbrXMLRequest.clear()
        crd.txtbrXMLResponse.clear()
        crd.txtbrXMLRequest.document().setDefaultStyleSheet(style)
        crd.txtbrXMLResponse.document().setDefaultStyleSheet(style)
        crd.txtbrXMLRequest.setHtml(request_html)
        crd.txtbrXMLResponse.setHtml(response_html)
        crd.exec_()
Ejemplo n.º 6
0
    def show_xml(self):
        """show XML request / response"""

        crd = XMLDialog()
        request_html = highlight_xml(self.context, self.catalog.request)
        response_html = highlight_xml(self.context, self.catalog.response)
        style = QgsApplication.reportStyleSheet()
        crd.txtbrXMLRequest.clear()
        crd.txtbrXMLResponse.clear()
        crd.txtbrXMLRequest.document().setDefaultStyleSheet(style)
        crd.txtbrXMLResponse.document().setDefaultStyleSheet(style)
        crd.txtbrXMLRequest.setHtml(request_html)
        crd.txtbrXMLResponse.setHtml(response_html)
        crd.exec_()
Ejemplo n.º 7
0
    def show_api(self):
        """show API request / response"""

        crd = APIRequestResponseDialog()
        request_html = highlight_content(self.context, self.catalog.request,
                                         self.catalog.format)
        response_html = highlight_content(self.context, self.catalog.response,
                                          self.catalog.format)
        style = QgsApplication.reportStyleSheet()
        crd.txtbrAPIRequest.clear()
        crd.txtbrAPIResponse.clear()
        crd.txtbrAPIRequest.document().setDefaultStyleSheet(style)
        crd.txtbrAPIResponse.document().setDefaultStyleSheet(style)
        crd.txtbrAPIRequest.setHtml(request_html)
        crd.txtbrAPIResponse.setHtml(response_html)
        crd.exec_()
Ejemplo n.º 8
0
    def show_metadata(self):
        """show record metadata"""

        if not self.treeRecords.selectedItems():
            return

        item = self.treeRecords.currentItem()
        if not item:
            return

        identifier = get_item_data(item, 'identifier')

        try:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            cat = CatalogueServiceWeb(self.catalog_url, timeout=self.timeout,
                                      username=self.catalog_username,
                                      password=self.catalog_password)
            cat.getrecordbyid(
                [self.catalog.records[identifier].identifier])
        except ExceptionReport as err:
            QApplication.restoreOverrideCursor()
            QMessageBox.warning(self, self.tr('GetRecords error'),
                                self.tr('Error getting response: {0}').format(err))
            return
        except KeyError as err:
            QMessageBox.warning(self,
                                self.tr('Record parsing error'),
                                self.tr('Unable to locate record identifier'))
            QApplication.restoreOverrideCursor()
            return

        QApplication.restoreOverrideCursor()

        record = cat.records[identifier]
        record.xml_url = cat.request

        crd = RecordDialog()
        metadata = render_template('en', self.context,
                                   record, 'record_metadata_dc.html')

        style = QgsApplication.reportStyleSheet()
        crd.textMetadata.document().setDefaultStyleSheet(style)
        crd.textMetadata.setHtml(metadata)
        crd.exec_()
Ejemplo n.º 9
0
    def show_metadata(self):
        """show record metadata"""

        if not self.treeRecords.selectedItems():
            return

        item = self.treeRecords.currentItem()
        if not item:
            return

        identifier = get_item_data(item, 'identifier')

        try:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            cat = CatalogueServiceWeb(self.catalog_url,
                                      timeout=self.timeout,
                                      username=self.catalog_username,
                                      password=self.catalog_password)
            cat.getrecordbyid([self.catalog.records[identifier].identifier])
        except ExceptionReport as err:
            QApplication.restoreOverrideCursor()
            QMessageBox.warning(
                self, self.tr('GetRecords error'),
                self.tr('Error getting response: {0}').format(err))
            return
        except KeyError as err:
            QMessageBox.warning(self, self.tr('Record parsing error'),
                                self.tr('Unable to locate record identifier'))
            QApplication.restoreOverrideCursor()
            return

        QApplication.restoreOverrideCursor()

        record = cat.records[identifier]
        record.xml_url = cat.request

        crd = RecordDialog()
        metadata = render_template('en', self.context, record,
                                   'record_metadata_dc.html')

        style = QgsApplication.reportStyleSheet()
        crd.textMetadata.document().setDefaultStyleSheet(style)
        crd.textMetadata.setHtml(metadata)
        crd.exec_()
Ejemplo n.º 10
0
    def connection_info(self):
        """show connection info"""

        current_text = self.cmbConnectionsServices.currentText()
        key = '/MetaSearch/%s' % current_text
        self.catalog_url = self.settings.value('%s/url' % key)
        self.catalog_username = self.settings.value('%s/username' % key)
        self.catalog_password = self.settings.value('%s/password' % key)

        # connect to the server
        if not self._get_csw():
            return

        if self.catalog:  # display service metadata
            self.btnCapabilities.setEnabled(True)
            metadata = render_template('en', self.context, self.catalog,
                                       'service_metadata.html')
            style = QgsApplication.reportStyleSheet()
            self.textMetadata.clear()
            self.textMetadata.document().setDefaultStyleSheet(style)
            self.textMetadata.setHtml(metadata)
Ejemplo n.º 11
0
    def connection_info(self):
        """show connection info"""

        current_text = self.cmbConnectionsServices.currentText()
        key = '/MetaSearch/%s' % current_text
        self.catalog_url = self.settings.value('%s/url' % key)

        # connect to the server
        if not self._get_csw():
            return

        QApplication.restoreOverrideCursor()

        if self.catalog:  # display service metadata
            self.btnCapabilities.setEnabled(True)
            metadata = render_template('en', self.context,
                                       self.catalog,
                                       'service_metadata.html')
            style = QgsApplication.reportStyleSheet()
            self.textMetadata.clear()
            self.textMetadata.document().setDefaultStyleSheet(style)
            self.textMetadata.setHtml(metadata)
Ejemplo n.º 12
0
    def __init__(self, parent=None, iface=None):
        """Constructor
        :param parent: Parent object
        :type parent: QWidget
        :param iface: A QGIS interface instance.
        :type iface: QgsInterface
        """
        super(SOSClientDialog, self).__init__(parent)

        settings = QtCore.QSettings()

        self.iface = iface
        self.reply = None
        self.service = None
        self.filterRequest = None
        self.createTimeManagerLayer = False
        self.addLayerToTimeManager = lambda *a, **k: None

        # Set up the user interface from Designer.
        self.setupUi(self)

        #Ayuda
        self.btnBox.helpRequested.connect(
            lambda: showPluginHelp(filename="help/index"))
        # Botón Añadir y Editar y añadir
        self.btnAdd.setDefaultAction(self.actionAdd)
        self.btnAdd.addAction(self.actionEditRequest)
        self.btnBox.addButton(self.btnAdd, QtGui.QDialogButtonBox.ActionRole)
        self.btnAdd.setEnabled(False)

        #Guardar y cargar lista de servidores
        self.btnSave.setVisible(False)
        self.btnLoad.setVisible(False)

        #Visor de información del servidor
        self.htmlView.document().setDefaultStyleSheet(
            QgsApplication.reportStyleSheet())
        self.htmlView.customContextMenuRequested.connect(
            lambda point, widget=self.htmlView, actions=[self.actionShowXML]:
            addContextMenuActions(point, widget, actions))

        #Acciones de selección para listas
        self.lstProperties.addAction(self.actionSelectAllProperties)
        self.lstProperties.addAction(self.actionSelectNoneProperties)
        self.lstProperties.addAction(self.actionSelectInvertProperties)
        self.lstFeatures.addAction(self.actionSelectAllFeatures)
        self.lstFeatures.addAction(self.actionSelectNoneFeatures)
        self.lstFeatures.addAction(self.actionSelectInvertFeatures)
        self.lstProcedures.addAction(self.actionSelectAllProcedures)
        self.lstProcedures.addAction(self.actionSelectNoneProcedures)
        self.lstProcedures.addAction(self.actionSelectInvertProcedures)

        #Filtros
        self.grpFilterSpatial.setEnabled(False)
        self.lblSpatialFilterWarning.setVisible(False)
        self.grpFilterTemporal.setEnabled(False)
        self.grpFilterScalar.setEnabled(False)

        #Listar conexiones
        self.populateConnectionList()

        #Directorio de trabajo
        self.workDirName.setText(
            settings.value("SOSClient/workDir",
                           QtCore.QDir.tempPath(),
                           type=str))
        self.workDirName.textChanged.connect(
            lambda value: settings.setValue("SOSClient/workDir", value))