@@ -1252,6 +1252,7 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
1252
1252
if update {
1253
1253
uploadFilesIfNeeded (newPrimitiveNodes )
1254
1254
wfVersion = createNewVersion (updatedWfVersion )
1255
+ return wfVersion
1255
1256
}
1256
1257
}
1257
1258
} else {
@@ -1359,6 +1360,7 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
1359
1360
return wfVersion
1360
1361
}
1361
1362
1363
+ wfVersion = createNewVersion (wfVersion )
1362
1364
return wfVersion
1363
1365
}
1364
1366
@@ -1547,7 +1549,7 @@ func readConfigInputs(config *map[string]interface{}, wfVersion *types.WorkflowV
1547
1549
isSplitter := strings .HasPrefix (node .Name , "file-splitter" ) || strings .HasPrefix (node .Name , "split-to-string" )
1548
1550
if node .Script == nil && ! isSplitter {
1549
1551
oldParam , paramExists := node .Inputs [paramName ]
1550
- paramExists = paramExists && oldParam .Value != nil
1552
+ // paramExists = paramExists && oldParam.Value != nil
1551
1553
if ! paramExists {
1552
1554
fmt .Println ("Parameter " + paramName + " doesn't exist for node " + nodeName )
1553
1555
os .Exit (0 )
@@ -1783,9 +1785,9 @@ func addPrimitiveNodeFromConfig(wfVersion *types.WorkflowVersionDetailed, newPri
1783
1785
connectionFound = true
1784
1786
primitiveNodeName := getNodeNameFromConnectionID (connection .Source .ID )
1785
1787
if strings .HasSuffix (connection .Destination .ID , node .Name + "/" + paramName ) && newPNode .Name != primitiveNodeName {
1786
- delete (wfVersion .Data .PrimitiveNodes , newPNode .Name )
1788
+ // delete(wfVersion.Data.PrimitiveNodes, newPNode.Name)
1787
1789
newPNode .Name = primitiveNodeName
1788
- wfVersion .Data .PrimitiveNodes [newPNode . Name ] = & newPNode
1790
+ wfVersion .Data .PrimitiveNodes [primitiveNodeName ] = & newPNode
1789
1791
}
1790
1792
var primitiveNode * types.PrimitiveNode
1791
1793
primitiveNode , pNodeExists = wfVersion .Data .PrimitiveNodes [primitiveNodeName ]
@@ -1841,9 +1843,28 @@ func addPrimitiveNodeFromConfig(wfVersion *types.WorkflowVersionDetailed, newPri
1841
1843
wfVersion .Name = nil
1842
1844
updateNeeded = true
1843
1845
}
1846
+ wfVersion .Data .PrimitiveNodes [primitiveNodeName ] = & newPNode
1844
1847
break
1845
1848
}
1846
1849
}
1850
+
1851
+ if ! pNodeExists {
1852
+ id := getAvailablePrimitiveNodeID (strings .ToLower (newPNode .Type ), wfVersion .Data .Connections )
1853
+ nodeID := newPNode .Type + "-input-" + fmt .Sprint (id )
1854
+ nodeID = strings .ToLower (nodeID )
1855
+
1856
+ pNode := createNewPrimitiveNode (newPNode .Type , newPNode .Value , id )
1857
+
1858
+ wfVersion .Data .PrimitiveNodes [nodeID ] = & pNode
1859
+
1860
+ connection := createPrimitiveNodeConnection (nodeID , node .Name , paramName )
1861
+ wfVersion .Data .Connections = append (wfVersion .Data .Connections , connection )
1862
+
1863
+ wfVersion .Data .Nodes [node .Name ].Inputs [paramName ].Value = newPNode .Value
1864
+ connectionFound = true
1865
+ pNodeExists = true
1866
+ }
1867
+
1847
1868
if ! connectionFound {
1848
1869
fmt .Println (node .Name + " is not connected to any input!" )
1849
1870
os .Exit (0 )
@@ -1854,6 +1875,41 @@ func addPrimitiveNodeFromConfig(wfVersion *types.WorkflowVersionDetailed, newPri
1854
1875
return updateNeeded
1855
1876
}
1856
1877
1878
+ func createNewPrimitiveNode (nodeType string , value interface {}, id int ) types.PrimitiveNode {
1879
+ var node types.PrimitiveNode
1880
+
1881
+ node .Name = strings .ToLower (nodeType ) + "-input-" + fmt .Sprint (id )
1882
+ node .Value = value
1883
+ node .Label = value .(string )
1884
+ node .Type = nodeType
1885
+ node .TypeName = nodeType
1886
+
1887
+ return node
1888
+ }
1889
+
1890
+ func getAvailablePrimitiveNodeID (nodeType string , connections []types.Connection ) int {
1891
+ availableID := 1
1892
+ for _ , connection := range connections {
1893
+ if strings .HasPrefix (connection .Source .ID , "output/" + nodeType + "-input-" ) {
1894
+ nodeID := strings .Split (connection .Source .ID , "/" )[1 ]
1895
+ numericID , _ := strconv .Atoi (strings .Split (nodeID , "-" )[2 ])
1896
+ if numericID >= availableID {
1897
+ availableID = numericID + 1
1898
+ }
1899
+ }
1900
+ }
1901
+ return availableID
1902
+ }
1903
+
1904
+ func createPrimitiveNodeConnection (source , destinationNode , destinationInput string ) types.Connection {
1905
+ var c types.Connection
1906
+
1907
+ c .Source .ID = "output/" + source + "/output"
1908
+ c .Destination .ID = "input/" + destinationNode + "/" + destinationInput
1909
+
1910
+ return c
1911
+ }
1912
+
1857
1913
func readConfigOutputs (config * map [string ]interface {}) map [string ]output.NodeInfo {
1858
1914
downloadNodes := make (map [string ]output.NodeInfo )
1859
1915
if outputs , exists := (* config )["outputs" ]; exists && outputs != nil {
0 commit comments