-
Notifications
You must be signed in to change notification settings - Fork 3
Trade Validation Rules
All the validations are stored in a STI structure:
CREATE TABLE trade_validation_rules
(
id serial NOT NULL,
valid_values_view character varying(255),
type character varying(255) NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
format_re character varying(255),
run_order integer NOT NULL,
column_names character varying(255)[],
is_primary boolean NOT NULL DEFAULT true,
scope hstore,
CONSTRAINT trade_validation_rules_pkey PRIMARY KEY (id)
)
Returns records where the specified columns are NULL. In case more than one column is specified, predicates are combined using AND.
Required fields in STI structure:
- column_names
Columns validated for presence:
- TRADING_PARTNER
- TERM_CODE
- SPECIES_NAME
- APPENDIX
- QUANTITY
Returns records that do not pass the ISNUMERIC test for all columns specified in column_names.
Required fields in STI structure:
- column_names
Columns validated for numericality:
- YEAR
- QUANTITY
Returns records that do not pass the regex test for all columns specified in column_names.
Required fields in STI structure:
- column_names
- format_re
Columns validated for presence:
- YEAR
Returns records from sandbox where values in column_names are not included in valid_values_view. The valid_values_view should have the same column names and data types as the sandbox columns specified in column_names.
Columns | Valid values view | View def |
---|---|---|
TERM_CODE | valid_term_code_view |
|
SOURCE_CODE | valid_source_code_view |
|
PURPOSE_CODE | valid_purpose_code_view |
|
UNIT_CODE | valid_unit_code_view |
|
TRADING_PARTNER | valid_trading_partner_view |
|
COUNTRY_OF_ORIGIN | valid_country_of_origin_view |
|
SPECIES_NAME | valid_species_name_view |
|
APPENDIX | valid_appendix_view |
|
Returns records from sandbox where values in column_names are not included in valid_values_view. The valid_values_view should have the same column names and data types as the sandbox columns specified in column_names.
Columns | Scope | Valid values view | View def |
---|---|---|---|
[SPECIES_NAME, TERM_CODE] | valid_taxon_concept_term_view |
|
|
[TERM_CODE, UNIT_CODE] | valid_term_unit_view |
|
|
[TERM_CODE, PURPOSE_CODE] | valid_term_purpose_view |
|
|
[SPECIES_NAME, COUNTRY_OF_ORIGIN] | source_code = W | valid_species_name_country_of_origin_view |
|
(Point of View)
Columns | Scope | Valid values view | View def |
---|---|---|---|
[SPECIES_NAME, EXPORTER] | source_code = W, country_of_origin = NULL | valid_species_name_country_of_origin_view |
|
(Point of View)
Columns | Scope | Valid values view | View def |
---|---|---|---|
[EXPORTER, IMPORTER] |
|
||
[EXPORTER, COUNTRY_OF_ORIGIN] |
|
- Source_code D and Appendix II for reporting country not EU – (will need more thought on exact checks for this one)