def collections_data(request, collection): if request.method != 'POST': raise PopupException(_('POST request required.')) response = {'status': -1} source = request.POST.get('source') if source == 'file': searcher = CollectionManagerController(request.user) searcher.update_data_from_hdfs( request.fs, collection, None, request.POST.get('path'), request.POST.get('type'), separator=request.POST.get('separator'), quote_character=request.POST.get('quote')) response['status'] = 0 response['message'] = _('Index imported!') else: response['message'] = _('Unsupported source %s') % source return JsonResponse(response)
def collections_data(request, collection): if request.method != 'POST': raise PopupException(_('POST request required.')) response = {'status': -1} source = request.POST.get('source') if source == 'file': searcher = CollectionManagerController(request.user) searcher.update_data_from_hdfs(request.fs, collection, None, request.POST.get('path'), request.POST.get('type'), separator=request.POST.get('separator'), quote_character=request.POST.get('quote')) response['status'] = 0 response['message'] = _('Index imported!') else: response['message'] = _('Unsupported source %s') % source return JsonResponse(response)
def collections_create(request): if request.method != 'POST': raise PopupException(_('POST request required.')) response = {'status': -1} collection = json.loads(request.POST.get('collection', '{}')) if collection: searcher = CollectionManagerController(request.user) # Create instance directory, collection, and add fields searcher.create_collection(collection.get('name'), collection.get('fields', []), collection.get('uniqueKeyField'), collection.get('df')) try: if request.POST.get('source') == 'file': # Index data searcher.update_data_from_hdfs( request.fs, collection.get('name'), collection.get('fields', []), request.POST.get('path'), request.POST.get('type'), separator=request.POST.get('separator'), quote_character=request.POST.get('quote')) elif request.POST.get('source') == 'hive': # Run a custom hive query and post data to collection from beeswax.server import dbms db = dbms.get(request.user) database = request.POST.get('database') table = request.POST.get('table') columns = [ field['name'] for field in collection.get('fields', []) ] searcher.update_data_from_hive(db, collection.get('name'), database, table, columns) # Not up to date response['status'] = 0 response['message'] = _('Collection created!') except Exception as e: LOG.error(e) raise else: response['message'] = _('Collection missing.') return JsonResponse(response)
def collections_create(request): if request.method != 'POST': raise PopupException(_('POST request required.')) response = {'status': -1} collection = json.loads(request.POST.get('collection', '{}')) if collection: searcher = CollectionManagerController(request.user) # Create instance directory, collection, and add fields searcher.create_collection(collection.get('name'), collection.get('fields', []), collection.get('uniqueKeyField'), collection.get('df')) try: if request.POST.get('source') == 'file': # Index data searcher.update_data_from_hdfs(request.fs, collection.get('name'), collection.get('fields', []), request.POST.get('path'), request.POST.get('type'), separator=request.POST.get('separator'), quote_character=request.POST.get('quote')) elif request.POST.get('source') == 'hive': # Run a custom hive query and post data to collection from beeswax.server import dbms db = dbms.get(request.user) database = request.POST.get('database') table = request.POST.get('table') columns = [field['name'] for field in collection.get('fields', [])] searcher.update_data_from_hive(db, collection.get('name'), database, table, columns) response['status'] = 0 response['message'] = _('Collection created!') except Exception, e: LOG.error(e) raise