def notify(self, entity, operation=None): if isinstance(entity, model.resource.Resource): if entity.format.lower() in vectorstorer.supported_formats: # Yes, we are interested in this format log.info( 'Notified on modification %r of vector resource %r (state=%s)' % (operation, entity.id, entity.state)) if operation == model.domain_object.DomainObjectOperation.new: # A new vector resource has been created resource_actions.identify_resource(entity) elif operation == model.domain_object.DomainObjectOperation.deleted: # A vector resource has been deleted #resource_actions.delete_ingest_resource(entity.as_dict()) pass elif operation is None: # The URL of a vector resource has been updated #resource_actions.update_ingest_resource(entity) pass elif isinstance(entity, model.Package): log.info('Notified on modification %r of dataset %r (state=%r)' % (operation, entity.id, entity.state)) if entity.state == 'deleted': resource_actions.delete_ingest_resources_in_package( entity.as_dict()) return
def notify(self, entity, operation=None): if isinstance(entity, model.resource.Resource): if operation == model.domain_object.DomainObjectOperation.new: if entity.format.lower() in vectorstorer.supported_formats: # Yes, we are interested in this format log.info( 'Notified on modification %r of vector resource %r (state=%s)' % (operation, entity.id, entity.state)) # A new vector resource has been created resource_actions.identify_resource(entity) elif operation == model.domain_object.DomainObjectOperation.changed: if entity.state == 'deleted': if entity.format.lower() in vectorstorer.supported_formats: # A parent vector resource has recieved a 'deleted' notification # so we also delete the ingestion produced resources resource_actions.delete_ingest_resource( entity.as_dict()) elif entity.format.lower() in vector_child_formats: # A child vector resource has recieved a 'deleted' notification # so we also delete all other resources associated to the deleted resource_actions.delete_ingest_resource( entity.as_dict()) elif entity.state == 'active': # The metadata of a resource has been updated so we get # the Resource object as it was before the update in order # to check if this can be updated #old_resource = self._get_resource_before_commit(entity.id) #if old_resource.format.lower() in vector_child_formats: #log.info('Notified on metadata update of %s vector resource %r' % ( #old_resource.format, old_resource.id )) ## A vector child resource (e.g WMS) has recieved an update ## notification so we abort the operation #raise toolkit.abort(400, #"%s resources can't be updated." % (old_resource.format)) pass elif operation is None: # The URL of a vector resource has been updated #if entity.format.lower() in vectorstorer.supported_formats: #resource_actions.update_ingest_resource(entity) pass elif isinstance(entity, model.package.Package): log.info('Notified on modification %r of dataset %r (state=%r)' % (operation, entity.id, entity.state)) if entity.state == 'deleted': #resource_actions.delete_ingest_resources_in_package( #entity.as_dict()) pass
def notify(self, entity, operation=None): if isinstance(entity, model.resource.Resource): if operation == model.domain_object.DomainObjectOperation.new: if entity.format.lower() in vectorstorer.supported_formats: # Yes, we are interested in this format log.info('Notified on modification %r of vector resource %r (state=%s)' % ( operation, entity.id, entity.state)) # A new vector resource has been created resource_actions.identify_resource(entity) elif operation == model.domain_object.DomainObjectOperation.changed: if entity.state == 'deleted': if entity.format.lower() in vectorstorer.supported_formats: # A parent vector resource has recieved a 'deleted' notification # so we also delete the ingestion produced resources resource_actions.delete_ingest_resource(entity.as_dict()) elif entity.format.lower() in vector_child_formats: # A child vector resource has recieved a 'deleted' notification # so we also delete all other resources associated to the deleted resource_actions.delete_ingest_resource(entity.as_dict()) elif entity.state == 'active': # The metadata of a resource has been updated so we get # the Resource object as it was before the update in order # to check if this can be updated #old_resource = self._get_resource_before_commit(entity.id) #if old_resource.format.lower() in vector_child_formats: #log.info('Notified on metadata update of %s vector resource %r' % ( #old_resource.format, old_resource.id )) ## A vector child resource (e.g WMS) has recieved an update ## notification so we abort the operation #raise toolkit.abort(400, #"%s resources can't be updated." % (old_resource.format)) pass elif operation is None: # The URL of a vector resource has been updated #if entity.format.lower() in vectorstorer.supported_formats: #resource_actions.update_ingest_resource(entity) pass elif isinstance(entity, model.package.Package): log.info('Notified on modification %r of dataset %r (state=%r)' % ( operation, entity.id, entity.state)) if entity.state == 'deleted': #resource_actions.delete_ingest_resources_in_package( #entity.as_dict()) pass
def identify_resource(self, resource_id, storer_type, parent): user_dict = self._check_access() self._setup_template_variables(user_dict) context, data_dict = self._get_context() resource = model.Session.query(model.Resource).get(resource_id) if storer_type == ResourceStorerType.VECTOR: # Fixme: adapt resource_actions.identify_resource(resource) if parent == 'dashboard': _action = 'show_dashboard_resources' else: _action = 'show_admin_page_resources' h.redirect_to(toolkit.url_for( controller='ckanext.publicamundi.controllers.user:UserController', action=_action))
def identify_resource(self, resource_id, storer_type, parent): user_dict = self._check_access() self._setup_template_variables(user_dict) context, data_dict = self._get_context() resource = model.Session.query(model.Resource).get(resource_id) if storer_type == ResourceStorerType.VECTOR: # Fixme: adapt resource_actions.identify_resource(resource) if parent == 'dashboard': _action = 'show_dashboard_resources' else: _action = 'show_admin_page_resources' redirect(toolkit.url_for( controller='ckanext.publicamundi.controllers.user:UserController', action=_action))