geonature.core.gn_meta.mtd

Submodules

Package Contents

Classes

CorAcquisitionFrameworkActor

The base class of the SQLAlchemy.Model declarative model class.

CorDatasetActor

The base class of the SQLAlchemy.Model declarative model class.

TAcquisitionFramework

The base class of the SQLAlchemy.Model declarative model class.

MTDInstanceApi

INPNCAS

Functions

insert_user_and_org(info_user[, update_user_organism])

associate_actors(actors, CorActor, pk_name, pk_value)

Associate actor and DS or AF according to CorActor value.

sync_af(af)

Will update a given AF (Acquisition Framework) if already exists in database according to UUID, else update the AF.

sync_ds(ds, cd_nomenclatures)

Will create or update a given DS according to UUID.

parse_acquisition_framework(ca)

parse_acquisition_framwork_xml(xml)

Parse an xml of AF from a string

parse_jdd_xml(xml)

Parse an xml of datasets from a string

add_unexisting_digitizer(id_digitizer)

Method to trigger global MTD sync.

process_af_and_ds(af_list, ds_list[, id_role])

Synchro AF<array>, Synchro DS<array>

sync_af_and_ds()

Method to trigger global MTD sync.

sync_af_and_ds_by_user(id_role[, id_af])

Method to trigger MTD sync on user authentication.

Attributes

config

logger

handler

formatter

geonature.core.gn_meta.mtd.insert_user_and_org(info_user, update_user_organism: bool = True)[source]
class geonature.core.gn_meta.mtd.CorAcquisitionFrameworkActor[source]

Bases: geonature.utils.env.DB.Model

The base class of the SQLAlchemy.Model declarative model class.

To define models, subclass db.Model, not this. To customize db.Model, subclass this and pass it as model_class to SQLAlchemy. To customize db.Model at the metaclass level, pass an already created declarative model class as model_class.

__tablename__ = 'cor_acquisition_framework_actor'
__table_args__
id_cafa
id_acquisition_framework
id_role
id_organism
id_nomenclature_actor_role
nomenclature_actor_role
role
organism
class geonature.core.gn_meta.mtd.CorDatasetActor[source]

Bases: geonature.utils.env.DB.Model

The base class of the SQLAlchemy.Model declarative model class.

To define models, subclass db.Model, not this. To customize db.Model, subclass this and pass it as model_class to SQLAlchemy. To customize db.Model at the metaclass level, pass an already created declarative model class as model_class.

__tablename__ = 'cor_dataset_actor'
__table_args__
id_cda
id_dataset
id_role
id_organism
id_nomenclature_actor_role
nomenclature_actor_role
role
organism
actor()[source]
display()[source]
class geonature.core.gn_meta.mtd.TAcquisitionFramework[source]

Bases: geonature.core.gn_meta.models.commons.db.Model

The base class of the SQLAlchemy.Model declarative model class.

To define models, subclass db.Model, not this. To customize db.Model, subclass this and pass it as model_class to SQLAlchemy. To customize db.Model at the metaclass level, pass an already created declarative model class as model_class.

__tablename__ = 't_acquisition_frameworks'
__table_args__
id_acquisition_framework
unique_acquisition_framework_id
acquisition_framework_name
acquisition_framework_desc
id_nomenclature_territorial_level
territory_desc
keywords
id_nomenclature_financing_type
target_description
ecologic_or_geologic_target
acquisition_framework_parent_id
is_parent
opened
id_digitizer
acquisition_framework_start_date
acquisition_framework_end_date
meta_create_date
meta_update_date
initial_closing_date
creator
nomenclature_territorial_level
nomenclature_financing_type
cor_af_actor
cor_objectifs
cor_volets_sinp
cor_territories
bibliographical_references
t_datasets
datasets
user_actors()[source]
organism_actors()[source]
is_deletable()[source]
has_instance_permission(scope, _through_ds=True)[source]
static get_id(uuid_af)[source]

return the acquisition framework’s id from its UUID if exist or None

static get_user_af(user, only_query=False, only_user=False)[source]

get the af(s) where the user is actor (himself or with its organism - only himelsemf id only_use=True) or digitizer param:

  • user from TRole model

  • only_query: boolean (return the query not the id_datasets allowed if true)

  • only_user: boolean: return only the dataset where user himself is actor (not with its organoism)

return: a list of id_dataset or a query

