Explorar o código

HUE-3878 [oozie] Drag & Dropped a saved Sqoop1 snippet

Romain Rigaux %!s(int64=9) %!d(string=hai) anos
pai
achega
59861a1696

+ 10 - 2
apps/oozie/src/oozie/models2.py

@@ -2335,9 +2335,17 @@ class SqoopDocumentAction(Action):
   FIELDS = {
     'uuid': {
         'name': 'uuid',
-        'label': _('Spark program'),
+        'label': _('Sqoop program'),
         'value': '',
-        'help_text': _('Select a saved Spark program you want to schedule.'),
+        'help_text': _('Select a saved Sqoop program you want to schedule.'),
+        'type': 'sqoop'
+     },
+     'parameters': {
+          'name': 'parameters',
+          'label': _('Parameters'),
+          'value': [],
+          'help_text': _('The %(type)s parameters of the script. E.g. N=5, INPUT=${inputDir}')  % {'type': TYPE.title()},
+          'type': ''
      },
      # Common
      'files': {

+ 5 - 0
apps/oozie/src/oozie/static/oozie/js/workflow-editor.ko.js

@@ -511,6 +511,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
     self.getDocuments('query-java', self.javaQueries);
     self.getDocuments('query-spark2', self.sparkApps);
     self.getDocuments('query-pig', self.pigScripts);
+    self.getDocuments('query-sqoop1', self.sqoopScripts);
   };
 
   self.getDocuments = function(type, destination) {
@@ -557,6 +558,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.javaQueries = ko.observableArray();
   self.sparkApps = ko.observableArray();
   self.pigScripts = ko.observableArray();
+  self.sqoopScripts = ko.observableArray();
   self.history = ko.mapping.fromJS(history_json);
 
   self.getDocumentById = function (type, uuid) {
@@ -567,6 +569,8 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
       data = self.sparkApps();
     } else if (type.indexOf('pig') != -1) {
       data = self.pigScripts();
+    } else if (type.indexOf('sqoop1') != -1) {
+      data = self.sqoopScripts();
     } else {
       data = self.hiveQueries();
     }
@@ -1294,6 +1298,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.draggableJavaDocumentAction = ko.observable(bareWidgetBuilder("Java", "java-document-widget"));
   self.draggableSparkDocumentAction = ko.observable(bareWidgetBuilder("Spark", "spark-document-widget"));
   self.draggablePigDocumentAction = ko.observable(bareWidgetBuilder("Pig", "pig-document-widget"));
+  self.draggableSqoopDocumentAction = ko.observable(bareWidgetBuilder("Sqoop", "sqoop-document-widget"));
   self.draggableKillNode = ko.observable(bareWidgetBuilder("Kill", "kill-widget"));
 };
 

+ 67 - 2
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -169,7 +169,7 @@
       <a class="widget-icon"><i class="fa fa-file-code-o"></i></a>
       <!-- /ko -->
 
-      <!-- ko if: widgetType() == 'sqoop-widget' -->
+      <!-- ko if: widgetType() == 'sqoop-widget' || widgetType() == 'sqoop-document-widget' -->
       <img src="${ static('oozie/art/icon_sqoop_48.png') }" class="widget-icon">
       <!-- /ko -->
 
@@ -813,7 +813,7 @@
       <div data-bind="visible: ! $parent.ooziePropertiesExpanded()" class="nowrap">
         <!-- ko if: $root.getDocumentById(type(), properties.uuid()) -->
         <!-- ko with: $root.getDocumentById(type(), properties.uuid()) -->
-          <select data-bind="options: $root.pigScripts, optionsText: 'name', optionsValue: 'uuid', value: $parent.properties.uuid, select2Version4:{ placeholder: '${ _ko('Java program name...')}'}"></select>
+          <select data-bind="options: $root.pigScripts, optionsText: 'name', optionsValue: 'uuid', value: $parent.properties.uuid, select2Version4:{ placeholder: '${ _ko('Pig program name...')}'}"></select>
           <a href="#" data-bind="attr: { href: absoluteUrl() }" target="_blank" title="${ _('Open') }">
             <i class="fa fa-external-link-square"></i>
           </a>
@@ -1373,6 +1373,71 @@
 </script>
 
 
+<script type="text/html" id="sqoop-document-widget">
+  <!-- ko if: $root.workflow.getNodeById(id()) -->
+  <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="padding: 10px">
+
+    <div data-bind="visible: ! $root.isEditing()">
+      <span data-bind="template: { name: 'logs-icon' }"></span>
+      <!-- ko if: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
+      <!-- ko with: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
+        <a data-bind="attr: { href: absoluteUrl() }" target="_blank"><span data-bind='text: name'></span></a>
+        <br/>
+        <span data-bind='text: description' class="muted"></span>
+      <!-- /ko -->
+      <!-- /ko -->
+    </div>
+
+    <div data-bind="visible: $root.isEditing">
+      <div data-bind="visible: ! $parent.ooziePropertiesExpanded()" class="nowrap">
+        <!-- ko if: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
+        <!-- ko with: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
+          <select data-bind="options: $root.sqoopScripts, optionsText: 'name', optionsValue: 'uuid', value: $parent.properties.uuid, select2Version4:{ placeholder: '${ _ko('Sqoop program name...')}'}"></select>
+          <a href="#" data-bind="attr: { href: absoluteUrl() }" target="_blank" title="${ _('Open') }">
+            <i class="fa fa-external-link-square"></i>
+          </a>
+          <div data-bind='text: description' style="padding: 3px; margin-top: 2px" class="muted"></div>
+        <!-- /ko -->
+        <!-- /ko -->
+
+        <div class="row-fluid">
+          <div class="span6" data-bind="template: { name: 'common-properties-parameters' }"></div>
+          <div class="span6" data-bind="template: { name: 'common-properties-files' }"></div>
+        </div>
+
+      </div>
+    </div>
+
+    <div data-bind="visible: $parent.ooziePropertiesExpanded">
+      <ul class="nav nav-tabs">
+        <li class="active"><a data-bind="attr: { href: '#properties-' + id()}" data-toggle="tab">${ _('Properties') }</a></li>
+        <li><a data-bind="attr: { href: '#sla-' + id()}" href="#sla" data-toggle="tab">${ _('SLA') }</a></li>
+        <li><a data-bind="attr: { href: '#credentials-' + id()}" data-toggle="tab">${ _('Credentials') }</a></li>
+        <li><a data-bind="attr: { href: '#transitions-' + id()}" data-toggle="tab">${ _('Transitions') }</a></li>
+      </ul>
+      <div class="tab-content">
+        <div class="tab-pane active" data-bind="attr: { id: 'properties-' + id() }">
+          <span data-bind="template: { name: 'common-action-properties' }"></span>
+        </div>
+
+        <div class="tab-pane" data-bind="attr: { id: 'sla-' + id() }">
+          <span data-bind="template: { name: 'common-action-sla' }"></span>
+        </div>
+
+        <div class="tab-pane" data-bind="attr: { id: 'credentials-' + id() }">
+          <span data-bind="template: { name: 'common-action-credentials' }"></span>
+        </div>
+
+        <div class="tab-pane" data-bind="attr: { id: 'transitions-' + id() }">
+          <span data-bind="template: { name: 'common-action-transition' }"></span>
+        </div>
+      </div>
+    </div>
+  </div>
+  <!-- /ko -->
+</script>
+
+
 <script type="text/html" id="mapreduce-widget">
   <!-- ko if: $root.workflow.getNodeById(id()) -->
   <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="padding: 10px">

+ 9 - 2
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -141,6 +141,13 @@ ${ layout.menubar(section='workflows', is_editor=True, pullright=buttons) }
          <a class="draggable-icon"><img src="${ static('oozie/art/icon_pig_48.png') }" class="app-icon"></a>
     </div>
 
+    <div data-bind="css: { 'draggable-widget': true },
+                    draggable: {data: draggableSqoopDocumentAction(), isEnabled: true,
+                    options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableSqoopDocumentAction());}}}"
+         title="${_('Saved Sqoop command')}" rel="tooltip" data-placement="top">
+         <a class="draggable-icon"><img src="${ static('oozie/art/icon_sqoop_48.png') }" class="app-icon"></a>
+    </div>
+
     % endif
 
     <div class="toolbar-label">${ _('ACTIONS') }</div>
