Beispiel #1
0
 def _create_bulk_upload_package(self,bulk_upload_id, package_name, package_title):
     """
     Creates DB entry in 'bulk_upload_package' table for linking bulk upload and uploaded package.
     """
     log.debug("Create Bulk Upload Package: bid: %s pname: %s  ptitle: %s" % (bulk_upload_id, package_name, package_title))
     data = {'bulk_upload_id': bulk_upload_id, 'package_name': package_name, 'package_title': package_title}
     data_dict = {'model': 'BulkUpload_Package'}
     data_dict['data'] = data
     data_dict['process'] = 'create'
     context = {'model': ckan_model, 'session': ckan_model.Session}
     trans_dispatch(context, data_dict)
Beispiel #2
0
 def _create_bulk_upload_package(self, bulk_upload_id, package_name,
                                 package_title):
     """
     Creates DB entry in 'bulk_upload_package' table for linking bulk upload and uploaded package.
     """
     log.debug("Create Bulk Upload Package: bid: %s pname: %s  ptitle: %s" %
               (bulk_upload_id, package_name, package_title))
     data = {
         'bulk_upload_id': bulk_upload_id,
         'package_name': package_name,
         'package_title': package_title
     }
     data_dict = {'model': 'BulkUpload_Package'}
     data_dict['data'] = data
     data_dict['process'] = 'create'
     context = {'model': ckan_model, 'session': ckan_model.Session}
     trans_dispatch(context, data_dict)
Beispiel #3
0
    def save_search(self):

        data = clean_dict(unflatten(tuplize_dict(parse_params(request.params))))

        user = model.User.by_name(c.user.decode('utf8'))

        data_dict = {'model': 'UserSearch'}
        data_dict['data'] = {'user_id': user.id, 'search_name': data['search_name'], 'url': data['url']}
        data_dict['process'] = 'create'
        context = {'model': model, 'session': model.Session}

        from ckanext.ngds.metadata.controllers.transaction_data import dispatch as trans_dispatch

        trans_dispatch(context, data_dict)

        return {
            'success': True
        }
Beispiel #4
0
def create_package_resource_document_index(pkg_id, resource_dict_list):
    """
    Creates entry for the documents to be full-text indexed for a particular dataset or package. (resource_document_index table).
    Before creating new entries, existing to be indexed (status as 'NEW') entries are updated as 'CANCEL'.
    :returns: True after creating entries in db.
    """

    from ckanext.ngds.metadata.controllers.transaction_data import dispatch as trans_dispatch

    ckan_model.Session().execute(
        "UPDATE public.resource_document_index SET status=:status_val where package_id=:pkg_id and status=:old_status",
        {'status_val': 'CANCEL', 'pkg_id': pkg_id, 'old_status': 'NEW'})

    data_dict = {'model': 'DocumentIndex'}
    data_dict['process'] = 'add'
    context = {'model': ckan_model, 'session': ckan_model.Session}

    for index_dict in resource_dict_list:
        index_dict['status'] = 'NEW'
        data_dict['data'] = index_dict
        trans_dispatch(context, data_dict)

    return True
Beispiel #5
0
def create_package_resource_document_index(pkg_id, resource_dict_list):
    """
    Creates entry for the documents to be full-text indexed for a particular dataset or package. (resource_document_index table).
    Before creating new entries, existing to be indexed (status as 'NEW') entries are updated as 'CANCEL'.
    :returns: True after creating entries in db.
    """

    from ckanext.ngds.metadata.controllers.transaction_data import dispatch as trans_dispatch

    ckan_model.Session().execute(
        "UPDATE public.resource_document_index SET status=:status_val where package_id=:pkg_id and status=:old_status",
        {"status_val": "CANCEL", "pkg_id": pkg_id, "old_status": "NEW"},
    )

    data_dict = {"model": "DocumentIndex"}
    data_dict["process"] = "add"
    context = {"model": ckan_model, "session": ckan_model.Session}

    for index_dict in resource_dict_list:
        index_dict["status"] = "NEW"
        data_dict["data"] = index_dict
        trans_dispatch(context, data_dict)

    return True