def run(self): ''' Runs the widget :returns: True if there's no errors :rtype: Boolean ''' project = PagLuxembourg.main.current_project if not project.isPagProject(): return layer_structure_errors = list() data_errors = list() # 'MODIFICATION PAG' layer definition layer_PAG = project.getModificationPagLayer() # 'MODIFICATION PAG' selection definition selection_PAG = layer_PAG.selectedFeatures() # Counting number entities in 'MODIFICATION PAG' selection entity_count_PAG = layer_PAG.selectedFeatureCount() # Iterates through XSD types for type in PagLuxembourg.main.xsd_schema.types: layer = project.getLayer(type) if layer is None: continue warn_errors, fatal_errors = self.checkLayerStructure(layer, type) layer_structure_errors = layer_structure_errors + warn_errors + fatal_errors if len(fatal_errors) > 0: continue layer_data_errors = self.checkLayerData(selection_PAG, layer, type) data_errors.append(layer_data_errors) # Flatten data errors data_errors_flat = list() for layer, errors in data_errors: for feature, field, message in errors: data_errors_flat.append((layer, feature, field, message)) valid = (len(layer_structure_errors) + len(data_errors_flat)) == 0 # Messages display for number of selected entities if valid and entity_count_PAG == 1: PagLuxembourg.main.qgis_interface.messageBar().clearWidgets() PagLuxembourg.main.qgis_interface.messageBar().pushSuccess( QCoreApplication.translate('DataChecker', 'Success'), QCoreApplication.translate( 'DataChecker', 'No errors found on entities that intersect {} selected entity in MODIFICATION PAG layer' ).format(entity_count_PAG)) elif valid and entity_count_PAG == 0: PagLuxembourg.main.qgis_interface.messageBar().clearWidgets() PagLuxembourg.main.qgis_interface.messageBar().pushSuccess( QCoreApplication.translate('DataChecker_no', 'Success'), QCoreApplication.translate('DataChecker_no', 'No errors found')) elif valid and entity_count_PAG > 1: PagLuxembourg.main.qgis_interface.messageBar().clearWidgets() PagLuxembourg.main.qgis_interface.messageBar().pushSuccess( QCoreApplication.translate('DataChecker_many', 'Success'), QCoreApplication.translate( 'DataChecker_many', 'No errors found on entities that intersect {} selected entities in MODIFICATION PAG layer' ).format(entity_count_PAG)) else: self.dlg = ErrorSummaryDialog(layer_structure_errors, data_errors) self.dlg.show() return valid