Data Validators
Aggregated and individual rule validators.
BaseRuleValidator
Validator for an individual rule.
This is an abstract class that needs to be subclassed with the
specific validation implementation by overriding the validate
protected function.
Source code in src/cplus_plugin/lib/validation/validators.py
feedback
property
Returns the feedback object used in the validator for providing feedback on the validation process.
Returns:
Type | Description |
---|---|
ValidationFeedback
|
Feedback object used in the validator for providing feedback on the validation process. |
result
property
Returns the result of the validation process.
Returns:
Type | Description |
---|---|
RuleResult
|
Result of the validation process. |
rule_configuration
property
Returns the rule configuration use in the validator.
Returns:
Type | Description |
---|---|
RuleConfiguration
|
Rule configuration used in the validator. |
rule_type
abstractmethod
property
Returns the type identifier of the rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
Type identifier of the rule validator. |
get_default_layer_metadata
Get default layer metadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_uuid |
str
|
UUID of the layer |
required |
layer_type |
str
|
Type of the layer e.g. ncs_pathway |
'ncs_pathway'
|
Returns:
Type | Description |
---|---|
typing.Dict
|
Layer metadata |
Source code in src/cplus_plugin/lib/validation/validators.py
is_comparative
Indicate whether the validation check is comparative i.e. relative to the datasets or an absolute check. The former requires more than one dataset to execute the validation whereas the latter can be executed even for one dataset.
Returns:
Type | Description |
---|---|
bool
|
True if the validator is comparative else False. Default is True. |
Source code in src/cplus_plugin/lib/validation/validators.py
log
Convenience function that logs the given messages by appending the information in the rule configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Message to be logged. |
required |
info |
bool
|
False if the message should be logged as a warning else True if information. |
True
|
Source code in src/cplus_plugin/lib/validation/validators.py
run
Initiates the rule validation process and returns a result indicating whether the process succeeded or failed.
A fail result would, for instance, be due to no layers, or only one layer, defined for validation.
Returns:
Type | Description |
---|---|
bool
|
True if the validation process succeeded or False if it failed. |
Source code in src/cplus_plugin/lib/validation/validators.py
CarbonLayerResolutionValidator
Bases: ResolutionValidator
Checks if the resolution of the carbon layers matches that of the corresponding NCS pathways.
Source code in src/cplus_plugin/lib/validation/validators.py
rule_type
property
Returns the no data value rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
No data value rule validator. |
CrsValidator
Bases: BaseRuleValidator
Checks if the input datasets have the same CRS.
Source code in src/cplus_plugin/lib/validation/validators.py
DataValidator
Bases: QgsTask
Abstract runner for checking a set of datasets against specific validation rules.
Rule validators need to be added manually in the sub-class implementation and set the model component type of the result.
Source code in src/cplus_plugin/lib/validation/validators.py
feedback
property
Returns the feedback object used in the validator for providing feedback on the validation process.
Returns:
Type | Description |
---|---|
ValidationFeedback
|
Feedback object used in the validator for providing feedback on the validation process. |
result
property
Returns the result of the validation process.
Returns:
Type | Description |
---|---|
ValidationResult
|
Result of the validation process. |
add_rule_validator
Add a rule validator for validating the input model components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_validator |
BaseRuleValidator
|
Validator for checking the input model components based on the specific validation rule. |
required |
Source code in src/cplus_plugin/lib/validation/validators.py
cancel
create_rule_validator
staticmethod
Factory method for creating a rule validator object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_type |
RuleType
|
The type of the validator rule. |
required |
config |
RuleConfiguration
|
The context information for configuring the rule validator. |
required |
feedback |
ValidationFeedback
|
Feedback object for reporting progress. |
required |
Returns:
Type | Description |
---|---|
BaseRuleValidator
|
An instance of the specific rule validator. |
Source code in src/cplus_plugin/lib/validation/validators.py
finished
Depending on the outcome of the validation process,
validation_completed
signal will be emitted only if the
validation was successful. The result
attribute will also contain the
validation result object. If an error occurred during the validation
process, the validation result object will be None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
bool
|
True if the validation process was successful, else False. |
required |
Source code in src/cplus_plugin/lib/validation/validators.py
log
Convenience function that logs the given messages by appending the information for the validator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Message to be logged. |
required |
info |
bool
|
False if the message should be logged as a warning else True if information. |
True
|
Source code in src/cplus_plugin/lib/validation/validators.py
rule_validators
staticmethod
Returns all the rule validator classes, any new validator type needs to be added here.
The validator classes are indexed by their corresponding rule type enum.
Returns:
Type | Description |
---|---|
dict
|
Collection containing rule validator classes indexed by their corresponding rule types. |
Source code in src/cplus_plugin/lib/validation/validators.py
run
Initiates the validation process based on the specified validators and returns a result indicating whether the process succeeded or failed.
Returns:
Type | Description |
---|---|
bool
|
True if the validation process succeeded or False if it failed. |
Source code in src/cplus_plugin/lib/validation/validators.py
validator_cls_by_type
staticmethod
Gets the rule validator class based on the corresponding rule type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_type |
RuleType
|
The type of the validator rule. |
required |
Returns:
Type | Description |
---|---|
BaseRuleValidator
|
The rule validator class corresponding to the given rule type. |
Source code in src/cplus_plugin/lib/validation/validators.py
NcsDataValidator
Bases: DataValidator
Validates both NCS pathway and carbon layer datasets. The resolution check for carbon layers is tagged as a warning rather than an error.
Source code in src/cplus_plugin/lib/validation/validators.py
NoDataValueValidator
Bases: BaseRuleValidator
Checks if applicable input datasets have the same no data value.
Source code in src/cplus_plugin/lib/validation/validators.py
rule_type
property
Returns the no data value rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
No data value rule validator. |
ProjectedCrsValidator
Bases: BaseRuleValidator
Checks if the input datasets have a projected CRS.
Source code in src/cplus_plugin/lib/validation/validators.py
rule_type
property
Returns the projected CRS rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
Projected CRS rule validator. |
RasterValidator
Bases: BaseRuleValidator
Checks if the input datasets are raster layers.
Source code in src/cplus_plugin/lib/validation/validators.py
rule_type
property
Returns the raster type rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
Raster type rule validator. |
ResolutionValidator
Bases: BaseRuleValidator
Checks if datasets have the same spatial resolution.
Source code in src/cplus_plugin/lib/validation/validators.py
rule_type
property
Returns the no data value rule validator.
Returns:
Type | Description |
---|---|
RuleType
|
No data value rule validator. |
create_resolution_definition
classmethod
Creates a resolution definition tuple from a layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
QgsRasterLayer
|
Input layer. |
required |
Returns:
Type | Description |
---|---|
tuple
|
Tuple containing x and y resolutions as well as the units. |
Source code in src/cplus_plugin/lib/validation/validators.py
resolution_definition_to_str
classmethod
Formats the resolution definition to a friendly-display string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resolution_definition |
tuple
|
Tuple containing x and y resolutions as well as the units. |
required |
Returns:
Type | Description |
---|---|
str
|
Friendly display string. |