geonode.resource.manager ======================== .. py:module:: geonode.resource.manager Attributes ---------- .. autoapisummary:: geonode.resource.manager.logger geonode.resource.manager.resource_manager Classes ------- .. autoapisummary:: geonode.resource.manager.ResourceManagerInterface geonode.resource.manager.ResourceManager Module Contents --------------- .. py:data:: logger .. py:class:: ResourceManagerInterface .. py:method:: search(filter: dict, /, resource_type: Optional[object]) -> django.db.models.query.QuerySet :abstractmethod: Returns a QuerySet of the filtered resources into the DB. - The 'filter' parameter should be an dictionary with the filtering criteria; - 'filter' = None won't return any result - 'filter' = {} will return the whole set - The 'resource_type' parameter allows to specify the concrete resource model (e.g. Dataset, Document, Map, ...) - 'resource_type' must be a class - 'resource_type' = Dataset will return a set of the only available Layers .. py:method:: exists(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> bool :abstractmethod: Returns 'True' or 'False' if the resource exists or not. - If 'instance' is provided, it will take precedence on 'uuid' - The existance criteria might be subject to the 'concrete resource manager' one, dependent on the resource type e.g.: a local Dataset existance check will be constrained by the existance of the layer on the GIS backend .. py:method:: delete(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> int :abstractmethod: Deletes a resource from the DB. - If 'instance' is provided, it will take precedence on 'uuid' - It will also fallback to the 'concrete resource manager' delete model. - This will eventually delete the related resources on the GIS backend too. .. py:method:: create(uuid: str, /, resource_type: Optional[object] = None, defaults: dict = {}) -> geonode.base.models.ResourceBase :abstractmethod: The method will just create a new 'resource_type' on the DB model and invoke the 'post save' triggers. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. - It is possible to pass initial default values, like the 'files' from the 'storage_manager' trhgouh the 'defaults' dictionary .. py:method:: update(uuid: str, /, instance: geonode.base.models.ResourceBase = None, xml_file: str = None, metadata_uploaded: bool = False, vals: dict = {}, regions: dict = {}, keywords: dict = {}, custom: dict = {}, notify: bool = True) -> geonode.base.models.ResourceBase :abstractmethod: The method will update an existing 'resource_type' on the DB model and invoke the 'post save' triggers. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. - It is possible to pass initial default values, like the 'files' from the 'storage_manager' trhgouh the 'vals' dictionary - The 'xml_file' parameter allows to fetch metadata values from a file - The 'notify' parameter allows to notify the members that the resource has been updated .. py:method:: ingest(files: List[str], /, uuid: str = None, resource_type: Optional[object] = None, defaults: dict = {}, **kwargs) -> geonode.base.models.ResourceBase :abstractmethod: The method allows to create a resource by providing the list of files. e.g.: In [1]: from geonode.resource.manager import resource_manager In [2]: from geonode.layers.models import Dataset In [3]: from django.contrib.auth import get_user_model In [4]: admin = get_user_model().objects.get(username='admin') In [5]: files = ["/.../san_andres_y_providencia_administrative.dbf", "/.../san_andres_y_providencia_administrative.prj", ...: "/.../san_andres_y_providencia_administrative.shx", "/.../san_andres_y_providencia_administrative.sld", "/.../san_andres_y_providencia_administrative.shp"] In [6]: resource_manager.ingest(files, resource_type=Dataset, defaults={'owner': admin}) .. py:method:: copy(instance: geonode.base.models.ResourceBase, /, uuid: str = None, owner: django.conf.settings.AUTH_USER_MODEL = None, defaults: dict = {}) -> geonode.base.models.ResourceBase :abstractmethod: The method makes a copy of the existing resource. - It makes a copy of the files - It creates a new layer on the GIS backend in the case the ResourceType is a Dataset .. py:method:: append(instance: geonode.base.models.ResourceBase, vals: dict = {}) -> geonode.base.models.ResourceBase :abstractmethod: The method appends data to an existing resource. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. .. py:method:: replace(instance: geonode.base.models.ResourceBase, vals: dict = {}) -> geonode.base.models.ResourceBase :abstractmethod: The method replaces data of an existing resource. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. .. py:method:: exec(method: str, uuid: str, /, instance: geonode.base.models.ResourceBase = None, **kwargs) -> geonode.base.models.ResourceBase :abstractmethod: A generic 'exec' method allowing to invoke specific methods of the concrete resource manager not exposed by the interface. - The parameter 'method' represents the actual name of the concrete method to invoke. .. py:method:: remove_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> bool :abstractmethod: Completely cleans the permissions of a resource, resetting it to the default state (owner only) .. py:method:: set_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None, owner: django.conf.settings.AUTH_USER_MODEL = None, permissions: dict = {}, created: bool = False, approval_status_changed: bool = False, group_status_changed: bool = False) -> bool :abstractmethod: Sets the permissions of a resource. - It optionally gets a JSON 'perm_spec' through the 'permissions' parameter - If no 'perm_spec' is provided, it will set the default permissions (owner only) .. py:method:: set_thumbnail(uuid: str, /, instance: geonode.base.models.ResourceBase = None, overwrite: bool = True, check_bbox: bool = True) -> bool :abstractmethod: Allows to generate or re-generate the Thumbnail of a Resource. .. py:class:: ResourceManager(concrete_manager=None) Bases: :py:obj:`ResourceManagerInterface` .. py:attribute:: _concrete_resource_manager .. py:method:: _get_concrete_manager() .. py:method:: _get_instance(uuid: str) -> geonode.base.models.ResourceBase :classmethod: .. py:method:: search(filter: dict, /, resource_type: Optional[object]) -> django.db.models.query.QuerySet Returns a QuerySet of the filtered resources into the DB. - The 'filter' parameter should be an dictionary with the filtering criteria; - 'filter' = None won't return any result - 'filter' = {} will return the whole set - The 'resource_type' parameter allows to specify the concrete resource model (e.g. Dataset, Document, Map, ...) - 'resource_type' must be a class - 'resource_type' = Dataset will return a set of the only available Layers .. py:method:: exists(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> bool Returns 'True' or 'False' if the resource exists or not. - If 'instance' is provided, it will take precedence on 'uuid' - The existance criteria might be subject to the 'concrete resource manager' one, dependent on the resource type e.g.: a local Dataset existance check will be constrained by the existance of the layer on the GIS backend .. py:method:: delete(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> int Deletes a resource from the DB. - If 'instance' is provided, it will take precedence on 'uuid' - It will also fallback to the 'concrete resource manager' delete model. - This will eventually delete the related resources on the GIS backend too. .. py:method:: create(uuid: str, /, resource_type: Optional[object] = None, defaults: dict = {}) -> geonode.base.models.ResourceBase The method will just create a new 'resource_type' on the DB model and invoke the 'post save' triggers. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. - It is possible to pass initial default values, like the 'files' from the 'storage_manager' trhgouh the 'defaults' dictionary .. py:method:: update(uuid: str, /, instance: geonode.base.models.ResourceBase = None, xml_file: str = None, metadata_uploaded: bool = False, vals: dict = {}, regions: list = [], keywords: list = [], custom: dict = {}, notify: bool = True, extra_metadata: list = [], *args, **kwargs) -> geonode.base.models.ResourceBase The method will update an existing 'resource_type' on the DB model and invoke the 'post save' triggers. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. - It is possible to pass initial default values, like the 'files' from the 'storage_manager' trhgouh the 'vals' dictionary - The 'xml_file' parameter allows to fetch metadata values from a file - The 'notify' parameter allows to notify the members that the resource has been updated .. py:method:: ingest(files: List[str], /, uuid: str = None, resource_type: Optional[object] = None, defaults: dict = {}, **kwargs) -> geonode.base.models.ResourceBase The method allows to create a resource by providing the list of files. e.g.: In [1]: from geonode.resource.manager import resource_manager In [2]: from geonode.layers.models import Dataset In [3]: from django.contrib.auth import get_user_model In [4]: admin = get_user_model().objects.get(username='admin') In [5]: files = ["/.../san_andres_y_providencia_administrative.dbf", "/.../san_andres_y_providencia_administrative.prj", ...: "/.../san_andres_y_providencia_administrative.shx", "/.../san_andres_y_providencia_administrative.sld", "/.../san_andres_y_providencia_administrative.shp"] In [6]: resource_manager.ingest(files, resource_type=Dataset, defaults={'owner': admin}) .. py:method:: copy(instance: geonode.base.models.ResourceBase, /, uuid: str = None, owner: django.conf.settings.AUTH_USER_MODEL = None, defaults: dict = {}) -> geonode.base.models.ResourceBase The method makes a copy of the existing resource. - It makes a copy of the files - It creates a new layer on the GIS backend in the case the ResourceType is a Dataset .. py:method:: append(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs) The method appends data to an existing resource. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. .. py:method:: replace(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs) The method replaces data of an existing resource. - It assumes any GIS backend resource (e.g. layers on GeoServer) already exist. .. py:method:: _validate_resource(instance: geonode.base.models.ResourceBase, action_type: str) -> bool .. py:method:: exec(method: str, uuid: str, /, instance: geonode.base.models.ResourceBase = None, **kwargs) -> geonode.base.models.ResourceBase A generic 'exec' method allowing to invoke specific methods of the concrete resource manager not exposed by the interface. - The parameter 'method' represents the actual name of the concrete method to invoke. .. py:method:: remove_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None) -> bool Remove object permissions on given resource. If is a layer removes the layer specific permissions then the resourcebase permissions. .. py:method:: set_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None, owner: django.conf.settings.AUTH_USER_MODEL = None, permissions: dict = {}, created: bool = False, approval_status_changed: bool = False, group_status_changed: bool = False) -> bool Sets the permissions of a resource. - It optionally gets a JSON 'perm_spec' through the 'permissions' parameter - If no 'perm_spec' is provided, it will set the default permissions (owner only) .. py:method:: set_thumbnail(uuid: str, /, instance: geonode.base.models.ResourceBase = None, overwrite: bool = True, check_bbox: bool = True, thumbnail=None) -> bool Allows to generate or re-generate the Thumbnail of a Resource. .. py:data:: resource_manager