# Path: invenio_records/systemfields/model.py
# class ModelField(SystemField):
#     """Model field for providing get and set access on a model field."""
# 
#     def __init__(self, model_field_name=None, dump=True, dump_key=None,
#                  dump_type=None):
#         """Initialize the field.
# 
#         :param model_field_name: Name of field on the database model.
#         :param dump: Set to false to not dump the field.
#         :param dump_key: The dictionary key to use in dumps.
#         :param dump_type: The data type used to determine how to serialize the
#             model field.
#         """
#         self._model_field_name = model_field_name
#         self.dump = dump
#         self._dump_key = dump_key
#         self._dump_type = dump_type
# 
#     #
#     # Helpers
#     #
#     @property
#     def model_field_name(self):
#         """The name of the SQLAlchemy field on the model.
# 
#         Defaults to the attribute name used on the class.
#         """
#         return self._model_field_name or self.attr_name
# 
#     @property
#     def dump_key(self):
#         """The dictionary key to use in dump output.
# 
#         Note, it's up to the dumper to choose if it respects this name.
#         The name defaults to the model field name.
#         """
#         return self._dump_key or self.model_field_name
# 
#     @property
#     def dump_type(self):
#         """The data type used to determine how to serialize the model field.
# 
#         Defaults to none, meaning the dumper will determine how to dump it.
#         """
#         return self._dump_type
# 
#     def _set(self, model, value):
#         """Internal method to set value on the model's field."""
#         setattr(model, self.model_field_name, value)
# 
#     #
#     # Data descriptor
#     #
#     def __get__(self, record, owner=None):
#         """Accessing the attribute."""
#         # Class access
#         if record is None:
#             return self
#         # Instance access
#         try:
#             return getattr(record.model, self.model_field_name)
#         except AttributeError:
#             return None
# 
#     def __set__(self, instance, value):
#         """Accessing the attribute."""
#         self._set(instance.model, value)
# 
#     #
#     # Record extension
#     #
#     def post_init(self, record, data, model=None, field_data=None):
#         """Initialise the model field."""
#         if field_data is not None:
#             self._set(model, field_data)
# 
# Path: invenio_records/dumpers/base.py
# class Dumper:
#     """Interface for dumpers."""
# 
#     def dump(self, record, data):
#         """Dump a record that can be used a source document for Elasticsearch.
# 
#         The job of this method is to create a Python dictionary from the record
#         provided in the argument.
# 
#         If you overwrite this method without calling super, then you should
#         ensure that you make a deep copy of the record dictionary, to avoid
#         that changes to the dump affects the record.
# 
#         :param record: The record to dump.
#         :param data: The initial dump data passed in by ``record.dumps()``.
#         """
#         data.update(deepcopy(dict(record)))
#         return data
# 
#     def load(self, data, record_cls):
#         """Load a record from the source document of an Elasticsearch hit.
# 
#         The job of this method, is to create a record of type ``record_cls``
#         based on the input ``data``.
# 
#         :param data: A Python dictionary representing the data to load.
#         :param records_cls: The record class to be constructed.
#         :returns: A instance of ``record_cls``.
#         """
#         raise NotImplementedError()


from copy import deepcopy
from datetime import date, datetime
from uuid import UUID
from sqlalchemy.sql.sqltypes import JSON, Boolean, DateTime, Integer, String, \
    Text
from sqlalchemy.sql.type_api import Variant
from sqlalchemy_utils.types.uuid import UUIDType
from ..systemfields.model import ModelField
from .base import Dumper
import arrow
import pytz
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Elasticsearch source dumper.

