[ONOS-7196]Making a separate database, graph and Wiki page for the old flow rules result

Change-Id: Ifeeaa0d725d2cd39c9f276d5383f562f2a67be34
diff --git a/TestON/JenkinsFile/scripts/SCPFflowTp1g.R b/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
index 9c79ac8..140d5f8 100644
--- a/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
+++ b/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
@@ -23,6 +23,16 @@
 # **********************************************************
 # STEP 1: Data management.
 # **********************************************************
+has_flow_obj = 1
+database_host = 2
+database_port = 3
+database_u_id = 4
+database_pw = 5
+test_name = 6
+branch_name = 7
+has_neighbors = 8
+old_flow = 9
+save_directory = 10
 
 print( "**********************************************************" )
 print( "STEP 1: Data management." )
@@ -47,7 +57,7 @@
 
 print( "Verifying CLI args." )
 
-if ( is.na( args[ 9 ] ) ){
+if ( is.na( args[ save_directory ] ) ){
 
     print( paste( "Usage: Rscript SCPFflowTp1g.R",
                                   "<has-flow-obj>",
@@ -58,6 +68,7 @@
                                   "<test-name>",
                                   "<branch-name>",
                                   "<has-neighbors>",
+                                  "<using-old-flow>",
                                   "<directory-to-save-graphs>",
                                   sep=" " ) )
 
@@ -75,7 +86,7 @@
 commandNeighborModifier <- ""
 fileFlowObjModifier <- ""
 sqlFlowObjModifier <- ""
-if ( args[ 1 ] == 'y' ){
+if ( args[ has_flow_obj ] == 'y' ){
     fileFlowObjModifier <- "_flowObj"
     sqlFlowObjModifier <- "_fobj"
     chartTitle <- paste( chartTitle, " with Flow Objectives", sep="" )
@@ -83,22 +94,27 @@
 
 chartTitle <- paste( chartTitle, "\nNeighbors =", sep="" )
 
-if ( args[ 8 ] == 'y' ){
+fileOldFlowModifier <- ""
+if ( args[ has_neighbors ] == 'y' ){
     fileNeighborsModifier <- "all"
     commandNeighborModifier <- "scale=1 OR NOT "
     chartTitle <- paste( chartTitle, "Cluster Size - 1" )
 } else {
     chartTitle <- paste( chartTitle, "0" )
 }
-
-errBarOutputFile <- paste( args[ 9 ],
-                           args[ 6 ],
+if ( args[ old_flow ] == 'y' ){
+    fileOldFlowModifier <- "_OldFlow"
+    chartTitle <- paste( chartTitle, "With Old Flow", sep="\n" )
+}
+errBarOutputFile <- paste( args[ save_directory ],
+                           args[ test_name ],
                            "_",
-                           args[ 7 ],
+                           args[ branch_name ],
                            "_",
                            fileNeighborsModifier,
                            "-neighbors",
                            fileFlowObjModifier,
+                           fileOldFlowModifier,
                            "_graph.jpg",
                            sep="" )
 # ------------------
@@ -109,10 +125,10 @@
 
 con <- dbConnect( dbDriver( "PostgreSQL" ),
                   dbname = "onostest",
-                  host = args[ 2 ],
-                  port = strtoi( args[ 3 ] ),
-                  user = args[ 4 ],
-                  password = args[ 5 ] )
+                  host = args[ database_host ],
+                  port = strtoi( args[ database_port ] ),
+                  user = args[ database_u_id ],
+                  password = args[ database_pw ] )
 
 # ---------------------------
 # Flow Throughput SQL Command
@@ -125,12 +141,15 @@
                   "_tests WHERE (",
                   commandNeighborModifier,
                   "neighbors = 0 ) AND branch = '",
-                  args[ 7 ],
+                  args[ branch_name ],
                   "' AND date IN ( SELECT max( date ) FROM flow_tp",
                   sqlFlowObjModifier,
                   "_tests WHERE branch='",
-                  args[ 7 ],
-                  "' ) GROUP BY scale ORDER BY scale",
+                  args[ branch_name ],
+                  "' AND ",
+                  ( if( args[ old_flow ] == 'y' ) "" else "NOT " ),
+                  "is_old_flow",
+                  " ) GROUP BY scale ORDER BY scale",
                   sep="" )
 
 print( "Sending SQL command:" )