ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [27/28] ambari git commit: AMBARI-20095. Unique Name not created automatically when designing workflow (Venkat Sairam via pallavkul)
Date Tue, 21 Feb 2017 17:19:07 GMT
AMBARI-20095. Unique Name not created automatically when designing workflow (Venkat Sairam
via pallavkul)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/600d0a1a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/600d0a1a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/600d0a1a

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 600d0a1a0ff4c2d927296339c05d71ac67cd2332
Parents: ebf81f6
Author: pallavkul <pallav.kul@gmail.com>
Authored: Tue Feb 21 22:26:02 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Tue Feb 21 22:26:02 2017 +0530

----------------------------------------------------------------------
 .../ui/app/components/flow-designer.js          | 34 ++++++++++++++++++--
 .../main/resources/ui/app/domain/workflow.js    |  7 ++--
 2 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/600d0a1a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
index 190bb1a..b2b9c68 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
@@ -72,6 +72,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   showActionEditor : false,
   flattenedNodes: [],
   dataNodes: [], /* For cytoscape */
+  counterMap : {},
   hoveredAction: null,
   workflowImporter:WorkflowImporter.create({}),
   actionTypeResolver: ActionTypeResolver.create({}),
@@ -110,7 +111,6 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     this.sendAction('register', this.get('tabInfo'), this);
     this.set('flowRenderer',CytoscapeRenderer.create());
     this.set('workflow',Workflow.create({}));
-    this.set("isNew",true);
     CommonUtils.setTestContext(this);
   }.on('init'),
   elementsInserted :function(){
@@ -138,6 +138,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
           this.set("workflow",draftWorkflow);
           this.rerender();
           this.doValidation();
+          this.generateCounterMap();
         }
       }.bind(this)).catch(function(data){
       });
@@ -239,6 +240,22 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     this.flowRenderer.initRenderer(function(){
       this.renderWorkflow();
     }.bind(this),{context:this,id : this.get('cyId'),flattenedNodes:this.get("flattenedNodes"),dataNodes:this.get("dataNodes"),
cyOverflow:this.get("cyOverflow"),canvasHeight:canvasHeight});
+    this.generateCounterMap();
+  },
+  generateCounterMap() {
+    let len = 0, id = 0, val = null, self = this;
+    this.get('dataNodes').forEach(function(item){
+      if(item.data.node) {
+        if(item.data.node.type === "action") {
+          let keyMap = self.get("counterMap"), type = item.data.node.actionType;
+          if(keyMap.hasOwnProperty(type)){
+            keyMap[type] = parseInt(keyMap[type])+1;
+          } else {
+            keyMap[type] = 1;
+          }
+        }
+      }
+    });
   },
   renderWorkflow(){
     this.set('renderNodeTransitions', true);
@@ -488,6 +505,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     this.get("workflow").resetWorfklow();
     this.set('globalConfig', {});
     this.set('parameters', {});
+    this.set('counterMap', {});
     this.set("undoAvailable", false);
     this.set("showingConfirmationNewWorkflow", false);
     if(this.get('workflow.parameters') !== null){
@@ -758,6 +776,16 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     this.importWorkflowFromString(dataStr);
     this.send("hideStreamImport");
   },
+  generateUniqueNodeId(type){
+    let keyMap = this.get("counterMap");
+    if(keyMap.hasOwnProperty(type)){
+      keyMap[type] = ++keyMap[type];
+      return keyMap[type];
+    } else {
+      keyMap[type] = 1;
+      return 1;
+    }
+  },
   actions:{
     importWorkflowStream(dataStr){
       this.importWorkflowFromFile(dataStr);
@@ -864,7 +892,9 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
       var currentTransition=this.get("currentTransition.transition");
       var transition = this.get("currentTransition").source.transitions.findBy('targetNode.id',currentTransition.targetNode.id);
       transition.source=this.get("currentTransition").source;
-      this.get("workflow").addNode(transition, type);
+
+      let temp = this.generateUniqueNodeId(type);
+      this.get("workflow").addNode(transition, type, {}, temp);
       this.rerender();
       this.doValidation();
       this.scrollToNewPosition();

http://git-wip-us.apache.org/repos/asf/ambari/blob/600d0a1a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js
index a563c20..0fc5d6c 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js
@@ -134,18 +134,19 @@ var Workflow= Ember.Object.extend(FindNodeMixin,{
     var generatedNode=this.generatedNode(null,"kill",settings);
     return source.addTransitionTo(generatedNode,"error");
   },
-  addNode(transition,type,settings) {
+  addNode(transition,type,settings, id) {
     var target=transition.targetNode;
     var computedTarget=target;
     if (target && target.isPlaceholder()){
       computedTarget=target.getTargets()[0];
     }
     var generatedNode=this.generatedNode(computedTarget,type,settings);
+    generatedNode.name = generatedNode.name+ "_"+ id;
     var sourceNode=transition.source;
-    if (sourceNode.isPlaceholder()){
+    if (sourceNode && sourceNode.isPlaceholder()) {
       var orignalTransition=this.findTransitionTo(this.startNode,sourceNode.id);
       orignalTransition.targetNode=generatedNode;
-    }else{
+    } else {
       transition.targetNode=generatedNode;
     }
     return generatedNode;


Mime
View raw message