Dumper used to dump/load an the body of an Elasticsearch document.
"""





class ElasticsearchDumperExt:
    """Interface for Elasticsearch dumper extensions."""

    def dump(self, record, data):
        """Dump the data."""

    def load(self, data, record_cls):
        """Load the data.

        Reverse the changes made by the dump method.
        """



# Path: invenio_records/systemfields/model.py
# class ModelField(SystemField):
#     """Model field for providing get and set access on a model field."""
# 
#     def __init__(self, model_field_name=None, dump=True, dump_key=None,
#                  dump_type=None):
#         """Initialize the field.
# 
#         :param model_field_name: Name of field on the database model.
#         :param dump: Set to false to not dump the field.
#         :param dump_key: The dictionary key to use in dumps.
#         :param dump_type: The data type used to determine how to serialize the
#             model field.
#         """
#         self._model_field_name = model_field_name
#         self.dump = dump
#         self._dump_key = dump_key
#         self._dump_type = dump_type
# 
#     #
#     # Helpers
#     #
#     @property
#     def model_field_name(self):
#         """The name of the SQLAlchemy field on the model.
# 
#         Defaults to the attribute name used on the class.
#         """
#         return self._model_field_name or self.attr_name
# 
#     @property
#     def dump_key(self):
#         """The dictionary key to use in dump output.
# 
#         Note, it's up to the dumper to choose if it respects this name.
#         The name defaults to the model field name.
#         """
#         return self._dump_key or self.model_field_name
# 
#     @property
#     def dump_type(self):
#         """The data type used to determine how to serialize the model field.
# 
#         Defaults to none, meaning the dumper will determine how to dump it.
#         """
#         return self._dump_type
# 
#     def _set(self, model, value):
#         """Internal method to set value on the model's field."""
#         setattr(model, self.model_field_name, value)
# 
#     #
#     # Data descriptor
#     #
#     def __get__(self, record, owner=None):
#         """Accessing the attribute."""
#         # Class access
#         if record is None:
#             return self
#         # Instance access
#         try:
#             return getattr(record.model, self.model_field_name)
#         except AttributeError:
#             return None
# 
#     def __set__(self, instance, value):
#         """Accessing the attribute."""
#         self._set(instance.model, value)
# 
#     #
#     # Record extension
#     #
#     def post_init(self, record, data, model=None, field_data=None):
#         """Initialise the model field."""
#         if field_data is not None:
#             self._set(model, field_data)
# 
# Path: invenio_records/dumpers/base.py
# class Dumper:
#     """Interface for dumpers."""
# 
#     def dump(self, record, data):
#         """Dump a record that can be used a source document for Elasticsearch.
# 
#         The job of this method is to create a Python dictionary from the record
#         provided in the argument.
# 
#         If you overwrite this method without calling super, then you should
#         ensure that you make a deep copy of the record dictionary, to avoid
#         that changes to the dump affects the record.
# 
#         :param record: The record to dump.
#         :param data: The initial dump data passed in by ``record.dumps()``.
#         """
#         data.update(deepcopy(dict(record)))
#         return data
# 
#     def load(self, data, record_cls):
#         """Load a record from the source document of an Elasticsearch hit.
# 
#         The job of this method, is to create a record of type ``record_cls``
#         based on the input ``data``.
# 
#         :param data: A Python dictionary representing the data to load.
#         :param records_cls: The record class to be constructed.
#         :returns: A instance of ``record_cls``.
#         """
#         raise NotImplementedError()


# Path: invenio_records/dumpers/elasticsearch.py
from copy import deepcopy
from datetime import date, datetime
from uuid import UUID
from sqlalchemy.sql.sqltypes import JSON, Boolean, DateTime, Integer, String, \
    Text
from sqlalchemy.sql.type_api import Variant
from sqlalchemy_utils.types.uuid import UUIDType
from ..systemfields.model import ModelField
from .base import Dumper
import arrow
import pytz

# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Elasticsearch source dumper.

Dumper used to dump/load an the body of an Elasticsearch document.
"""





class ElasticsearchDumperExt:
    """Interface for Elasticsearch dumper extensions."""

    def dump(self, record, data):
        """Dump the data."""

    def load(self, data, record_cls):
        """Load the data.

        Reverse the changes made by the dump method.
        """



class ElasticsearchDumper(Dumper):