def create_dataset(self, name='', datastore_name='', view_name='', stream_id='', parameter_dict=None, spatial_domain=None,temporal_domain=None, description=''):
#        validate_true(name and parameter_dict and temporal_domain and spatial_domain, 'Datasets require name, parameter dictionary, temporal and spatial domains.')

        validate_is_not_none(parameter_dict, 'A parameter dictionary must be supplied to register a new dataset.')
        validate_is_not_none(spatial_domain, 'A spatial domain must be supplied to register a new dataset.')
        validate_is_not_none(temporal_domain, 'A temporal domain must be supplied to register a new dataset.')

        dataset                      = DataSet()
        dataset.description          = description
        dataset.name                 = name
        dataset.primary_view_key     = stream_id or None
        dataset.datastore_name       = datastore_name or self.DEFAULT_DATASTORE
        dataset.view_name            = view_name or self.DEFAULT_VIEW
        dataset.parameter_dictionary = parameter_dict
        dataset.temporal_domain      = temporal_domain
        dataset.spatial_domain       = spatial_domain


        dataset_id, _ = self.clients.resource_registry.create(dataset)
        if stream_id:
            self.add_stream(dataset_id,stream_id)

        coverage = self._create_coverage(description or dataset_id, parameter_dict, spatial_domain, temporal_domain) 
        self._persist_coverage(dataset_id, coverage)

        return dataset_id
    def create_dataset(
        self, stream_id="", datastore_name="", view_name="", name="", description="", contact=None, user_metadata=None
    ):
        """@brief Create a resource which defines a dataset. For LCA it is assumed that datasets are organized by stream.
        @param stream_id is the primary key used in the couch view to retrieve the content or metadata
        @param datastore_name is the name of the datastore where this dataset resides.
        @param view_name is the name of the view which joins the dataset definition to the dataset
        @param contact is the contact information for the dataset adminstrator
        @param user_metadata is user defined metadata which can be added to this dataset. Should be annotation via association
        @param name is the name of the dataset resource
        @param description is a description of the dataset resource

        @param stream_id    str
        @param datastore_name    str
        @param view_name    str
        @param name    str
        @param description    str
        @param contact    ContactInformation
        @param user_metadata    Unknown
        @retval dataset_id    str
        """
        if not (stream_id and datastore_name):
            raise BadRequest("You must provide a stream_id and datastore name by which to identify this dataset.")

        dataset = DataSet()
        dataset.description = description
        dataset.name = name or stream_id
        dataset.primary_view_key = stream_id
        dataset.datastore_name = datastore_name
        # @todo: fill this in
        dataset.view_name = view_name or "datasets/dataset_by_id"

        dataset_id, _ = self.clients.resource_registry.create(dataset)
        return dataset_id
Пример #3
0
    def create_dataset(self,
                       stream_id='',
                       datastore_name='',
                       view_name='',
                       name='',
                       description='',
                       contact=None,
                       user_metadata=None):
        """@brief Create a resource which defines a dataset. For LCA it is assumed that datasets are organized by stream.
        @param stream_id is the primary key used in the couch view to retrieve the content or metadata
        @param datastore_name is the name of the datastore where this dataset resides.
        @param view_name is the name of the view which joins the dataset definition to the dataset
        @param contact is the contact information for the dataset adminstrator
        @param user_metadata is user defined metadata which can be added to this dataset. Should be annotation via association
        @param name is the name of the dataset resource
        @param description is a description of the dataset resource

        @param stream_id    str
        @param datastore_name    str
        @param view_name    str
        @param name    str
        @param description    str
        @param contact    ContactInformation
        @param user_metadata    Unknown
        @retval dataset_id    str
        """
        if not (stream_id and datastore_name):
            raise BadRequest(
                "You must provide a stream_id and datastore name by which to identify this dataset."
            )

        dataset = DataSet()
        dataset.description = description
        dataset.name = name or stream_id
        dataset.primary_view_key = stream_id
        dataset.datastore_name = datastore_name
        #@todo: fill this in
        dataset.view_name = view_name or 'datasets/dataset_by_id'

        dataset_id, _ = self.clients.resource_registry.create(dataset)
        return dataset_id