Преглед на файлове

HUE-1389 [oozie] Automatically retrieve Hive query parameters

Romain Rigaux преди 9 години
родител
ревизия
7ca1b216db

+ 2 - 1
apps/oozie/src/oozie/static/oozie/js/workflow-editor.ko.js

@@ -518,7 +518,8 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.subworkflows = ko.observableArray(getOtherSubworkflows(self, subworkflows_json));
   self.hiveQueries = ko.observableArray([{"uuid": "c73171ec-acff-4c30-b350-3df0c31689a9", "name": "show tables"}]);
   self.history = ko.mapping.fromJS(history_json);
-
+  //AssistHelper.getInstance(vm);
+  
   self.getSubWorkflow = function (uuid) {
     var wf = $.grep(self.subworkflows(), function (wf, i) {
       return wf.value == uuid;

+ 10 - 10
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -105,8 +105,17 @@ ${ layout.menubar(section='workflows', is_editor=True, pullright=buttons) }
 
 <%dashboard:layout_toolbar>
   <%def name="skipLayout()"></%def>
-  <%def name="widgetSectionName()">${ _('ACTIONS') }</%def>
+  <%def name="widgetSectionName()">${ _('DOCUMENTS') }</%def>
   <%def name="widgets()">
+    <div data-bind="css: { 'draggable-widget': true },
+                    draggable: {data: draggableHiveDocumentAction(), isEnabled: true,
+                    options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableHiveDocumentAction());}}}"
+         title="${_('Saved Hive query')}" rel="tooltip" data-placement="top">
+         <a class="draggable-icon"><img src="${ static('oozie/art/icon_beeswax_48.png') }" class="app-icon"><sup style="color: #338bb8; margin-left: -4px; top: -14px; font-size: 12px">2</sup></a>
+    </div>
+
+    <div class="toolbar-label">${ _('ACTIONS') }</div>
+
     <div data-bind="css: { 'draggable-widget': true },
                     draggable: {data: draggableHiveAction(), isEnabled: true,
                     options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableHiveAction());}}}"
@@ -218,15 +227,6 @@ ${ layout.menubar(section='workflows', is_editor=True, pullright=buttons) }
          title="${_('Kill')}" rel="tooltip" data-placement="top">
          <a class="draggable-icon"><i class="fa fa-stop"></i></a>
     </div>
-
-  <div class="toolbar-label">${ _('DOCUMENTS') }</div>
-
-  <div data-bind="css: { 'draggable-widget': true },
-                  draggable: {data: draggableHiveDocumentAction(), isEnabled: true,
-                  options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableHiveDocumentAction());}}}"
-       title="${_('Saved Hive query')}" rel="tooltip" data-placement="top">
-       <a class="draggable-icon"><img src="${ static('oozie/art/icon_beeswax_48.png') }" class="app-icon"><sup style="color: #338bb8; margin-left: -4px; top: -14px; font-size: 12px">2</sup></a>
-  </div>
 </%def>
 </%dashboard:layout_toolbar>
 

+ 5 - 0
apps/oozie/src/oozie/views/editor2.py

@@ -36,6 +36,8 @@ from liboozie.credentials import Credentials
 from liboozie.oozie_api import get_oozie
 from liboozie.submission2 import Submission
 
+from notebook.models import Notebook
+
 from oozie.decorators import check_document_access_permission, check_document_modify_permission,\
   check_editor_access_permission
 from oozie.forms import ParameterForm
@@ -327,6 +329,9 @@ def action_parameters(request):
           parameters = parameters.union(set(find_dollar_braced_variables(data)))
         elif node_data['type'] == 'pig':
           parameters = parameters.union(set(find_dollar_variables(data)))
+    elif node_data['type'] == 'hive-document':
+      notebook = Notebook(document=Document2.objects.get_by_uuid(uuid=node_data['properties']['uuid']))          
+      parameters = parameters.union(set(find_dollar_braced_variables(notebook.get_str())))
 
     response['status'] = 0
     response['parameters'] = list(parameters)

+ 1 - 1
desktop/libs/liboozie/src/liboozie/submission2.py

@@ -188,7 +188,7 @@ class Submission(object):
           from notebook.models import Notebook
           notebook = Notebook(document=Document2.objects.get_by_uuid(uuid=action.data['properties']['uuid']))
           
-          self._create_file(deployment_dir, action.data['name'] + '.sql', notebook.get_data()['snippets'][0]['statement'])
+          self._create_file(deployment_dir, action.data['name'] + '.sql', notebook.get_str())
           #self.data['properties']['script_path'] = _generate_hive_script(self.data['uuid']) #'workspace_%s' % workflow.uui
 
     oozie_xml = self.job.to_xml(self.properties)