geonature.core.imports.checks.sql.extra#

Functions#

check_referential(→ None)

Check the referential integrity of a column in the transient table.

check_cd_nom(→ None)

Check the existence of a cd_nom in the Taxref referential.

check_cd_hab(→ None)

Check the existence of a cd_hab in the Habref referential.

generate_altitudes(→ None)

Generate the altitudes based on geomatries, and given altitues in an import.

check_duplicate_uuid(imprt, entity, uuid_field)

Check if there is already a record with the same uuid in the transient table. Include an error in the report for each entry with a uuid dupplicated.

check_existing_uuid(imprt, entity, uuid_field[, ...])

Check if there is already a record with the same uuid in the destination table.

generate_missing_uuid_for_id_origin(imprt, uuid_field, ...)

Update records in the transient table where the uuid is None

generate_missing_uuid(imprt, entity, uuid_field[, ...])

Update records in the transient table where the UUID is None

check_duplicate_source_pk(→ None)

Check for duplicate source primary keys in the transient table of an import.

check_dates(→ None)

Check the validity of dates in the transient table of an import.

check_altitudes(→ None)

Check the validity of altitudes in the transient table of an import.

check_depths(→ None)

Check the validity of depths in the transient table of an import.

check_digital_proof_urls(imprt, entity, ...)

Checks for valid URLs in a given column of a transient table.

check_entity_data_consistency(imprt, entity, fields, ...)

Checks for rows with the same uuid, but different contents,

disable_duplicated_rows(imprt, entity, fields, ...)

When several rows have the same value in grouping field (typically UUID) field,

Module Contents#

geonature.core.imports.checks.sql.extra.check_referential(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, field: geonature.core.imports.models.BibFields, reference_field: sqlalchemy.Column, error_type: str, reference_table: sqlalchemy.Table | None = None) None[source]#

Check the referential integrity of a column in the transient table.

Parameters#

imprtTImports

The import to check.

entityEntity

The entity to check.

fieldBibFields

The field to check.

reference_fieldBibFields

The reference field to check.

error_typestr

The type of error encountered.

reference_tableOptional[sa.Table], optional

The reference table to check. If not provided, it will be inferred from the reference_field.

geonature.core.imports.checks.sql.extra.check_cd_nom(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, field: geonature.core.imports.models.BibFields, list_id: int | None = None) None[source]#

Check the existence of a cd_nom in the Taxref referential.

Parameters#

imprtTImports

The import to check.

entityEntity

The entity to check.

fieldBibFields

The field to check.

list_idOptional[int], optional

The list to filter on, by default None.

geonature.core.imports.checks.sql.extra.check_cd_hab(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, field: geonature.core.imports.models.BibFields) None[source]#

Check the existence of a cd_hab in the Habref referential.

Parameters#

imprtTImports

The import to check.

entityEntity

The entity to check.

fieldBibFields

The field to check.

geonature.core.imports.checks.sql.extra.generate_altitudes(imprt: geonature.core.imports.models.TImports, geom_local_field: geonature.core.imports.models.BibFields, alt_min_field: geonature.core.imports.models.BibFields, alt_max_field: geonature.core.imports.models.BibFields) None[source]#

Generate the altitudes based on geomatries, and given altitues in an import.

Parameters#

imprtTImports

The import to generate altitudes for.

geom_local_fieldBibFields

The field representing the geometry in the destination import’s transient table.

alt_min_fieldBibFields

The field representing the minimum altitude in the destination import’s transient table.

alt_max_fieldBibFields

The field representing the maximum altitude in the destination import’s transient table.

geonature.core.imports.checks.sql.extra.check_duplicate_uuid(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, uuid_field: geonature.core.imports.models.BibFields)[source]#

Check if there is already a record with the same uuid in the transient table. Include an error in the report for each entry with a uuid dupplicated.

Parameters#

imprtImport

The import to check.

entityEntity

The entity to check.

uuid_fieldBibFields

The field to check.

geonature.core.imports.checks.sql.extra.check_existing_uuid(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, uuid_field: geonature.core.imports.models.BibFields, whereclause: Any = sa.true(), skip=False)[source]#

Check if there is already a record with the same uuid in the destination table. Include an error in the report for each existing uuid in the destination table. Parameters ———- imprt : Import

The import to check.

entityEntity

The entity to check.

uuid_fieldBibFields

The field to check.

whereclauseBooleanClause

The WHERE clause to apply to the check.

skip: Boolean

Raise SKIP_EXISTING_UUID instead of EXISTING_UUID and set row validity to None (do not import)

geonature.core.imports.checks.sql.extra.generate_missing_uuid_for_id_origin(imprt: geonature.core.imports.models.TImports, uuid_field: geonature.core.imports.models.BibFields, id_origin_field: geonature.core.imports.models.BibFields)[source]#

Update records in the transient table where the uuid is None with a new UUID. Generate UUID in transient table when there are no UUID yet, but there are a id_origin. Ensure rows with same id_origin get the same UUID.

Parameters#

imprtTImports

The import to check.

uuid_fieldBibFields

The field to check.

id_origin_fieldBibFields

Field used to generate the UUID

geonature.core.imports.checks.sql.extra.generate_missing_uuid(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, uuid_field: geonature.core.imports.models.BibFields, whereclause: Any = None)[source]#

Update records in the transient table where the UUID is None with a new UUID.

Parameters#

imprtTImports

The import to check.

entityEntity

The entity to check.

uuid_fieldBibFields

The field to check.

geonature.core.imports.checks.sql.extra.check_duplicate_source_pk(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, field: geonature.core.imports.models.BibFields) None[source]#

Check for duplicate source primary keys in the transient table of an import.

Parameters#

imprtTImports

The import to check.

entityEntity

The entity to check.

fieldBibFields

The field to check.

geonature.core.imports.checks.sql.extra.check_dates(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, date_min_field: geonature.core.imports.models.BibFields = None, date_max_field: geonature.core.imports.models.BibFields = None) None[source]#

Check the validity of dates in the transient table of an import.

Parameters#

imprtTImports

The import to check.

entityTEntity

The entity to check.

date_min_fieldBibFields, optional

The field representing the minimum date.

date_max_fieldBibFields, optional

The field representing the maximum date.

geonature.core.imports.checks.sql.extra.check_altitudes(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, alti_min_field: geonature.core.imports.models.BibFields = None, alti_max_field: geonature.core.imports.models.BibFields = None) None[source]#

Check the validity of altitudes in the transient table of an import.

Parameters#

imprtTImports

The import to check.

entityTEntity

The entity to check.

alti_min_fieldBibFields, optional

The field representing the minimum altitude.

alti_max_fieldBibFields, optional

The field representing the maximum altitude.

geonature.core.imports.checks.sql.extra.check_depths(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, depth_min_field: geonature.core.imports.models.BibFields = None, depth_max_field: geonature.core.imports.models.BibFields = None) None[source]#

Check the validity of depths in the transient table of an import.

Parameters#

imprtTImports

The import to check.

entityTEntity

The entity to check.

depth_min_fieldBibFields, optional

The field representing the minimum depth.

depth_max_fieldBibFields, optional

The field representing the maximum depth.

geonature.core.imports.checks.sql.extra.check_digital_proof_urls(imprt, entity, digital_proof_field)[source]#

Checks for valid URLs in a given column of a transient table.

Parameters#

imprtTImports

The import to check.

entityTEntity

The entity to check.

digital_proof_fieldTField

The field containing the URLs to check.

geonature.core.imports.checks.sql.extra.check_entity_data_consistency(imprt, entity, fields, grouping_field)[source]#

Checks for rows with the same uuid, but different contents, in the same entity. Used mainely for parent entities. Parameters ———- imprt : TImports

The import to check.

entityEntity

The entity to check.

fieldsBibFields

The fields to check.

grouping_fieldBibFields

The field to group identical rows.

geonature.core.imports.checks.sql.extra.disable_duplicated_rows(imprt, entity, fields, grouping_field)[source]#

When several rows have the same value in grouping field (typically UUID) field, first one is untouched but following rows have validity set to None (do not import).