geonature.core.imports.models

Contenu

geonature.core.imports.models#

Attributes#

Classes#

Functions#

optional_conditions_to_jsonschema(→ dict)

Convert optional conditions into a JSON schema.

get_fields_of_an_entity(→ List[BibFields])

Get all BibFields associated with a given entity.

Module Contents#

class geonature.core.imports.models.ImportModule[source]#

Bases: geonature.core.gn_commons.models.TModules

__mapper_args__[source]#
generate_module_url_for_source(source)[source]#
class geonature.core.imports.models.ImportUserErrorType[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'bib_errors_types'[source]#
__table_args__[source]#
pk[source]#
category[source]#
name[source]#
description[source]#
level[source]#
__str__()[source]#
class geonature.core.imports.models.ImportUserError[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 't_user_errors'[source]#
__table_args__[source]#
pk[source]#
id_import[source]#
imprt[source]#
id_type[source]#
type[source]#
column[source]#
rows[source]#
comment[source]#
id_entity[source]#
entity[source]#
__str__()[source]#
class geonature.core.imports.models.Destination[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'bib_destinations'[source]#
__table_args__[source]#
id_destination[source]#
id_module[source]#
code[source]#
label[source]#
table_name[source]#
module[source]#
entities[source]#
get_transient_table()[source]#
property validity_columns[source]#
property statistics_labels[source]#
property actions[source]#
static allowed_destinations(user: pypnusershub.db.models.User | None = None, action_code: str = 'C') List[Destination][source]#

Return a list of allowed destinations for a given user and an action.

Parameters#

userUser, optional

The user to filter destinations for. If not provided, the current_user is used.

actionstr

The action to filter destinations for. Possible values are “C”, “R”, “U”, “V”, “E”, “D”.

Returns#

allowed_destinationList of Destination

List of allowed destinations for the given user.

filter_by_role(user: pypnusershub.db.models.User | None = None, action_code: str = 'C', **kwargs)[source]#

Filter Destination by role.

Parameters#

userUser, optional

The user to filter destinations for. If not provided, the current_user is used.

Returns#

sqlalchemy.sql.elements.BinaryExpression

A filter criterion for the id_destination column of the Destination table.

has_instance_permission(user: pypnusershub.db.models.User | None = None, action_code: str = 'C')[source]#

Check if a user has the permissions to do an action on this destination.

Parameters#

userUser, optional

The user to check the permission for. If not provided, the current_user is used.

action_codestr

The action to check the permission for. Possible values are “C”, “R”, “U”, “V”, “E”, “D”.

Returns#

bool

True if the user has the right to do the action on this destination, False otherwise.

class geonature.core.imports.models.BibThemes[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'bib_themes'[source]#
__table_args__[source]#
id_theme[source]#
name_theme[source]#
fr_label_theme[source]#
eng_label_theme[source]#
desc_theme[source]#
order_theme[source]#
class geonature.core.imports.models.EntityField[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'cor_entity_field'[source]#
__table_args__[source]#
id_entity[source]#
entity[source]#
id_field[source]#
field[source]#
desc_field[source]#
id_theme[source]#
theme[source]#
order_field[source]#
comment[source]#
class geonature.core.imports.models.Entity[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'bib_entities'[source]#
__table_args__[source]#
id_entity[source]#
id_destination[source]#
destination[source]#
code[source]#
label[source]#
order[source]#
validity_column[source]#
destination_table_schema[source]#
destination_table_name[source]#
id_unique_column[source]#
id_parent[source]#
parent[source]#
childs[source]#
fields[source]#
unique_column[source]#
get_destination_table()[source]#
class geonature.core.imports.models.InstancePermissionMixin[source]#
get_instance_permissions(scopes, user=None)[source]#
geonature.core.imports.models.cor_role_import[source]#
class geonature.core.imports.models.TImports[source]#

Bases: InstancePermissionMixin, geonature.utils.env.db.Model

__tablename__ = 't_imports'[source]#
__table_args__[source]#
AVAILABLE_ENCODINGS[source]#
AVAILABLE_FORMATS = ['csv', 'geojson'][source]#
AVAILABLE_SEPARATORS = [',', ';'][source]#
id_import[source]#
id_destination[source]#
destination[source]#
format_source_file[source]#
srid[source]#
separator[source]#
detected_separator[source]#
encoding[source]#
detected_encoding[source]#
full_file_name[source]#
id_dataset[source]#
date_create_import[source]#
date_update_import[source]#
date_end_import[source]#
source_count[source]#
erroneous_rows[source]#
statistics[source]#
date_min_data[source]#
date_max_data[source]#
uuid_autogenerated[source]#
altitude_autogenerated[source]#
authors[source]#
loaded[source]#
processed[source]#
dataset[source]#
source_file[source]#
columns[source]#
fieldmapping[source]#
contentmapping[source]#
task_id[source]#
errors[source]#
property cruved[source]#
errors_count[source]#
property task_progress[source]#
has_instance_permission(scope, user=None, action_code='C')[source]#
static filter_by_scope(scope, user=None, **kwargs)[source]#
as_dict(import_as_dict)[source]#
class geonature.core.imports.models.BibFields[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 'bib_fields'[source]#
__table_args__[source]#
id_field[source]#
id_destination[source]#
destination[source]#
name_field[source]#
source_field[source]#
dest_field[source]#
fr_label[source]#
eng_label[source]#
type_field[source]#
mandatory[source]#
autogenerated[source]#
mnemonique[source]#
nomenclature_type[source]#
display[source]#
multi[source]#
optional_conditions[source]#
mandatory_conditions[source]#
entities[source]#
property source_column[source]#
property dest_column[source]#
__str__()[source]#
geonature.core.imports.models.cor_role_mapping[source]#
class geonature.core.imports.models.MappingTemplate[source]#

Bases: geonature.utils.env.db.Model

__tablename__ = 't_mappings'[source]#
__table_args__[source]#
id[source]#
id_destination[source]#
destination[source]#
label[source]#
type[source]#
active[source]#
public[source]#
property cruved[source]#
__mapper_args__[source]#
owners[source]#
has_instance_permission(scope: int, user=None)[source]#
static filter_by_scope(scope, user=None)[source]#
geonature.core.imports.models.optional_conditions_to_jsonschema(name_field: str, optional_conditions: Iterable[str]) dict[source]#

Convert optional conditions into a JSON schema.

Parameters#

name_fieldstr

The name of the field.

optional_conditionsIterable[str]

The optional conditions.

Returns#

dict

The JSON schema.

Notes#

The JSON schema is created to ensure that if any of the optional conditions is not provided, the name_field is required.

geonature.core.imports.models.get_fields_of_an_entity(entity: Entity, columns: List[str] | None = None, optional_where_clause: Any | None = None) List[BibFields][source]#

Get all BibFields associated with a given entity.

Parameters#

entityEntity

The entity to get the fields for.

columnsOptional[List[str]], optional

The columns to retrieve. If None, all columns are retrieved.

optional_where_clauseOptional[Any], optional

An optional where clause to apply to the query.

Returns#

List[BibFields]

The BibFields associated with the given entity.

class geonature.core.imports.models.FieldMapping[source]#

Bases: MappingTemplate

__tablename__ = 't_fieldmappings'[source]#
__table_args__[source]#
id[source]#
values[source]#
__mapper_args__[source]#
static validate_values(field_mapping_json)[source]#

Validate the field mapping values returned by the client form.

Parameters#

field_mapping_jsondict

The field mapping values.

Raises#

ValueError

If the field mapping values are invalid.

class geonature.core.imports.models.ContentMapping[source]#

Bases: MappingTemplate

__tablename__ = 't_contentmappings'[source]#
__table_args__[source]#
id[source]#
values[source]#
__mapper_args__[source]#
static validate_values(values)[source]#