classmethod _get_read_scope(user=None)[source]
classmethod filter_by_scope(scope, *, query, user=None)[source]
classmethod filter_by_readable(*, query, user=None)[source]

Return the afs where the user has autorization via its CRUVED

classmethod filter_by_areas(areas, *, query)[source]

Filter meta by areas

classmethod filter_by_params(params={}, *, _ds_search=True, query=None)[source]
geonature.core.gn_meta.mtd.config[source]
geonature.core.gn_meta.mtd.associate_actors(actors, CorActor, pk_name, pk_value)[source]

Associate actor and DS or AF according to CorActor value.

Parameters

actorslist

list of actors

CorActordb.Model

table model

pk_namestr

pk attribute name

pk_valuestr

pk value

geonature.core.gn_meta.mtd.sync_af(af)[source]

Will update a given AF (Acquisition Framework) if already exists in database according to UUID, else update the AF.

Parameters

afdict

AF infos.

Returns

TAcquisitionFramework

The updated or inserted acquisition framework.

geonature.core.gn_meta.mtd.sync_ds(ds, cd_nomenclatures)[source]

Will create or update a given DS according to UUID. Only process DS if dataset’s cd_nomenclatures exists in ref_normenclatures.t_nomenclatures.

Paramètres:
  • ds – <dict> DS infos

  • cd_nomenclatures – <array> cd_nomenclature from ref_normenclatures.t_nomenclatures

geonature.core.gn_meta.mtd.parse_acquisition_framework(ca)[source]
geonature.core.gn_meta.mtd.parse_acquisition_framwork_xml(xml)[source]

Parse an xml of AF from a string Return:

dict: a dict of the parsed xml

geonature.core.gn_meta.mtd.parse_jdd_xml(xml)[source]

Parse an xml of datasets from a string Return:

list: a list of dict of the JDD in the xml

geonature.core.gn_meta.mtd.logger[source]
geonature.core.gn_meta.mtd.handler[source]
geonature.core.gn_meta.mtd.formatter[source]
class geonature.core.gn_meta.mtd.MTDInstanceApi(api_endpoint, instance_id, id_role=None)[source]
af_path = '/mtd/cadre/export/xml/GetRecordsByInstanceId?id={ID_INSTANCE}'[source]
ds_path = '/mtd/cadre/jdd/export/xml/GetRecordsByInstanceId?id={ID_INSTANCE}'[source]
ds_user_path = '/mtd/cadre/jdd/export/xml/GetRecordsByUserId?id={ID_ROLE}'[source]
af_user_path = '/mtd/cadre/export/xml/GetRecordsByUserId?id={ID_ROLE}'[source]
single_af_path = '/mtd/cadre/export/xml/GetRecordById?id={ID_AF}'[source]
_get_xml_by_url(url)[source]
_get_xml(path)[source]
_get_af_xml()[source]
get_af_list()[source]
_get_ds_xml()[source]
get_ds_list()[source]
get_ds_user_list()[source]

Retrieve the list of of datasets (ds) for the user.

Returns

list

A list of datasets (ds) for the user.

get_list_af_for_user()[source]

Retrieve a list of acquisition frameworks (af) for the user.

Returns

list

A list of acquisition frameworks for the user.

get_single_af(af_uuid)[source]

Return a single acquistion framework based on its uuid.

Parameters

af_uuidstr

uuid of the acquisition framework

Returns

dict

acquisition framework data

class geonature.core.gn_meta.mtd.INPNCAS[source]
base_url[source]
user[source]
password[source]
id_search_path = 'rechercheParId/{user_id}'[source]
classmethod _get_user_json(user_id)[source]
classmethod get_user(user_id)[source]
geonature.core.gn_meta.mtd.add_unexisting_digitizer(id_digitizer)[source]

Method to trigger global MTD sync.

Paramètres:

id_digitizer – as id role from meta info

geonature.core.gn_meta.mtd.process_af_and_ds(af_list, ds_list, id_role=None)[source]

Synchro AF<array>, Synchro DS<array>

Paramètres:
  • af_list – list af

  • ds_list – list ds

  • id_role – use role id pass on user authent only

geonature.core.gn_meta.mtd.sync_af_and_ds()[source]

Method to trigger global MTD sync.

geonature.core.gn_meta.mtd.sync_af_and_ds_by_user(id_role, id_af=None)[source]

Method to trigger MTD sync on user authentication.

Args:

id_role (int): The ID of the role (group or user). id_af (str, optional): The ID of the AF (Acquisition Framework). Defaults to None.