@@ -297,8 +304,8 @@ ${ workflow.render() }
           <!-- ko if: type() == 'workflow' -->
           <select data-bind="options: $root.subworkflows, optionsText: 'name', optionsValue: 'value', value: value"></select>
           <!-- /ko -->
-          <!-- ko if: ['hive', 'java', 'spark', 'pig'].indexOf(type()) != -1 -->
-          <select data-bind="options: type() == 'java' ? $root.javaQueries() : (type() == 'spark' ? $root.sparkApps() : (type() == 'pig' ? $root.pigScripts() : $root.hiveQueries())), optionsText: 'name', optionsValue: 'uuid', value: value, select2Version4:{ placeholder: '${ _ko('Document name...')}'}"></select>
+          <!-- ko if: ['hive', 'java', 'spark', 'pig', 'sqoop'].indexOf(type()) != -1 -->
+          <select data-bind="options: type() == 'java' ? $root.javaQueries() : (type() == 'spark' ? $root.sparkApps() : (type() == 'pig' ? $root.pigScripts() : (type() == 'sqoop' ? $root.sqoopScripts() : $root.hiveQueries()))), optionsText: 'name', optionsValue: 'uuid', value: value, select2Version4:{ placeholder: '${ _ko('Document name...')}'}"></select>
           <!-- ko if: $root.getDocumentById(type(), value()) -->
             <!-- ko with: $root.getDocumentById(type(), value()) -->
               <a href="#" data-bind="attr: { href: $data.absoluteUrl() }" target="_blank" title="${ _('Open') }">

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

@@ -303,6 +303,9 @@ def action_parameters(request):
     elif node_data['type'] == 'hive-document':
       notebook = Notebook(document=Document2.objects.get_by_uuid(user=request.user, uuid=node_data['properties']['uuid']))
       parameters = parameters.union(set(find_dollar_braced_variables(notebook.get_str())))
+    elif node_data['type'] == 'sqoop-document':
+      notebook = Notebook(document=Document2.objects.get_by_uuid(user=request.user, uuid=node_data['properties']['uuid']))
+      parameters = parameters.union(set(find_dollar_braced_variables(notebook.get_str())))
     elif node_data['type'] == 'spark-document':
       notebook = Notebook(document=Document2.objects.get_by_uuid(user=request.user, uuid=node_data['properties']['uuid']))
       for arg in notebook.get_data()['snippets'][0]['properties']['spark_arguments']: