-
Notifications
You must be signed in to change notification settings - Fork 16
/
JobView.java
773 lines (743 loc) · 38.9 KB
/
JobView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
import java.util.Map;
import java.sql.*;
import java.util.ArrayList;
public class JobView
{
public static String action = "jobs";
private static String getHead()
{
String myScript = "function formSubmit(offset)\n";
myScript += "{\n";
myScript += " document.getElementById(\"offset\").value = offset;\n";
myScript += " document.getElementById(\"myForm\").submit();\n";
myScript += "}\n";
myScript += "function sortRS(sortBy, sort)\n";
myScript += "{\n";
myScript += " document.getElementById(\"offset\").value = 0;\n";
myScript += " document.getElementById(\"sort_by\").value = sortBy;\n";
myScript += " document.getElementById(\"sort\").value = sort;\n";
myScript += " document.getElementById(\"myForm\").submit();\n";
myScript += "}\n";
myScript += "function updateQueue(id, myAction)\n";
myScript += "{\n";
myScript += " document.getElementById(\"action_type\").value = \"queue\";\n";
myScript += " document.getElementById(\"queue_action\").value = myAction;\n";
myScript += " document.getElementById(\"id\").value = id;\n";
myScript += " document.getElementById(\"myForm\").submit();\n";
myScript += "}\n";
myScript += "function updateJob(id, myAction)\n";
myScript += "{\n";
myScript += " document.getElementById(\"action_type\").value = myAction;\n";
myScript += " document.getElementById(\"offset\").value = 0;\n";
myScript += " document.getElementById(\"submit_form\").value = \"0\";\n";
myScript += " document.getElementById(\"id\").value = id;\n";
myScript += " document.getElementById(\"myForm\").submit();\n";
myScript += "}\n";
return myScript;
}
public static String viewList(String search, ResultSet rs, String limit, String offset, String sortBy, String sort)
{
String myScript = getHead();
String msg = OutsourcerView.viewSearch(action, search, limit, offset, sortBy, sort, myScript);
msg += "<table class=\"tftable\" border=\"0\">\n";
msg += "<tr>\n";
msg += "<td><h4><a href=\"?action_type=update\">Define New Job</a></h4></td>\n";
msg += "<td align=\"center\"><h4><a href=\"queue?action_type=insert_all\">Queue All Jobs</a></h4></td>\n";
msg += "<td align=\"right\"><h4><a href=\"?action_type=delete_all\">Delete All Jobs</a></h4></td>\n";
msg += "</tr>\n";
msg += "</table>\n";
msg += "<br>\n";
msg += getHeader(sortBy, sort);
try
{
msg += OutsourcerView.viewResults(limit, offset, rs);
}
catch (Exception ex)
{
msg += ex.getMessage();
}
return msg;
}
private static String getJavaScriptFunctions()
{
String myScript = "function disableInputFields()\n";
myScript += "{\n";
myScript += " var ver = \"" + UI.gpVersion + "\";\n";
myScript += " var val = document.getElementById(\"source_type\").selectedIndex;\n";
myScript += " var t = document.getElementById(\"refresh_type\").selectedIndex;\n";
myScript += " var a = document.getElementById(\"target_append_only\").selectedIndex;\n";
myScript += " if (t == 0)\n"; //refresh_type not set yet.
myScript += " {\n";
myScript += " document.getElementById(\"target_schema_name\").value = \"\";\n";
myScript += " document.getElementById(\"target_table_name\").value = \"\";\n";
myScript += " document.getElementById(\"target_append_only\").value = \"true\";\n";
myScript += " document.getElementById(\"target_compressed\").value = \"false\";\n";
myScript += " document.getElementById(\"target_row_orientation\").value = \"true\";\n";
myScript += " document.getElementById(\"source_type\").value = \"\";\n";
myScript += " document.getElementById(\"source_server_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_instance_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_port\").value = \"\";\n";
myScript += " document.getElementById(\"source_database_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_schema_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_table_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_user_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_pass\").value = \"\";\n";
myScript += " document.getElementById(\"column_name\").value = \"\";\n";
myScript += " document.getElementById(\"sql_text\").value = \"\";\n";
myScript += " document.getElementById(\"snapshot\").value = \"false\";\n";
myScript += " document.getElementById(\"schedule_desc\").value = \"\";\n";
myScript += " document.getElementById(\"r_target_schema_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_table_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_type\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_server_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_instance_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_port\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_database_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_schema_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_table_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_user_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_pass\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_column_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_sql_text\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_schedule_desc\").style.display = \"none\";\n";
myScript += " } else \n";
myScript += " if (t != 4) // Not a transform and a value has been picked\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_schema_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_target_table_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_type\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_schedule_desc\").style.display = \"\";\n";
myScript += " if (t == 1) //Append\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_column_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"snapshot\").value = \"false\";\n";
myScript += " document.getElementById(\"r_sql_text\").style.display = \"\";\n";
myScript += " if (ver == \"AO\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"\";\n";
myScript += " } else\n";
myScript += " if (ver == \"HAWQ\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"none\";\n";
myScript += " }\n";
myScript += " if (a == 0) //append-optimized\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"\";\n";
myScript += " } else\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"none\";\n";
myScript += " }\n";
myScript += " } else \n";
myScript += " if (t == 2 || t == 3) //DDL and Refresh\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_column_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"column_name\").value = \"\";\n";
myScript += " document.getElementById(\"r_sql_text\").style.display = \"\";\n";
myScript += " document.getElementById(\"snapshot\").value = \"false\";\n";
myScript += " if (ver == \"AO\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"\";\n";
myScript += " } else\n";
myScript += " if (ver == \"HAWQ\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"none\";\n";
myScript += " }\n";
myScript += " if (a == 0) //append-optimized\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"\";\n";
myScript += " } else\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"none\";\n";
myScript += " }\n";
myScript += " } else \n";
myScript += " if (t == 5) //Replication\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_column_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_sql_text\").style.display = \"\";\n";
myScript += " if (ver == \"AO\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"\";\n";
myScript += " if (a == 0) //append-optimized\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"\";\n";
myScript += " } else\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"none\";\n";
myScript += " }\n";
myScript += " } else\n";
myScript += " if (ver == \"HAWQ\")\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"\";\n";
myScript += " }\n";
myScript += " }\n";
myScript += " if (val == 0)\n"; // source type not set yet
myScript += " {\n";
myScript += " document.getElementById(\"r_source_server_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_instance_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_port\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_database_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_schema_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_table_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_user_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_pass\").style.display = \"none\";\n";
myScript += " document.getElementById(\"source_server_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_instance_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_port\").value = \"\";\n";
myScript += " document.getElementById(\"source_database_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_schema_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_table_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_user_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_pass\").value = \"\";\n";
myScript += " } else\n"; //Oracle or SQL Server picked
myScript += " {\n";
myScript += " document.getElementById(\"r_source_server_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_database_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_schema_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_table_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_user_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_pass\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_schedule_desc\").style.display = \"\";\n";
myScript += " if (val == 1) //Oracle\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_source_instance_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_port\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"source_instance_name\").value = \"\";\n";
myScript += " } else\n";
myScript += " if (val == 2) //SQL Server\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_source_instance_name\").style.display = \"\";\n";
myScript += " document.getElementById(\"r_source_port\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"source_port\").value = \"\";\n";
myScript += " }\n";
myScript += " }\n";
myScript += " } else //transform job\n";
myScript += " {\n";
myScript += " document.getElementById(\"r_sql_text\").style.display = \"\";\n";
myScript += " document.getElementById(\"target_schema_name\").value = \"\";\n";
myScript += " document.getElementById(\"target_table_name\").value = \"\";\n";
myScript += " document.getElementById(\"target_append_only\").value = \"true\";\n";
myScript += " document.getElementById(\"target_compressed\").value = \"false\";\n";
myScript += " document.getElementById(\"target_row_orientation\").value = \"true\";\n";
myScript += " document.getElementById(\"source_type\").value = \"\";\n";
myScript += " document.getElementById(\"source_server_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_instance_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_port\").value = \"\";\n";
myScript += " document.getElementById(\"source_database_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_schema_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_table_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_user_name\").value = \"\";\n";
myScript += " document.getElementById(\"source_pass\").value = \"\";\n";
myScript += " document.getElementById(\"column_name\").value = \"\";\n";
myScript += " document.getElementById(\"snapshot\").value = \"false\";\n";
myScript += " document.getElementById(\"schedule_desc\").value = \"\";\n";
myScript += " document.getElementById(\"r_target_schema_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_table_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_append_only\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_compressed\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_target_row_orientation\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_type\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_server_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_instance_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_port\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_database_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_schema_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_table_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_user_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_source_pass\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_column_name\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_snapshot\").style.display = \"none\";\n";
myScript += " document.getElementById(\"r_schedule_desc\").style.display = \"\";\n";
myScript += " }\n";
myScript += "}\n";
return myScript;
}
public static String viewUpdate(String id, String refreshType, String targetSchemaName, String targetTableName, boolean targetAppendOnly, boolean targetCompressed, boolean targetRowOrientation, String sourceType, String sourceServerName, String sourceInstanceName, String sourcePort, String sourceDatabaseName, String sourceSchemaName, String sourceTableName, String sourceUserName, String sourcePass, String columnName, String sqlText, boolean snapshot, String scheduleDesc, ArrayList<String> scheduleList)
{
String buttonText = "";
if (id == null)
{
id = "";
buttonText = "Insert";
targetAppendOnly = true;
targetCompressed = false;
targetRowOrientation = true;
snapshot = false;
}
else
{
buttonText = "Update";
}
targetSchemaName = OutsourcerView.setHTMLField(targetSchemaName);
targetTableName = OutsourcerView.setHTMLField(targetTableName);
sourceServerName = OutsourcerView.setHTMLField(sourceServerName);
sourceInstanceName = OutsourcerView.setHTMLField(sourceInstanceName);
sourcePort = OutsourcerView.setHTMLField(sourcePort);
sourceDatabaseName = OutsourcerView.setHTMLField(sourceDatabaseName);
sourceSchemaName = OutsourcerView.setHTMLField(sourceSchemaName);
sourceTableName = OutsourcerView.setHTMLField(sourceTableName);
sourceUserName = OutsourcerView.setHTMLField(sourceUserName);
sourcePass = OutsourcerView.setHTMLField(sourcePass);
columnName = OutsourcerView.setHTMLField(columnName);
if (sqlText == null)
sqlText = "";
String myScript = getJavaScriptFunctions();
String onLoad="disableInputFields()";
String msg = OutsourcerView.viewHeader(myScript, onLoad, action);
msg += "<form action=\"jobs\" method=\"post\">\n";
msg += "<table class=\"tftable\" border=\"1\">\n";
msg += "<tr><td width=\"30%\"><b>ID</b></td>";
msg += "<td>" + id + "</td></tr>\n";
msg += "<tr><td><b>Refresh Type</b></td>";
msg += "<td><select id=\"refresh_type\" name=\"refresh_type\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"append\"";
if (refreshType != null && refreshType.equals("append"))
msg += " selected";
msg += ">Append</option>\n";
msg += "<option value=\"ddl\"";
if (refreshType != null && refreshType.equals("ddl"))
msg += " selected";
msg += ">DDL</option>\n";
msg += "<option value=\"refresh\"";
if (refreshType != null && refreshType.equals("refresh"))
msg += " selected";
msg += ">Refresh</option>\n";
msg += "<option value=\"transform\"";
if (refreshType != null && refreshType.equals("transform"))
msg += " selected";
msg += ">Transform</option>\n";
if (!(UI.gpVersion.equals("HAWQ")))
{
msg += "<option value=\"replication\"";
if (refreshType != null && refreshType.equals("replication"))
msg += " selected";
msg += ">Replication</option>\n";
msg += "</select>\n";
}
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_schema_name\"><td><b>Target Schema</b></td>\n";
msg += "<td><input type=\"text\" id=\"target_schema_name\" name=\"target_schema_name\" value=" + targetSchemaName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_table_name\"><td><b>Target Table</b></td>\n";
msg += "<td><input type=\"text\" id=\"target_table_name\" name=\"target_table_name\" value=" + targetTableName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_append_only\"><td><b>";
if (UI.gpVersion.equals("AO"))
msg += "Target Append-Optimized";
else
msg += "Target Append-Only";
msg += "</b></td>\n";
msg += "<td><select id=\"target_append_only\" name=\"target_append_only\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"true\"";
if (targetAppendOnly == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetAppendOnly == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_target_compressed\"><td><b>Target Compressed</b></td>\n";
msg += "<td><select id=\"target_compressed\" name=\"target_compressed\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"true\"";
if (targetCompressed == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetCompressed == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_target_row_orientation\"><td><b>Target Row Orientation</b></td>\n";
msg += "<td><select id=\"target_row_orientation\" name=\"target_row_orientation\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"true\"";
if (targetRowOrientation == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetRowOrientation == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_column_name\"><td><b>Column Name</b></td>";
msg += "<td><input type=\"column_name\" id=\"column_name\" name=\"column_name\" value=" + columnName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_snapshot\"><td><b>Snapshot</b></td>\n";
msg += "<td><select id=\"snapshot\" name=\"snapshot\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"true\"";
if (snapshot == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (snapshot == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_sql_text\"><td><b>Transform SQL</b></td>";
msg += "<td><textarea cols=\"50\" rows=\"10\" id=\"sql_text\" name=\"sql_text\">" + sqlText + "</textarea>\n";
msg += "</td></tr>\n";
msg += "<tr id=\"r_schedule_desc\"><td><b>Schedule</b></td>";
msg += "<td><select id=\"schedule_desc\" name=\"schedule_desc\">\n";
msg += "<option value=\"\"></option>\n";
for (int i = 0; i < scheduleList.size(); i++)
{
msg += "<option value=\"" + scheduleList.get(i) + "\"";
if (scheduleDesc != null && scheduleDesc.equals(scheduleList.get(i)))
msg += " selected";
msg += ">" + scheduleList.get(i) + "</option>\n";
}
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_type\"><td><b>Source Type</b></td>\n";
msg += "<td><select id=\"source_type\" name=\"source_type\" onchange=\"disableInputFields()\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"oracle\"";
if (sourceType != null && sourceType.equals("oracle"))
msg += " selected";
msg += ">Oracle</option>\n";
msg += "<option value=\"sqlserver\"";
if (sourceType != null && sourceType.equals("sqlserver"))
msg += " selected";
msg += ">SQL Server</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_source_server_name\"><td><b>Source Server Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_server_name\" name=\"source_server_name\" value=" + sourceServerName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_instance_name\"><td><b>Source Instance Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_instance_name\" name=\"source_instance_name\" value=" + sourceInstanceName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_port\"><td><b>Source Port</b></td>";
msg += "<td><input type=\"text\" id=\"source_port\" name=\"source_port\" onkeyup=\"this.value=this.value.replace(/[^\\d]/,'')\" value=" + sourcePort + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_database_name\"><td><b>Source Database Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_database_name\" name=\"source_database_name\" value=" + sourceDatabaseName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_schema_name\"><td><b>Source Schema Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_schema_name\" name=\"source_schema_name\" value=" + sourceSchemaName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_table_name\"><td><b>Source Table Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_table_name\" name=\"source_table_name\" value=" + sourceTableName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_user_name\"><td><b>Source User Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_user_name\" name=\"source_user_name\" value=" + sourceUserName + ">";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_pass\"><td><b>Source Password</b></td>";
msg += "<td><input type=\"password\" id=\"source_pass\" name=\"source_pass\" value=" + sourcePass + ">";
msg += "</td></tr>\n";
msg += "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"" + buttonText + "\"></td></tr>\n";
msg += "</table>\n";
msg += "<input type=\"hidden\" name=\"action_type\" value=\"update\">\n";
msg += "<input type=\"hidden\" name=\"submit_form\" value=\"1\">\n";
if (id != null)
msg += "<input type=\"hidden\" name=\"id\" value=\"" + id + "\">\n";
msg += "</form>\n";
return msg;
}
public static String viewDelete(String id, String refreshType, String targetSchemaName, String targetTableName, boolean targetAppendOnly, boolean targetCompressed, boolean targetRowOrientation, String sourceType, String sourceServerName, String sourceInstanceName, String sourcePort, String sourceDatabaseName, String sourceSchemaName, String sourceTableName, String sourceUserName, String sourcePass, String columnName, String sqlText, boolean snapshot, String scheduleDesc, ArrayList<String> scheduleList)
{
targetSchemaName = OutsourcerView.setHTMLField(targetSchemaName);
targetTableName = OutsourcerView.setHTMLField(targetTableName);
sourceServerName = OutsourcerView.setHTMLField(sourceServerName);
sourceInstanceName = OutsourcerView.setHTMLField(sourceInstanceName);
sourcePort = OutsourcerView.setHTMLField(sourcePort);
sourceDatabaseName = OutsourcerView.setHTMLField(sourceDatabaseName);
sourceSchemaName = OutsourcerView.setHTMLField(sourceSchemaName);
sourceTableName = OutsourcerView.setHTMLField(sourceTableName);
sourceUserName = OutsourcerView.setHTMLField(sourceUserName);
sourcePass = OutsourcerView.setHTMLField(sourcePass);
columnName = OutsourcerView.setHTMLField(columnName);
if (sqlText == null)
sqlText = "";
String myScript = getJavaScriptFunctions();
String onLoad="disableInputFields()";
String msg = OutsourcerView.viewHeader(myScript, onLoad, action);
msg += "<form action=\"jobs\" method=\"post\">\n";
msg += "<table class=\"tftable\" border=\"1\">\n";
msg += "<tr><td width=\"30%\"><b>ID</b></td>";
msg += "<td>" + id + "</td></tr>\n";
msg += "<tr><td><b>Refresh Type</b></td>";
msg += "<td><select id=\"refresh_type\" name=\"refresh_type\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"append\"";
if (refreshType != null && refreshType.equals("append"))
msg += " selected";
msg += ">Append</option>\n";
msg += "<option value=\"ddl\"";
if (refreshType != null && refreshType.equals("ddl"))
msg += " selected";
msg += ">DDL</option>\n";
msg += "<option value=\"refresh\"";
if (refreshType != null && refreshType.equals("refresh"))
msg += " selected";
msg += ">Refresh</option>\n";
msg += "<option value=\"transform\"";
if (refreshType != null && refreshType.equals("transform"))
msg += " selected";
msg += ">Transform</option>\n";
if (!(UI.gpVersion.equals("HAWQ")))
{
msg += "<option value=\"replication\"";
if (refreshType != null && refreshType.equals("replication"))
msg += " selected";
msg += ">Replication</option>\n";
msg += "</select>\n";
}
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_schema_name\"><td><b>Target Schema</b></td>\n";
msg += "<td><input type=\"text\" id=\"target_schema_name\" name=\"target_schema_name\" value=" + targetSchemaName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_table_name\"><td><b>Target Table</b></td>\n";
msg += "<td><input type=\"text\" id=\"target_table_name\" name=\"target_table_name\" value=" + targetTableName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_target_append_only\"><td><b>";
if (UI.gpVersion.equals("AO"))
msg += "Target Append-Optimized";
else
msg += "Target Append-Only";
msg += "</b></td>\n";
msg += "<td><select id=\"target_append_only\" name=\"target_append_only\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"true\"";
if (targetAppendOnly == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetAppendOnly == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_target_compressed\"><td><b>Target Compressed</b></td>\n";
msg += "<td><select id=\"target_compressed\" name=\"target_compressed\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"true\"";
if (targetCompressed == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetCompressed == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_target_row_orientation\"><td><b>Target Row Orientation</b></td>\n";
msg += "<td><select id=\"target_row_orientation\" name=\"target_row_orientation\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"true\"";
if (targetRowOrientation == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (targetRowOrientation == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_column_name\"><td><b>Column Name</b></td>";
msg += "<td><input type=\"column_name\" id=\"column_name\" name=\"column_name\" value=" + columnName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_snapshot\"><td><b>Snapshot</b></td>\n";
msg += "<td><select id=\"snapshot\" name=\"snapshot\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"true\"";
if (snapshot == true)
msg += " selected";
msg += ">True</option>\n";
msg += "<option value=\"false\"";
if (snapshot == false)
msg += " selected";
msg += ">False</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_sql_text\"><td><b>Transform SQL</b></td>";
msg += "<td><textarea readonly cols=\"50\" rows=\"10\" id=\"sql_text\" name=\"sql_text\">" + sqlText + "</textarea>\n";
msg += "</td></tr>\n";
msg += "<tr id=\"r_schedule_desc\"><td><b>Schedule</b></td>";
msg += "<td><select id=\"schedule_desc\" name=\"schedule_desc\"i onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"\"></option>\n";
for (int i = 0; i < scheduleList.size(); i++)
{
msg += "<option value=\"" + scheduleList.get(i) + "\"";
if (scheduleDesc != null && scheduleDesc.equals(scheduleList.get(i)))
msg += " selected";
msg += ">" + scheduleList.get(i) + "</option>\n";
}
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_type\"><td><b>Source Type</b></td>\n";
msg += "<td><select id=\"source_type\" name=\"source_type\" onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\">\n";
msg += "<option value=\"\"></option>\n";
msg += "<option value=\"oracle\"";
if (sourceType != null && sourceType.equals("oracle"))
msg += " selected";
msg += ">Oracle</option>\n";
msg += "<option value=\"sqlserver\"";
if (sourceType != null && sourceType.equals("sqlserver"))
msg += " selected";
msg += ">SQL Server</option>\n";
msg += "</select></td></tr>\n";
msg += "<tr id=\"r_source_server_name\"><td><b>Source Server Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_server_name\" name=\"source_server_name\" value=" + sourceServerName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_instance_name\"><td><b>Source Instance Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_instance_name\" name=\"source_instance_name\" value=" + sourceInstanceName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_port\"><td><b>Port</b></td>";
msg += "<td><input type=\"text\" id=\"source_port\" name=\"source_port\" value=" + sourcePort + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_database_name\"><td><b>Source Database Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_database_name\" name=\"source_database_name\" value=" + sourceDatabaseName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_schema_name\"><td><b>Source Schema Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_schema_name\" name=\"source_schema_name\" value=" + sourceSchemaName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_table_name\"><td><b>Source Table Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_table_name\" name=\"source_table_name\" value=" + sourceTableName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_user_name\"><td><b>Source User Name</b></td>";
msg += "<td><input type=\"text\" id=\"source_user_name\" name=\"source_user_name\" value=" + sourceUserName + " readonly>";
msg += "</td></tr>\n";
msg += "<tr id=\"r_source_pass\"><td><b>Source Password</b></td>";
msg += "<td><input type=\"password\" id=\"source_pass\" name=\"source_pass\" value=" + sourcePass + " readonly>";
msg += "</td></tr>\n";
msg += "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Delete\"></td></tr>\n";
msg += "</table>\n";
msg += "<input type=\"hidden\" name=\"action_type\" value=\"delete\">\n";
msg += "<input type=\"hidden\" name=\"submit_form\" value=\"1\">\n";
msg += "<input type=\"hidden\" name=\"id\" value=\"" + id + "\">\n";
msg += "</form>\n";
return msg;
}
private static String getHeader(String sortBy, String sort)
{
String downArrow = "↓";
String upArrow = "↑";
String defaultSort = "asc";
String manageHeader = "<th><b>Manage</b></th>\n";
String IDHeader = "<th><b>ID</b><button ";
String IDFocus = "";
String IDArrow = downArrow;
String IDSort = defaultSort;
String refreshTypeHeader = "<th><b>Type</b><button ";
String refreshTypeFocus = "";
String refreshTypeArrow = downArrow;
String refreshTypeSort = defaultSort;
String sourceHeader = "<th><b>Source</b><button ";
String sourceFocus = "";
String sourceArrow = downArrow;
String sourceSort = defaultSort;
String targetHeader = "<th><b>Target</b><button ";
String targetFocus = "";
String targetArrow = downArrow;
String targetSort = defaultSort;
String scheduleHeader = "<th><b>Schedule</b><button ";
String scheduleFocus = "";
String scheduleArrow = downArrow;
String scheduleSort = defaultSort;
String scheduleNextHeader = "<th><b>Schedule Next</b><button ";
String scheduleNextFocus = "";
String scheduleNextArrow = downArrow;
String scheduleNextSort = defaultSort;
if (sortBy.equals("id"))
{
IDFocus = OutsourcerView.focus;
if (sort.equals("asc"))
IDSort = "desc";
else
{
IDSort = "asc";
IDArrow = upArrow;
}
}
else if (sortBy.equals("refresh_type"))
{
refreshTypeFocus = OutsourcerView.focus;
if (sort.equals("asc"))
refreshTypeSort = "desc";
else
{
refreshTypeSort = "asc";
refreshTypeArrow = upArrow;
}
}
else if (sortBy.equals("source_info"))
{
sourceFocus = OutsourcerView.focus;
if (sort.equals("asc"))
sourceSort = "desc";
else
{
sourceSort = "asc";
sourceArrow = upArrow;
}
}
else if (sortBy.equals("target_table_name"))
{
targetFocus = OutsourcerView.focus;
if (sort.equals("asc"))
targetSort = "desc";
else
{
targetSort = "asc";
targetArrow = upArrow;
}
}
else if (sortBy.equals("schedule_desc"))
{
scheduleFocus = OutsourcerView.focus;
if (sort.equals("asc"))
scheduleSort = "desc";
else
{
scheduleSort = "asc";
scheduleArrow = upArrow;
}
}
else if (sortBy.equals("schedule_next"))
{
scheduleNextFocus = OutsourcerView.focus;
if (sort.equals("asc"))
scheduleNextSort = "desc";
else
{
scheduleNextSort = "asc";
scheduleNextArrow = upArrow;
}
}
IDHeader += IDFocus + "onclick=\"sortRS('id', '" + IDSort + "')\">" + IDArrow + "</button></th>\n";
refreshTypeHeader += refreshTypeFocus + "onclick=\"sortRS('refresh_type', '" + refreshTypeSort + "')\">" + refreshTypeArrow + "</button></th>\n";
sourceHeader += sourceFocus + "onclick=\"sortRS('source_info', '" + sourceSort + "')\">" + sourceArrow + "</button></th>\n";
targetHeader += targetFocus + "onclick=\"sortRS('target_table_name', '" + targetSort + "')\">" + targetArrow + "</button></th>\n";
scheduleHeader += scheduleFocus + "onclick=\"sortRS('schedule_desc', '" + scheduleSort + "')\">" + scheduleArrow + "</button></th>\n";
scheduleNextHeader += scheduleNextFocus + "onclick=\"sortRS('schedule_next', '" + scheduleNextSort + "')\">" + scheduleNextArrow + "</button></th>\n";
String msg = "<table class=\"tftable\" border=\"1\">\n";
msg += "<tr>\n";
msg += manageHeader + IDHeader + refreshTypeHeader + sourceHeader + targetHeader + scheduleHeader + scheduleNextHeader;
msg += "</tr>\n";
return msg;
}
public static String viewDelete()
{
String myScript = getJavaScriptFunctions();
String onLoad="";
String msg = OutsourcerView.viewHeader(myScript, onLoad, action);
msg += "<form action=\"jobs\" method=\"post\">\n";
msg += "<table class=\"tftable\" border=\"1\">\n";
msg += "<tr><td><b>Delete all jobs?</b></td>";
msg += "<td><input type=\"submit\" value=\"Delete\"></td></tr>\n";
msg += "</table>\n";
msg += "<input type=\"hidden\" name=\"action_type\" value=\"delete_all\">\n";
msg += "<input type=\"hidden\" name=\"submit_form\" value=\"1\">\n";
msg += "</form>\n";
return msg;
}
}