00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032
00033
00034
00035
00036
00037
00038
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 var RecordWiz = RecordWiz || {};
00119
00120 if (typeof Debug == 'undefined')
00121 console.log('ERROR: Debug is undefined! Must include Debug.js before RecordWiz_ConfigurationGUI.js');
00122 else if (typeof Globals == 'undefined')
00123 console.log('ERROR: Globals is undefined! Must include Globals.js before RecordWiz_ConfigurationGUI.js');
00124 else
00125 RecordWiz.wiz;
00126
00127
00130
00133 RecordWiz.createWiz = function(doneHandler, recordsAliasFastForward) {
00134
00135
00136 var _TABLE_BOOL_TYPE_TRUE_COLOR = "rgb(201, 255, 201)";
00137 var _TABLE_BOOL_TYPE_FALSE_COLOR = "rgb(255, 178, 178)";
00138
00139
00140
00141
00142 var _recordAlias;
00143 var _doneHandler = doneHandler;
00144 var _aRecordWasModified = false;
00145
00146 var _RECORD_TYPE_FE = "Front-end";
00147 var _RECORD_TYPE_PROCESSOR = "Processor";
00148 var _RECORD_TYPE_CONSUMER = "Consumer";
00149 var _RECORD_TYPE_PRODUCER = "Producer";
00150 var _validRecordTypes = [_RECORD_TYPE_FE,_RECORD_TYPE_PROCESSOR];
00151
00152
00154 function localParameterCheck()
00155 {
00156
00157 var i=_validRecordTypes.length-1;
00158 for(i;i>=0;--i)
00159 if(_validRecordTypes[i] == _recordAlias) break;
00160 if(i<0)
00161 {
00162 var str = "Invalid Record Alias '" + _recordAlias + "' was specified. " +
00163 "The only valid record aliases are as follows: ";
00164
00165 for(i=_validRecordTypes.length-1;i>=0;--i)
00166 str += "<br>\t" + _validRecordTypes[i];
00167 Debug.log(str,Debug.HIGH_PRIORITY);
00168 return false;
00169 }
00170 return true;
00171 }
00172
00173
00174 var _subsetUIDs;
00175 var _systemGroups;
00176 var _paramObjMap;
00177 var _furthestStep = -1;
00178 var _lastNextStep = -1;
00179 var _intermediateLevel = -1;
00180
00181
00182 var _modifiedTables;
00183
00184
00185 var _STEP_OUT_OF_SEQUENCE = 1000;
00186
00187 var
00188 _STEP_PROC_WHICH_BUFFER = 200,
00189 _STEP_SET_RECORD_FIELDS = 104,
00190 _STEP_WHICH_APP = 103,
00191 _STEP_SET_CONTEXT_HOST = 102,
00192 _STEP_WHICH_CONTEXT = 101,
00193 _STEP_CHANGE_GROUP = 1000,
00194 _STEP_GET_RECORD_NAME = 100,
00195 _STEP_WHICH_RECORD_TYPE = 20;
00196
00197
00198 var _START_STEP_INDEX = _STEP_GET_RECORD_NAME;
00199
00200 var _XDAQ_BASE_PATH = "XDAQContextConfiguration";
00201 var _XDAQAPP_BASE_PATH = "XDAQApplicationConfiguration";
00202
00203 var _DEFAULT_WIZ_COMMENT= "Generated by Record Creation Wiz";
00204
00207
00208 Debug.log("RecordWiz.wiz constructed");
00209 RecordWiz.wiz = this;
00210
00211
00212 if(!recordsAliasFastForward || recordsAliasFastForward == "")
00213 {
00214 DesktopContent.tooltip("Record Wizard Introduction",
00215 "Welcome to the Record Wizard GUI. Here you can create new records for "+
00216 "your <i>otsdaq</i> system. \n\n" +
00217 "The Record Wizard is presented as a step-by-step process that will walk you through creating the skeleton for your new record.\n\n" +
00218
00219 "Briefly, here is a description of the steps: " +
00220 "\n\t- 'What type of record do you want to add?'" +
00221 "\n\t- 'Do you want to add it to an existing context or create a new one?'"
00222 );
00223
00224 showPrompt(_STEP_WHICH_RECORD_TYPE);
00225 }
00226 else
00227 {
00228 _recordAlias = recordsAliasFastForward;
00229 if(!localParameterCheck())
00230 {
00231 Debug.log("Invalid parameters to the Record Creation Wizard!", Debug.HIGH_PRIORITY);
00232 return;
00233 }
00234
00235
00236 DesktopContent.tooltip(_recordAlias + " Wizard Introduction",
00237 "Welcome to the " + _recordAlias + " Wizard GUI. Here you can create new records for " +
00238 "your <i>otsdaq</i> system. \n\n" +
00239 "The " + _recordAlias + " Wizard is presented as a step-by-step process that will walk you through creating the skeleton for your new " +
00240 _recordAlias + ".\n\n" +
00241 "Briefly, here is a description of the steps: " +
00242 "\n\t- 'Do you want to add your " + _recordAlias + " to an existing context or create a new one?'"
00243 );
00244
00245 initRecordWizard();
00246 }
00247
00248 return;
00249
00252
00253
00254
00255
00256
00257 function xdaqContextTooltip()
00258 {
00259 DesktopContent.tooltip("XDAQ Contexts",
00260 "The lowest level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Context. " +
00261 "What is a XDAQ Context? Why do I need a XDAQ Context? Do I want a new one for my " + _recordAlias + " or not?" +
00262 "<br><br>" +
00263 "XDAQ Contexts are the fundamental executable program building blocks of <i>otsdaq</i>. " +
00264 "A XDAQ Context runs a group of XDAQ Applications inside of it. If one of those XDAQ Applications crashes, " +
00265 "then only the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
00266 "<br><br>" +
00267 "Two other useful features of XDAQ Contexts are that they can easily be turned on and off (enabled and disabled through the configuration editors), and " +
00268 "they can easily be distributed to other nodes (computers) in your DAQ system when your system scales up."
00269 );
00270 }
00271
00272
00273 function xdaqApplicationTooltip()
00274 {
00275 DesktopContent.tooltip("XDAQ Applications",
00276 "The second level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Application. " +
00277 "What is a XDAQ Application? Why do I need a XDAQ Application? Do I want a new one for my " + _recordAlias + " or not?" +
00278 "<br><br>" +
00279 "XDAQ Applications are server processes that can be controlled by <i>otsdaq</i> through network messages. " +
00280 "Ther can be one or many XDAQ Applciation in a XDAQ Context. If one of those XDAQ Applications crashes, " +
00281 "then all of the other XDAQ Applications in the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
00282 "<br><br>" +
00283 "Two other useful features of XDAQ Applications are that they can respond to web requests and state machine transitions."
00284 );
00285 }
00286
00287
00288
00289
00290
00291 function initRecordWizard()
00292 {
00293 _subsetUIDs = [];
00294 _modifiedTables = undefined;
00295 _furthestStep = -1;
00296 _paramObjMap = {};
00297 _systemGroups = {};
00298
00299 {
00300
00301 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00302 while(el)
00303 {
00304 el.parentNode.removeChild(el);
00305 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00306 }
00307 }
00308
00309
00310
00311 ConfigurationAPI.getAliasesAndGroups(
00312 function(retObj)
00313 {
00314 _systemGroups = retObj;
00315 console.log("_systemGroups",_systemGroups);
00316 console.log("ConfigurationAPI._activeGroups",ConfigurationAPI._activeGroups);
00317
00318
00319
00320 ConfigurationAPI.getSubsetRecords(
00321 getRecordConfiguration(),
00322 getRecordFilter() ,
00323 function(records)
00324 {
00325 _subsetUIDs = records;
00326 Debug.log("records found = " + records.length);
00327 console.log(records);
00328
00329 showPrompt(_STEP_GET_RECORD_NAME);
00330
00331 },_modifiedTables);
00332
00333 });
00334
00335 }
00336
00337
00338
00339
00340
00341 function showPrompt(stepIndex,paramObj)
00342 {
00343
00344 if(!stepIndex) stepIndex = 0;
00345
00346 if(stepIndex > _furthestStep &&
00347 _furthestStep < _STEP_OUT_OF_SEQUENCE)
00348 _furthestStep = stepIndex;
00349
00350 Debug.log("showPrompt " + stepIndex);
00351 Debug.log("_furthestStep " + _furthestStep);
00352
00353
00354 if(!_paramObjMap) _paramObjMap = {};
00355
00356
00357 if(paramObj)
00358 _paramObjMap[stepIndex] = paramObj;
00359 else if(_paramObjMap[stepIndex])
00360 paramObj = _paramObjMap[stepIndex];
00361 else
00362 {
00363
00364 _paramObjMap[stepIndex] = {};
00365 paramObj = _paramObjMap[stepIndex];
00366 }
00367
00368 console.log("_paramObjMap",_paramObjMap);
00369 console.log("paramObj",paramObj);
00370
00371 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00372
00373
00374 while(el)
00375 {
00376 el.parentNode.removeChild(el);
00377 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00378 }
00379
00380
00381
00382 var w = 480;
00383 var h = 340;
00384
00385 var str = "";
00386 var stepString = "stepIndex-" + stepIndex + "-";
00387
00388 var showPrevButton = true;
00389 var showNextButton = true;
00390 var prevStepIndex = stepIndex-1;
00391 if(prevStepIndex > _lastNextStep)
00392 prevStepIndex = _lastNextStep;
00393 _lastNextStep = stepIndex;
00394
00395 var nextStepIndex = stepIndex+1;
00396 var prevButtonText = "Go Back";
00397 var nextButtonText = "Next Step";
00398
00399 var recordName = "";
00400 try
00401 {
00402 recordName = _paramObjMap[_STEP_GET_RECORD_NAME]["recordName"];
00403 } catch(e){;}
00404
00407
00408 localAddContent();
00409 function localAddContent()
00410 {
00411 switch(stepIndex)
00412 {
00413 case _STEP_PROC_WHICH_BUFFER:
00414
00415 h = 370;
00416
00417 showNextButton = false;
00418
00419
00420 Debug.log("_STEP_PROC_WHICH_BUFFER " + recordName);
00421
00422
00423 str += "<br>";
00424 str += "Do you want to add the " + _recordAlias + " named '" +
00425 recordName + "' to a new Data Manager Buffer " +
00426 "or an existing one in the Data Manager '" +
00427 _paramObjMap[_STEP_WHICH_APP]["appName"] + "'?";
00428
00429 str += "<center>";
00430 str += "<table style='margin-bottom: 10px;'>";
00431
00433 {
00434 str += "<tr><td><b>New Buffer:</b></td><td>";
00435
00436 str += htmlOpen("input",
00437 {
00438 "type" : "text",
00439 "id" : stepString + "bufferName",
00440 "value": (paramObj["bufferName"]?paramObj["bufferName"]:
00441 ConfigurationAPI.createNewRecordName("Buffer",
00442 paramObj["allBuffers"])),
00443 }, "" , true );
00444
00445 str += htmlOpen("input",
00446 {
00447 "id": stepString + "addToNew",
00448 "type": "button",
00449 "value": "Add to New",
00450 "title": "Create a new Buffer and add the new " +
00451 _recordAlias + " to it."
00452 },
00453 0 , true );
00454 str += "</td></tr>";
00455 }
00456
00457 if(paramObj["buffers"].length)
00458 {
00459 str += "<tr><td><b>Existing Buffers:</b></td><td>";
00460 {
00461 str += htmlOpen("select",
00462 {
00463 "id" : stepString + "buffers",
00464 });
00465
00466 for(var i=0;i<paramObj["buffers"].length;++i)
00467 {
00468 str += htmlOpen("option",
00469 {
00470 },
00471 paramObj["buffers"][i] , true );
00472 }
00473 str += "</select>";
00474 str += htmlOpen("input",
00475 {
00476 "id": stepString + "addToExisting",
00477 "type": "button",
00478 "value": "Add to Existing",
00479 "title": "Add new " + _recordAlias +
00480 " to the chosen existing Buffer."
00481 },
00482 0 , true );
00483 }
00484 str += "</td></tr>";
00485 }
00486
00487 str += "</table>";
00488
00489
00490 if(paramObj["allBuffers"].length)
00491 {
00493
00494 str += htmlClearDiv();
00495 str += "Here is a dropdown of all existing Buffers " +
00496 " to help you in creating standardized names (Note: shown above are " +
00497 "only the Buffers in the chosen Data Manager '" +
00498 _paramObjMap[_STEP_WHICH_APP]["appName"] +
00499 "':";
00500
00501 str += htmlClearDiv();
00502 str += htmlOpen("select",
00503 {
00504 "id" : stepString + "allBuffers",
00505 "style" : "margin-bottom: 16px;"
00506 });
00507
00508 for(var i=0;i<paramObj["allBuffers"].length;++i)
00509 {
00510 str += htmlOpen("option",
00511 {
00512 },
00513 paramObj["allBuffers"][i] , true );
00514 }
00515 str += "</select>";
00516 }
00517
00518
00519
00520 str += "</center>";
00521 break;
00522
00523 case _STEP_SET_RECORD_FIELDS:
00524
00525 Debug.log("_STEP_SET_RECORD_FIELDS ");
00526
00527 nextButtonText = "Done!";
00528
00529 str += "<br>";
00530 str += "Please edit the fields for your record and then click 'Done!' to save " +
00531 " your new " + _recordAlias + " named '" + recordName + "':";
00532
00533 str += htmlClearDiv();
00534 str += htmlOpen("div",
00535 {
00536 "id" : stepString + "fields",
00537 "style" : "margin: 20px;",
00538
00539 }, "" , true );
00540 str += htmlClearDiv();
00541
00542 break;
00543
00544 case _STEP_WHICH_APP:
00545
00546 h = 370;
00547
00548 xdaqApplicationTooltip();
00549
00550 showNextButton = false;
00551
00552
00553 Debug.log("_STEP_WHICH_APP " + recordName);
00554
00555
00556 str += "<br>";
00557 str += "Do you want to add the " + _recordAlias + " named '" +
00558 recordName + "' to a new XDAQ " + getAppClass() +
00559 " Application or an existing one in the context '" +
00560 _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"] + "'?";
00561
00562 str += "<center>";
00563 str += "<table style='margin-bottom: 10px;'>";
00564
00566 {
00567 str += "<tr><td><b>New XDAQ App:</b></td><td>";
00568
00569 str += htmlOpen("input",
00570 {
00571 "type" : "text",
00572 "id" : stepString + "appName",
00573 "value": (paramObj["appName"]?paramObj["appName"]:
00574 ConfigurationAPI.createNewRecordName(getApp(),paramObj["allApps"])),
00575 }, "" , true );
00576
00577 str += htmlOpen("input",
00578 {
00579 "id": stepString + "addToNew",
00580 "type": "button",
00581 "value": "Add to New",
00582 "title": "Create a new XDAQ Application and add the new " + _recordAlias + " to it."
00583 },
00584 0 , true );
00585 str += "</td></tr>";
00586 }
00587
00588 if(paramObj["apps"].length)
00589 {
00590 str += "<tr><td><b>Existing Apps:</b></td><td>";
00591 {
00592 str += htmlOpen("select",
00593 {
00594 "id" : stepString + "apps",
00595 });
00596
00597 for(var i=0;i<paramObj["apps"].length;++i)
00598 {
00599 str += htmlOpen("option",
00600 {
00601 },
00602 paramObj["apps"][i] , true );
00603 }
00604 str += "</select>";
00605 str += htmlOpen("input",
00606 {
00607 "id": stepString + "addToExisting",
00608 "type": "button",
00609 "value": "Add to Existing",
00610 "title": "Add new " + _recordAlias + " to the chosen existing XDAQ Application."
00611 },
00612 0 , true );
00613 }
00614 str += "</td></tr>";
00615 }
00616
00617 str += "</table>";
00618
00619
00620 if(paramObj["allApps"].length)
00621 {
00623
00624 str += htmlClearDiv();
00625 str += "Here is a dropdown of all existing XDAQ Applications " +
00626 " to help you in creating standardized names (Note: shown above are " +
00627 "only apps with class " + getAppClass() + " and in the chosen context '" +
00628 _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"] +
00629 "'):";
00630
00631 str += htmlClearDiv();
00632 str += htmlOpen("select",
00633 {
00634 "id" : stepString + "allApps",
00635 "style" : "margin-bottom: 16px;"
00636 });
00637
00638 for(var i=0;i<paramObj["allApps"].length;++i)
00639 {
00640 str += htmlOpen("option",
00641 {
00642 },
00643 paramObj["allApps"][i] , true );
00644 }
00645 str += "</select>";
00646 }
00647
00648
00649
00650 str += "</center>";
00651 break;
00652
00653 case _STEP_SET_CONTEXT_HOST:
00654
00655 if(paramObj["isNewContext"])
00656 str += "Please enter the Host Address and Port for the " +
00657 "new Context named '" +
00658 _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"] + "':";
00659 else
00660 str += "Please verify the Host Address and Port for the " +
00661 "existing Context named '" +
00662 _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"] + "':";
00663
00664 str += "<center>";
00665 str += "<table style=''>";
00666
00668 {
00669 str += "<tr><td><b>Address:</b></td><td>";
00670
00671 str += htmlOpen("input",
00672 {
00673 "type" : "text",
00674 "id" : stepString + "address",
00675 "value" : (paramObj["address"]?paramObj["address"]:""),
00676 }, "" , true );
00677
00678 str += "</td></tr>";
00679 }
00681 {
00682 str += "<tr><td><b>Port:</b></td><td>";
00683
00684 str += htmlOpen("input",
00685 {
00686 "type" : "text",
00687 "id" : stepString + "port",
00688 "value" : (paramObj["port"]?paramObj["port"]:""),
00689 }, "" , true );
00690
00691 str += "</td></tr>";
00692 }
00693
00694 str += "</table>";
00695 str += "</center>";
00696
00698
00699 str += htmlClearDiv();
00700 str += "Here is a dropdown of existing Host Addresses " +
00701 " to help you in creating standardized addresses:";
00702 str += htmlClearDiv();
00703 str += htmlOpen("select",
00704 {
00705 "id" : stepString + "addresses",
00706 "style" : "margin-bottom: 16px;"
00707 });
00708
00709
00710 for(var i=0;i<paramObj["hostAddresses"].length;++i)
00711 {
00712 str += htmlOpen("option",
00713 {
00714 },paramObj["hostAddresses"][i] , true );
00715 }
00716 str += "</select>";
00717
00719
00720 str += htmlClearDiv();
00721 str += "Here is a dropdown of existing Host Ports " +
00722 " to help you in creating standardized ports:";
00723 str += htmlClearDiv();
00724 str += htmlOpen("select",
00725 {
00726 "id" : stepString + "ports",
00727 "style" : ""
00728 });
00729
00730
00731 for(var i=0;i<paramObj["hostPorts"].length;++i)
00732 {
00733 str += htmlOpen("option",
00734 {
00735 },paramObj["hostPorts"][i] , true );
00736 }
00737 str += "</select>";
00738
00739 break;
00740
00741 case _STEP_WHICH_CONTEXT:
00742
00743 xdaqContextTooltip();
00744
00745 showNextButton = false;
00746
00747
00748 Debug.log("_STEP_WHICH_CONTEXT " + recordName);
00749
00750
00751 str += "<br>";
00752 str += "Do you want to add the " + _recordAlias + " named '" +
00753 recordName + "' to a new XDAQ Context or an existing one?";
00754
00755
00756 str += "<center>";
00757 str += "<table style='margin-bottom: 10px;'>";
00758
00760 {
00761 str += "<tr><td><b>New XDAQ Context:</b></td><td>";
00762
00763 str += htmlOpen("input",
00764 {
00765 "type" : "text",
00766 "id" : stepString + "contextName",
00767 "value": (paramObj["contextName"]?paramObj["contextName"]:""),
00768 }, "" , true );
00769
00770 str += htmlOpen("input",
00771 {
00772 "id": stepString + "addToNew",
00773 "type": "button",
00774 "value": "Add to New",
00775 "title": "Create a new XDAQ Context and add the new " + _recordAlias + " to it."
00776 },
00777 0 , true );
00778 str += "</td></tr>";
00779 }
00780
00781 if(paramObj["contexts"].length)
00782 {
00783 str += "<tr><td><b>Existing Contexts:</b></td><td>";
00784 {
00785 str += htmlOpen("select",
00786 {
00787 "id" : stepString + "contexts",
00788 });
00789
00790 for(var i=0;i<paramObj["contexts"].length;++i)
00791 {
00792 str += htmlOpen("option",
00793 {
00794 },
00795 paramObj["contexts"][i] , true );
00796 }
00797 str += "</select>";
00798 str += htmlOpen("input",
00799 {
00800 "id": stepString + "addToExisting",
00801 "type": "button",
00802 "value": "Add to Existing",
00803 "title": "Add new " + _recordAlias + " to the chosen existing XDAQ Context."
00804 },
00805 0 , true );
00806 }
00807 str += "</td></tr>";
00808 }
00809
00810 str += "</table>";
00811 str += "</center>";
00812
00813 break;
00814
00815 case _STEP_CHANGE_GROUP:
00816
00817
00818 showNextButton = false;
00819 nextStepIndex = _STEP_GET_RECORD_NAME;
00820 prevStepIndex = _STEP_GET_RECORD_NAME;
00821
00822 str += "Choose a '" + paramObj["groupType"] +
00823 "' group to activate (either a System Alias or specific group):";
00824
00825 str += htmlClearDiv();
00826
00827 str += "<center>";
00828 str += "<table style='margin-bottom: 10px;'>";
00829 if(_systemGroups.aliases[paramObj["groupType"]].length)
00830 {
00831 str += "<tr><td><b>System Aliases:</b></td><td>";
00832 {
00833 str += htmlOpen("select",
00834 {
00835 "id" : stepString + "aliases",
00836 });
00837
00838 for(var i=0;i<_systemGroups.aliases[paramObj["groupType"]].length;++i)
00839 {
00840 str += htmlOpen("option",
00841 {
00842 },
00843 _systemGroups.aliases[paramObj["groupType"]]
00844 [i].alias , true );
00845 }
00846 str += "</select>";
00847 str += htmlOpen("input",
00848 {
00849 "id": stepString + "activateAlias",
00850 "type": "button",
00851 "value": "Activate Alias",
00852 "title": "Activate chosen System Alias and return to creating your new " + _recordAlias + "."
00853 },
00854 0 , true );
00855 }
00856 str += "</td></tr>";
00857 }
00858 else
00859 str += "<tr><td colspan='2'>No system aliases of type Context found.</td></tr>";
00860
00861 var groupNames = Object.keys(_systemGroups.groups[paramObj["groupType"]]);
00862 if(groupNames.length)
00863 {
00864 str += "<tr><td><b>Group Names:</b></td><td>";
00865 {
00866 str += htmlOpen("select",
00867 {
00868 "id" : stepString + "groupNames",
00869 });
00870
00871 for(var i=0;i<groupNames.length;++i)
00872 {
00873 str += htmlOpen("option",
00874 {
00875 },
00876 groupNames[i] , true );
00877 }
00878 str += "</select>";
00879
00880 }
00881 str += "</td></tr>";
00882 }
00883 else
00884 str += "<tr><td colspan='2'>No groups of type Context found.</td></tr>";
00885
00886 if(groupNames.length)
00887 {
00888 str += "<tr><td><b>Group Keys:</b></td><td>";
00889 {
00890 str += htmlOpen("select",
00891 {
00892 "id" : stepString + "groupKeys",
00893 });
00894
00895 for(var i=0;i<_systemGroups.groups[paramObj["groupType"]]
00896 [groupNames[0]].keys.length;++i)
00897 {
00898 str += htmlOpen("option",
00899 {
00900 },
00901 _systemGroups.groups[paramObj["groupType"]]
00902 [groupNames[0]].keys[i] , true );
00903 }
00904 str += "</select>";
00905 str += htmlOpen("input",
00906 {
00907 "id": stepString + "activateGroup",
00908 "type": "button",
00909 "value": "Activate Group",
00910 "title": "Activate chosen Group and Key pair and return to creating your new " + _recordAlias + "."
00911 },
00912 0 , true );
00913 }
00914 str += "</td></tr>";
00915 }
00916 str += "</table>";
00917 str += "</center>";
00918
00919 break;
00920
00921 case _STEP_GET_RECORD_NAME:
00922
00923
00924 prevStepIndex = _STEP_WHICH_RECORD_TYPE;
00925
00927
00928 str += htmlOpen("div",
00929 {
00930 "style" : "font-weight:bold; margin: 6px 0 20px 0;"
00931 },
00932 (_aRecordWasModified?
00933 ("Would you like to create another " + _recordAlias + "?"):
00934 ("Welcome to the " + _recordAlias + " creation Wizard!")) ,
00935 true );
00936 str += htmlClearDiv();
00937
00939
00940 str += "Enter the unique record name for your " + _recordAlias + ": ";
00941 str += htmlClearDiv();
00942 str += htmlOpen("input",
00943 {
00944 "type" : "text",
00945 "id" : stepString + "recordName",
00946 "style" : "margin-bottom: 16px;",
00947 "value" : (paramObj["recordName"]?paramObj["recordName"]:""),
00948 }, "" , true );
00949
00950
00951
00953
00954 str += htmlClearDiv();
00955 str += "Here is a dropdown of existing " + _recordAlias +
00956 " records to help you in creating standardized record names:";
00957 str += htmlClearDiv();
00958
00959
00960 str += htmlOpen("select",
00961 {
00962 "id" : stepString + "records",
00963 "style" : "margin-bottom: 16px;",
00964 });
00965
00966
00967 for(var i=0;i<_subsetUIDs.length;++i)
00968 {
00969 str += htmlOpen("option",
00970 {
00971 },_subsetUIDs[i] , true );
00972 }
00973 str += "</select>";
00974
00975
00976 str += htmlOpen("div",
00977 {
00978 "id" : stepString + "deleteRecordIcon",
00979 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-deleteIcon",
00980 "style" : "float: right; margin: 6px 112px -16px -200px; display: block;",
00981
00982 }, 0 , true );
00983
00984
00985
00986 str += htmlOpen("div",
00987 {
00988 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
00989 "-preloadImage-editIconHover",
00990 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-preloadImage",
00991 }, 0 , true );
00992 str += htmlOpen("div",
00993 {
00994 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
00995 "-preloadImage-treeEditTrashIconHover",
00996 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-preloadImage",
00997 }, 0 , true );
00998
00999
01001
01002 str += htmlClearDiv();
01003 str += "Note you are currently editing these active groups:";
01004 str += "<center>";
01005 str += "<table style='margin-bottom: 10px;'>";
01006 str += "<tr><td><b>Active Context:</b></td><td>";
01007 str += ConfigurationAPI._activeGroups.Context.groupName + " (" + ConfigurationAPI._activeGroups.Context.groupKey + ")";
01008
01009
01010 str += htmlOpen("div",
01011 {
01012 "id": stepString + "editContext",
01013 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-editIcon",
01014 "style": "float:right; display:block; margin: -3px 0 0 10px;",
01015 "title": "Click to activate a different Context group.",
01016
01017 }, 0 , true );
01018
01019 str += "</td></tr>";
01020 str += "<tr><td><b>Active Configuration:</b></td><td>";
01021 str += _systemGroups.activeGroups.Configuration.groupName + " (" + _systemGroups.activeGroups.Configuration.groupKey + ")";
01022
01023 str += htmlOpen("div",
01024 {
01025 "id": stepString + "editConfig",
01026 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-editIcon",
01027 "style": "float:right; display:block; margin: -3px 0 0 10px;",
01028 "title": "Click to activate a different Configuration group.",
01029 }, 0 , true );
01030
01031 str += "</td></tr>";
01032 str += "</table>";
01033 str += "</center>";
01034
01035
01036 break;
01037 case _STEP_WHICH_RECORD_TYPE:
01038
01039 nextStepIndex = _STEP_GET_RECORD_NAME;
01040 prevButtonText = "Close Wizard";
01041
01043
01044 str += htmlOpen("div",
01045 {
01046 "style" : "font-weight:bold; margin: 6px 0 20px 0;"
01047 },
01048 "Welcome to the record creation Wizard!" ,
01049 true );
01050 str += htmlClearDiv();
01051
01053
01054 str += htmlClearDiv();
01055 str += "Below is a dropdown of record types that this Wizard can help you create. " +
01056 " Choose one and proceed through the steps to create your new record:";
01057 str += htmlClearDiv();
01058 str += htmlOpen("select",
01059 {
01060 "id" : stepString + "recordTypes",
01061 "style" : "margin-bottom: 16px;"
01062 });
01063
01064 for(var i=0;i<_validRecordTypes.length;++i)
01065 {
01066 str += htmlOpen("option",
01067 {
01068 },_validRecordTypes[i] , true );
01069 }
01070 str += "</select>";
01071
01072 break;
01073 default:
01074 Debug.log("Should never happen - bad stepIndex (" + stepIndex +
01075 ")!",Debug.HIGH_PRIORITY);
01076 return;
01077 }
01078
01079
01080
01081 var ctrlStr = "";
01082
01083 if(stepIndex && showPrevButton)
01084 ctrlStr += htmlOpen("input",
01085 {
01086 "class": "prevButton " + stepString + "prevButton",
01087 "type": "button",
01088 "value": prevButtonText,
01089 "title": "Return to the previous step in the " + _recordAlias + " creation wizard."
01090 },
01091 0 , true );
01092 if(showNextButton)
01093 ctrlStr += htmlOpen("input",
01094 {
01095 "class": "nextButton " + stepString + "nextButton",
01096 "type": "button",
01097 "value": nextButtonText,
01098 "title": "Proceed to the next step in the " + _recordAlias + " creation wizard."
01099 },
01100 0 , true );
01101
01102
01103
01104 el = document.createElement("div");
01105 el.setAttribute("id", ConfigurationAPI._POP_UP_DIALOG_ID);
01106
01107 ConfigurationAPI.setPopUpPosition(el,w ,h );
01108
01109 el.innerHTML = ctrlStr + htmlClearDiv() + str + htmlClearDiv() + ctrlStr;
01110 document.body.appendChild(el);
01111 }
01112
01113
01116
01117 localAddHandlers();
01118 function localAddHandlers()
01119 {
01120 var newParamObj = {};
01121
01123
01124 switch(stepIndex)
01125 {
01126 case _STEP_SET_RECORD_FIELDS:
01127
01128 {
01129
01130 scopeForSetRecordFieldsContent();
01132 function scopeForSetRecordFieldsContent()
01133 {
01134 var recordFields = paramObj["fields"];
01135
01136 var fieldContainerEl = document.getElementById(stepString + "fields");
01137
01138
01139 ConfigurationAPI.editableField_SELECTED_COLOR_ = "transparent";
01140
01141
01142
01143
01144
01145
01146 for(var i=0;i<recordFields.length;++i)
01147 {
01148 el = document.createElement("div");
01149 el.setAttribute("id", "cfg_subset_field-" + i);
01150 el.setAttribute("style", "white-space:nowrap;" +
01151 "margin: 5px;");
01152 fieldContainerEl.appendChild(el);
01153
01154
01155 el.appendChild(ConfigurationAPI.createEditableFieldElement(
01156 recordFields[i],i));
01157
01158
01159 el = document.createElement("div");
01160 el.setAttribute("id", "clearDiv");
01161 fieldContainerEl.appendChild(el);
01162 }
01163 }
01164
01165 }
01166 break;
01167
01168 case _STEP_PROC_WHICH_BUFFER:
01169
01170 {
01171
01172
01173 document.getElementById(stepString + "buffers").onclick = localAppSelectHandler;
01174 document.getElementById(stepString + "buffers").onchange = localAppSelectHandler;
01175 document.getElementById(stepString + "allBuffers").onclick = localAppSelectHandler;
01176 document.getElementById(stepString + "allBuffers").onchange = localAppSelectHandler;
01177
01178 function localAppSelectHandler(event) {
01179 Debug.log("Selected " + this.value);
01180
01181
01182 document.getElementById(stepString + "bufferName").value =
01183 ConfigurationAPI.incrementName(this.value);
01184 };
01185
01187 document.getElementById(stepString + "addToNew").onclick =
01188 function()
01189 {
01190 var name = document.getElementById(stepString + "bufferName").value.trim();
01191 Debug.log("addToNew " + name);
01192
01193
01194 paramObj["bufferName"] = name;
01195
01196 localCreateIntermediateLevelRecord(name);
01197 };
01198
01200 document.getElementById(stepString + "addToExisting").onclick =
01201 function()
01202 {
01203 var name = document.getElementById(stepString + "buffers").value.trim();
01204 Debug.log("addToExisting " + name);
01205
01206
01207 paramObj["bufferName"] = name;
01208
01209 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]["buffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER]["buffers"] = [];
01210 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["isNew" + getIntermediateTypeName()] = false;
01211
01212
01213 localGetExistingIntermediateTargetGroupID(name);
01214
01215 };
01216
01217 }
01218
01219
01220
01221
01222
01223 break;
01224 case _STEP_WHICH_APP:
01225
01226 {
01227
01228
01229 document.getElementById(stepString + "apps").onclick = localAppSelectHandler;
01230 document.getElementById(stepString + "apps").onchange = localAppSelectHandler;
01231 document.getElementById(stepString + "allApps").onclick = localAppSelectHandler;
01232 document.getElementById(stepString + "allApps").onchange = localAppSelectHandler;
01233
01234 function localAppSelectHandler(event) {
01235 Debug.log("Selected " + this.value);
01236
01237
01238 document.getElementById(stepString + "appName").value =
01239 ConfigurationAPI.incrementName(this.value);
01240 };
01241
01243 document.getElementById(stepString + "addToNew").onclick =
01244 function()
01245 {
01246 var name = document.getElementById(stepString + "appName").value.trim();
01247 Debug.log("addToNew " + name);
01248
01249
01250 paramObj["appName"] = name;
01251
01252 localCreateApp(name);
01253 };
01254
01256 document.getElementById(stepString + "addToExisting").onclick =
01257 function()
01258 {
01259 var name = document.getElementById(stepString + "apps").value.trim();
01260 Debug.log("addToExisting " + name);
01261
01262
01263 paramObj["appName"] = name;
01264
01265 if(!_paramObjMap[_STEP_WHICH_APP]["apps"]) _paramObjMap[_STEP_WHICH_APP]["apps"] = [];
01266 _paramObjMap[_STEP_WHICH_APP]["isNewApp"] = false;
01267
01268
01269 localGetExistingSupervisorTargetGroupID(name);
01270
01271 };
01272
01273 }
01274
01275
01276
01277
01278
01279 break;
01280 case _STEP_SET_CONTEXT_HOST:
01281
01282 {
01283
01284 document.getElementById(stepString + "addresses").onclick = localAddressSelectHandler;
01285 document.getElementById(stepString + "addresses").onchange = localAddressSelectHandler;
01286
01287 function localAddressSelectHandler(event) {
01288 Debug.log("Selected " + this.value);
01289 document.getElementById(stepString + "address").value =
01290 this.value;
01291 };
01292
01293
01294 document.getElementById(stepString + "ports").onclick = localPortSelectHandler;
01295 document.getElementById(stepString + "ports").onchange = localPortSelectHandler;
01296
01297 function localPortSelectHandler(event) {
01298 Debug.log("Selected " + this.value);
01299 document.getElementById(stepString + "port").value =
01300 this.value;
01301 };
01302
01303 }
01304
01305 break;
01306
01307 case _STEP_WHICH_CONTEXT:
01308
01309 {
01310
01311 document.getElementById(stepString + "contexts").onclick = localContextSelectHandler;
01312 document.getElementById(stepString + "contexts").onchange = localContextSelectHandler;
01313
01314 function localContextSelectHandler(event) {
01315 Debug.log("Selected " + this.value);
01316
01317
01318 document.getElementById(stepString + "contextName").value =
01319 ConfigurationAPI.incrementName(this.value);
01320 };
01321
01323 document.getElementById(stepString + "addToNew").onclick =
01324 function()
01325 {
01326 var name = document.getElementById(stepString + "contextName").value.trim();
01327 Debug.log("addToNew " + name);
01328
01329
01330 paramObj["contextName"] = name;
01331
01332
01334
01335 ConfigurationAPI.addSubsetRecords(
01336 _XDAQ_BASE_PATH,
01337 name,
01339 function(modifiedTables,err)
01340 {
01341 Debug.log("modifiedTables length " + modifiedTables.length);
01342 if(!modifiedTables.length)
01343 {
01344
01345 Debug.log("There was an error while creating the XDAQ Context '" +
01346 name + ".' " + err,
01347 Debug.HIGH_PRIORITY);
01348 return;
01349 }
01350 _modifiedTables = modifiedTables;
01351
01352
01353 Debug.log("New context '" + name + "' was successfully created!");
01354
01355 newParamObj["isNewContext"] = true;
01356
01357
01358 if(paramObj["contexts"].indexOf(name) == -1)
01359 paramObj["contexts"].push(name);
01360
01361 localGetAllHostInfo();
01362
01363 },
01364 _modifiedTables,
01365 true );
01366
01367 };
01368
01370 document.getElementById(stepString + "addToExisting").onclick =
01371 function()
01372 {
01373 var name = document.getElementById(stepString + "contexts").value.trim();
01374 Debug.log("addToExisting " + name);
01375
01376
01377 paramObj["contextName"] = name;
01378
01379 newParamObj["isNewContext"] = false;
01380
01381
01382 ConfigurationAPI.getFieldValuesForRecords(
01383 _XDAQ_BASE_PATH,
01384 name,
01385 ["Address","Port","ApplicationGroupID"],
01386 function(objArr)
01387 {
01388 console.log(objArr);
01389 newParamObj["address"] = objArr[0].fieldValue;
01390 newParamObj["port"] = objArr[1].fieldValue;
01391 newParamObj["appGroupId"] = objArr[2].fieldValue;
01392
01393 localGetAllHostInfo();
01394 },
01395 _modifiedTables);
01396
01397
01398
01399 };
01400
01401
01403 function localGetAllHostInfo()
01404 {
01405 Debug.log("localGetExistingHostInfo()");
01406
01407 ConfigurationAPI.getUniqueFieldValuesForRecords(
01408 _XDAQ_BASE_PATH,
01409 "*",
01410 ["Address","Port"],
01411 function(objArr)
01412 {
01413 console.log(objArr);
01414 newParamObj["hostAddresses"] = objArr[0].fieldUniqueValueArray;
01415 newParamObj["hostPorts"] = objArr[1].fieldUniqueValueArray;
01416
01417 showPrompt(nextStepIndex,newParamObj);
01418 },
01419 _modifiedTables);
01420 }
01421 }
01422
01423 break;
01424
01425 case _STEP_GET_RECORD_NAME:
01426
01427 {
01428
01429
01430 document.getElementById(stepString + "records").onclick = localRecordsSelectHandler;
01431 document.getElementById(stepString + "records").onchange = localRecordsSelectHandler;
01432
01434 function localRecordsSelectHandler(event) {
01435 Debug.log("Selected " + this.value);
01436
01437
01438 document.getElementById(stepString + "recordName").value =
01439 ConfigurationAPI.incrementName(this.value);
01440 };
01441
01443 document.getElementById(stepString + "editConfig").onclick =
01444 function()
01445 {
01446 newParamObj["groupType"] = "Configuration";
01447
01448 paramObj["recordName"] = document.getElementById(stepString + "recordName").value.trim();
01449 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
01450 };
01452 document.getElementById(stepString + "editContext").onclick =
01453 function()
01454 {
01455 newParamObj["groupType"] = "Context";
01456
01457 paramObj["recordName"] = document.getElementById(stepString + "recordName").value.trim();
01458 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
01459 };
01461 document.getElementById(stepString + "deleteRecordIcon").onclick =
01462 function()
01463 {
01464 var selectedIndex = document.getElementById(stepString + "records").selectedIndex;
01465 var recordName = _subsetUIDs[selectedIndex];
01466 Debug.log("deleteRecord " + selectedIndex + " : " + recordName);
01467 Debug.log("getRecordConfiguration " + getRecordConfiguration());
01468 Debug.log("getAppConfiguration " + getAppConfiguration());
01469 try
01470 {
01471 Debug.log("getIntermediateTable " + getIntermediateTable());
01472 Debug.log("getIntermediateTypeName " + getIntermediateTypeName());
01473 }catch(e){
01474 Debug.log("No intermediate table: " + e);
01475 }
01476
01477 var generationsBack = 0;
01478 var lastGenerationsBack, parentCheckParentIndex;
01479
01480
01481
01482 _modifiedTables = undefined;
01483
01484 localPromptAndHandleRecordDeletion(_recordAlias,recordName);
01486 function localPromptAndHandleRecordDeletion(recordType,recordName)
01487 {
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497 var prompt;
01498
01499 if(generationsBack == 0)
01500 prompt = "Are you sure you want to remove the " + recordType + " named '" +
01501 recordName + "' from the active configuration?";
01502 else
01503 prompt = "Alert! A parent node, " + generationsBack + " level(s) up in the " +
01504 "configuration tree from the " +
01505 "origial " + _recordAlias + " '" + _subsetUIDs[selectedIndex] + ",' was found to " +
01506 "have no children.<br><br>Do you want to remove the childless " + recordType + " named '" +
01507 recordName + "' from the active configuration?";
01508
01509 DesktopContent.popUpVerification(
01510 prompt,
01511 function()
01512 {
01513
01514 Debug.log("do deleteRecord " + recordType + " : " + recordName);
01515
01516
01518
01519 ConfigurationAPI.deleteSubsetRecords(
01520 getParentTable(generationsBack),
01521 recordName,
01523 function(modifiedTables,err)
01524 {
01525 Debug.log("modifiedTables length " + modifiedTables.length);
01526 if(!modifiedTables.length)
01527 {
01528
01529 Debug.log("There was an error while creating the XDAQ Context '" +
01530 recordName + ".' " + err,
01531 Debug.HIGH_PRIORITY);
01532 return;
01533 }
01534 _modifiedTables = modifiedTables;
01535 console.log(_modifiedTables);
01536
01537
01538 Debug.log("The " + recordType + " named '" +
01539 recordName + "' was successfully removed!",
01540 Debug.INFO_PRIORITY);
01541
01542 parentCheckParentIndex = 0;
01543
01544
01545
01546
01547
01548 ConfigurationAPI.saveModifiedTables(_modifiedTables,
01549 function(savedTables, savedGroups, savedAliases)
01550 {
01551 if(!savedTables.length)
01552 {
01553 Debug.log("There was an error while saving the changes.",
01554 Debug.HIGH_PRIORITY);
01555 return;
01556 }
01557
01558 Debug.log("The " +
01559 _recordAlias + " named '" + recordName + "' was successfully removed!",
01560 Debug.INFO_PRIORITY);
01561
01562 _modifiedTables = undefined;
01563
01564 _aRecordWasModified = true;
01565
01566 if(generationsBack == 0)
01567 {
01568 generationsBack = 1;
01569 localCheckParentChildren();
01570 }
01571 else
01572 localCheckParentChildren();
01573
01574 },
01575
01576 0,
01577 0,
01578 0,
01579 0,
01580 0,
01581 true
01582
01583 );
01584
01585
01586
01587 },
01588 _modifiedTables,
01589 true );
01590
01591 },
01592 0 ,
01593 "#efeaea" , 0 ,
01594 "#770000" ,0 ,300 ,
01595 function()
01596 {
01597 Debug.log("User opted not to delete node.");
01598
01599
01600 if(generationsBack)
01601 localCheckParentChildren();
01602 }
01603 );
01604
01605
01607 function localCheckParentChildren()
01608 {
01609 if(lastGenerationsBack != generationsBack)
01610 {
01611
01612 Debug.log("Starting new generation of checking...");
01613 parentCheckParentIndex = 0;
01614 lastGenerationsBack = generationsBack;
01615 }
01616 Debug.log("localCheckParentChildren generationsBack=" + generationsBack +
01617 " parentCheckParentIndex=" + parentCheckParentIndex);
01618
01619
01620
01621
01622
01623
01624
01625 Debug.log("getAppConfiguration " + getAppConfiguration());
01626
01627 var modifiedTablesListStr = "";
01628 for(var i=0;_modifiedTables && i<_modifiedTables.length;++i)
01629 {
01630 if(i) modifiedTablesListStr += ",";
01631 modifiedTablesListStr += _modifiedTables[i].tableName + "," +
01632 _modifiedTables[i].tableVersion;
01633 }
01634
01635
01636 DesktopContent.XMLHttpRequest("Request?RequestType=getTreeView" +
01637 "&configGroup=" +
01638 "&configGroupKey=-1" +
01639 "&hideStatusFalse=0" +
01640 "&depth=3",
01641 "startPath=/" + getParentTable(generationsBack) +
01642 "&filterList=" + getParentFilter(generationsBack) +
01643 "&modifiedTables=" + modifiedTablesListStr,
01644 function(req)
01645 {
01646
01647 var tree = DesktopContent.getXMLNode(req,"tree");
01648 console.log(tree);
01649
01650
01651 try
01652 {
01653 var i,j;
01654 var parentChildren;
01655 var parentName;
01656 for(i=parentCheckParentIndex;i<tree.children.length;++i)
01657 {
01658 ++parentCheckParentIndex;
01659
01660 parentName = tree.children[i].getAttribute("value");
01661 Debug.log("Checking parent record " +
01662 parentCheckParentIndex + ":" +
01663 parentName);
01664
01665
01666 for(j=0;j<tree.children[i].children.length;++j)
01667 if(tree.children[i].children[j].getAttribute("value") ==
01668 getParentLinkField(generationsBack))
01669 {
01670
01671 parentChildren = DesktopContent.getXMLChildren(
01672 tree.children[i].children[j],
01673 "node");
01674 Debug.log("Num of children " + parentChildren.length);
01675
01676 if(parentChildren.length == 0)
01677 {
01678 localPromptAndHandleRecordDeletion(
01679 getParentType(generationsBack),
01680 parentName)
01681 return;
01682 }
01683 break;
01684 }
01685 }
01686
01687 Debug.log("No childless parent nodes found");
01688
01689
01690 ++generationsBack;
01691 localCheckParentChildren();
01692 }
01693 catch(e)
01694 {
01695
01696
01697 Debug.log("Giving up on childless parent node check. " +
01698 "Ignoring errors: " + e);
01699
01700 initRecordWizard();
01701 }
01702
01703
01704 });
01705
01706 }
01707 }
01708 };
01709 }
01710
01711 break;
01712
01713 case _STEP_CHANGE_GROUP:
01714
01715 {
01716
01718 document.getElementById(stepString + "activateAlias").onclick =
01719 function()
01720 {
01721
01722 var alias = document.getElementById(stepString + "aliases").value;
01723 Debug.log("activateAlias " + alias);
01724
01725
01726 var aliasObj;
01727 for(var i=0;i<
01728 _systemGroups.aliases[paramObj["groupType"]].length;++i)
01729 if(_systemGroups.aliases[paramObj["groupType"]][i].alias ==
01730 alias)
01731 {
01732 aliasObj = _systemGroups.aliases[paramObj["groupType"]][i];
01733 break;
01734 }
01735
01736 Debug.log("activateAlias group " + aliasObj.name +
01737 "-" + aliasObj.key);
01738
01739 ConfigurationAPI.activateGroup(aliasObj.name, aliasObj.key,
01740 true ,
01741
01742 function()
01743 {
01744 Debug.log("The System Alias '" + alias +
01745 "' (" + aliasObj.name + " (" +
01746 aliasObj.key + ")) was successfully activated!", Debug.INFO_PRIORITY);
01747
01748 initRecordWizard();
01749 });
01750 };
01751
01753 document.getElementById(stepString + "groupNames").onchange =
01754 function()
01755 {
01756
01757 Debug.log("Filling dropdown with keys for " + this.value);
01758 var str = "";
01759 for(var i=0;i<_systemGroups.groups[paramObj["groupType"]]
01760 [this.value].keys.length;++i)
01761 {
01762 str += htmlOpen("option",
01763 {
01764 },
01765 _systemGroups.groups[paramObj["groupType"]]
01766 [this.value].keys[i] , true );
01767 }
01768 document.getElementById(stepString + "groupKeys").innerHTML =
01769 str;
01770 };
01771
01773 document.getElementById(stepString + "activateGroup").onclick =
01774 function()
01775 {
01776
01777 var name = document.getElementById(stepString + "groupNames").value;
01778 var key = document.getElementById(stepString + "groupKeys").value;
01779
01780 Debug.log("activateGroup " + name +
01781 "-" + key);
01782
01783 ConfigurationAPI.activateGroup(name, key,
01784 true ,
01785
01786 function()
01787 {
01788 Debug.log("The Group '" + name + " (" +
01789 key + ") was successfully activated!", Debug.INFO_PRIORITY);
01790
01791 initRecordWizard();
01792 });
01793 };
01794
01795 }
01796
01797 break;
01798 default:;
01799 }
01800
01801
01802
01803
01805
01806 {
01807
01808
01810 function localCreateIntermediateLevelRecord(name)
01811 {
01812 Debug.log("localCreateIntermediateLevelRecord " + name);
01813
01815
01816 ConfigurationAPI.addSubsetRecords(
01817 getIntermediateTable(),
01818 name,
01820 function(modifiedTables,err)
01821 {
01822 Debug.log("modifiedTables length " + modifiedTables.length);
01823 if(!modifiedTables.length)
01824 {
01825
01826 Debug.log("There was an error while creating the XDAQ Application '" +
01827 name + ".' " + err,
01828 Debug.HIGH_PRIORITY);
01829 return;
01830 }
01831 _modifiedTables = modifiedTables;
01832
01833
01834 Debug.log("New intermediate record '" + name + "' was successfully created!");
01835
01836 newParamObj["isNew" + getIntermediateTypeName()] = true;
01837
01838 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
01839 {
01840 if(_intermediateLevel == 0)
01841 {
01842
01843
01844 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
01845 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]["allBuffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER]["allBuffers"] = [];
01846 if(_paramObjMap[_STEP_PROC_WHICH_BUFFER]["allBuffers"].indexOf(name) == -1)
01847 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["allBuffers"].push(name);
01848 }
01849 else
01850 throw("?");
01851 }
01852 else
01853 throw("?");
01854
01855 localSetupIntermediateLevelRecord(name);
01856
01857 },
01858 _modifiedTables,
01859 true );
01860 }
01861
01863 function localSetupIntermediateLevelRecord(name)
01864 {
01865
01866 var recordGroupId = "";
01867 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
01868 {
01869 if(_intermediateLevel == 0)
01870 {
01871 recordGroupId = _paramObjMap[_STEP_WHICH_APP]["appChildGroupName"];
01872 }
01873 else
01874 throw("?");
01875 }
01876 else
01877 throw("?");
01878
01879
01880 Debug.log("localSetupIntermediateLevelRecord " + name +
01881 " into groupId=" + recordGroupId);
01882
01883 var fieldArr,valueArr;
01884
01885 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
01886 {
01887 if(_intermediateLevel == 0)
01888 {
01889 fieldArr = [
01890 "Status",
01891 "DataManagerGroupID",
01892 "LinkToDataProcessorTable",
01893 "LinkToDataBufferGroupID",
01894 "CommentDescription"
01895 ];
01896
01897 valueArr = [
01898 "1",
01899 recordGroupId,
01900 getRecordConfiguration(),
01901 name+"ProcessorGroup",
01902 _DEFAULT_WIZ_COMMENT
01903 ];
01904 }
01905 else
01906 throw("?");
01907
01908 }
01909
01910 ConfigurationAPI.setFieldValuesForRecords(
01911 getIntermediateTable(),
01912 name,
01913 fieldArr,
01914 valueArr,
01915 function(modifiedTables)
01916 {
01917 Debug.log("modifiedTables length " + modifiedTables.length);
01918
01919 if(!modifiedTables.length)
01920 {
01921 Debug.log("There was an error while writing the values for the App.",
01922 Debug.HIGH_PRIORITY);
01923 return;
01924 }
01925 _modifiedTables = modifiedTables;
01926
01927
01928
01929
01930 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
01931 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["recordGroupName"] = name+"ProcessorGroup";
01932
01933 localCreateRecord(getRecordConfiguration());
01934
01935 },
01936 _modifiedTables);
01937 }
01938
01940 function localCreateApp(name)
01941 {
01942 Debug.log("localCreateApp " + name);
01944
01945 ConfigurationAPI.addSubsetRecords(
01946 _XDAQAPP_BASE_PATH,
01947 name,
01949 function(modifiedTables,err)
01950 {
01951 Debug.log("modifiedTables length " + modifiedTables.length);
01952 if(!modifiedTables.length)
01953 {
01954
01955 Debug.log("There was an error while creating the XDAQ Application '" +
01956 name + ".' " + err,
01957 Debug.HIGH_PRIORITY);
01958 return;
01959 }
01960 _modifiedTables = modifiedTables;
01961
01962
01963 Debug.log("New app '" + name + "' was successfully created!");
01964
01965
01966
01967 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
01968 if(!_paramObjMap[_STEP_WHICH_APP]["apps"]) _paramObjMap[_STEP_WHICH_APP]["apps"] = [];
01969 if(_paramObjMap[_STEP_WHICH_APP]["apps"].indexOf(name) == -1)
01970 _paramObjMap[_STEP_WHICH_APP]["apps"].push(name);
01971 _paramObjMap[_STEP_WHICH_APP]["isNewApp"] = true;
01972
01973 localSetupApp(name);
01974
01975 },
01976 _modifiedTables,
01977 true );
01978 }
01979
01981 function localSetupApp(name)
01982 {
01983 var context = _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"];
01984 var appGroupId = _paramObjMap[_STEP_SET_CONTEXT_HOST]["appGroupId"];
01985
01986 Debug.log("localSetupApp " + name + " in context=" + context + " groupId=" + appGroupId);
01987
01988 var fieldArr,valueArr;
01989
01990 if(1)
01991 {
01992 fieldArr = [
01993 "Status",
01994 "ApplicationGroupID",
01995 "LinkToSupervisorConfiguration",
01996 "LinkToSupervisorUID",
01997 "Class",
01998 "Instance",
01999 "Module",
02000 "CommentDescription"
02001 ];
02002
02003 valueArr = [
02004 "1",
02005 appGroupId,
02006 getAppConfiguration(),
02007 name+"Config",
02008 getAppClass(),
02009 "1",
02010 getAppModule(),
02011 _DEFAULT_WIZ_COMMENT
02012 ];
02013 }
02014
02015
02016
02017
02018
02019
02020 ConfigurationAPI.setFieldValuesForRecords(
02021 _XDAQAPP_BASE_PATH,
02022 name,
02023 fieldArr,
02024 valueArr,
02025 function(modifiedTables)
02026 {
02027 Debug.log("modifiedTables length " + modifiedTables.length);
02028
02029 if(!modifiedTables.length)
02030 {
02031 Debug.log("There was an error while writing the values for the App.",
02032 Debug.HIGH_PRIORITY);
02033 return;
02034 }
02035 _modifiedTables = modifiedTables;
02036
02037
02038 localCreateAppConfig(name+"Config");
02039
02040 },
02041 _modifiedTables);
02042 }
02043
02045 function localCreateAppConfig(name)
02046 {
02047 Debug.log("localCreateAppConfig " + name);
02049
02050 ConfigurationAPI.addSubsetRecords(
02051 getAppConfiguration(),
02052 name,
02054 function(modifiedTables,err)
02055 {
02056 Debug.log("modifiedTables length " + modifiedTables.length);
02057 if(!modifiedTables.length)
02058 {
02059
02060 Debug.log("There was an error while creating the XDAQ Application '" +
02061 name + ".' " + err,
02062 Debug.HIGH_PRIORITY);
02063 return;
02064 }
02065 _modifiedTables = modifiedTables;
02066
02067
02068 Debug.log("New app config '" + name + "' was successfully created!");
02069
02070
02071 localSetupAppConfig(name);
02072
02073 },
02074 _modifiedTables,
02075 true );
02076 }
02077
02079 function localSetupAppConfig(name)
02080 {
02081 var context = _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"];
02082 Debug.log("localSetupAppConfig " + name + " in context=" + context);
02083
02084 var fieldArr,valueArr;
02085 var groupSuffix;
02086
02087 _intermediateLevel = 0;
02088
02089 if(_recordAlias == _RECORD_TYPE_FE)
02090 {
02091 fieldArr = [
02092 "LinkToFEInterfaceTable",
02093 "LinkToFEInterfaceGroupID",
02094 "CommentDescription"
02095 ];
02096 groupSuffix = "FEGroup";
02097
02098 valueArr = [
02099 getRecordConfiguration(),
02100 name+groupSuffix,
02101 _DEFAULT_WIZ_COMMENT
02102 ];
02103 }
02104 else if(_recordAlias == _RECORD_TYPE_PROCESSOR
02105 )
02106 {
02107
02108 fieldArr = [
02109 "LinkToDataBufferTable",
02110 "LinkToDataManagerGroupID",
02111 "CommentDescription"
02112 ];
02113
02114 groupSuffix = "DMGroup";
02115
02116 valueArr = [
02117 getIntermediateTable(),
02118 name+groupSuffix,
02119 _DEFAULT_WIZ_COMMENT
02120 ];
02121 }
02122 else throw("?");
02123
02124 ConfigurationAPI.setFieldValuesForRecords(
02125 getAppConfiguration(),
02126 name,
02127 fieldArr,
02128 valueArr,
02129 function(modifiedTables)
02130 {
02131 Debug.log("modifiedTables length " + modifiedTables.length);
02132
02133 if(!modifiedTables.length)
02134 {
02135 Debug.log("There was an error while writing the values for the App.",
02136 Debug.HIGH_PRIORITY);
02137 return;
02138 }
02139 _modifiedTables = modifiedTables;
02140
02141
02142
02143 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
02144
02145
02146 _paramObjMap[_STEP_WHICH_APP]["appChildGroupName"] = name+groupSuffix;
02147
02148 if(_recordAlias == _RECORD_TYPE_FE)
02149 {
02150 Debug.log("Creating record...");
02151
02152 localCreateRecord(getRecordConfiguration());
02153 }
02154 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02155 {
02156 Debug.log("Setting up extra buffer level...");
02157 localHandleIntermediateLevel();
02158 }
02159 else throw("?");
02160
02161 },
02162 _modifiedTables);
02163 }
02164
02165
02167
02168 function localHandleIntermediateLevel()
02169 {
02170 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02171 {
02172 switch(_intermediateLevel)
02173 {
02174 case 0:
02175 {
02176
02177 var bufferGroupId = _paramObjMap[_STEP_WHICH_APP]["appChildGroupName"];
02178 var appName = _paramObjMap[_STEP_WHICH_APP]["appName"];
02179
02180
02181 Debug.log("localCreateIntermediateLevel-" + _intermediateLevel +
02182 " DataManager=" + appName);
02183
02184
02185
02186
02187
02188
02189
02190 ConfigurationAPI.getSubsetRecords(
02191 getIntermediateTable(),
02192 "" ,
02193 function(allRecords)
02194 {
02195 Debug.log("all buffers found = " + allRecords.length);
02196 console.log(allRecords);
02197
02198
02199 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
02200 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["allBuffers"] = allRecords;
02201
02202
02203 ConfigurationAPI.getSubsetRecords(
02204 getIntermediateTable(),
02205 "DataManagerGroupID="+
02206 encodeURIComponent(bufferGroupId) ,
02207 function(records)
02208 {
02209 Debug.log("buffers of DataManager '" + appName +
02210 "' found = " + records.length);
02211 console.log(records);
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222 if(records.length == 0)
02223 {
02224
02225
02226
02227 var bufferName = ConfigurationAPI.createNewRecordName("Buffer",allRecords);
02228
02229
02230 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["bufferName"] = bufferName;
02231
02232 localCreateIntermediateLevelRecord(appName);
02233 }
02234 else
02235 {
02236 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["buffers"] = records;
02237 showPrompt(_STEP_PROC_WHICH_BUFFER);
02238 }
02239
02240 },
02241 _modifiedTables);
02242
02243 },
02244 _modifiedTables);
02245
02246 var bufferName
02247 }
02248 break;
02249 default: throw("?");
02250 }
02251
02252 }
02253 else throw("?");
02254
02255 }
02256
02258
02259 function localGetExistingIntermediateTargetGroupID(intermediateName)
02260 {
02261
02262 Debug.log("localGetExistingSupervisorTargetGroupID " + intermediateName +
02263 " of type " + getIntermediateTypeName());
02264
02265 ConfigurationAPI.getTree(
02266 getIntermediateTable() + "/" + intermediateName,
02267 4 ,
02268 _modifiedTables,
02269 function(tree)
02270 {
02271 console.log(tree);
02272
02273 var table;
02274 var groupId;
02275
02276 try
02277 {
02278
02279 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02280 {
02281
02282 if(tree.children[1].children[0].nodeName !=
02283 "GroupID")
02284 throw("Invalid GroupID location in tree.");
02285 if(tree.children[1].children[1].nodeName !=
02286 "LinkConfigurationName")
02287 throw("Invalid Link Table location in tree.");
02288
02289 groupId =
02290 tree.children[1].children[0].getAttribute("value");
02291 table =
02292 tree.children[1].children[1].getAttribute("value");
02293 }
02294 else throw("?");
02295 }
02296 catch(e)
02297 {
02298 Debug.log("Error locating group in configuration for the new record. " + e,
02299 Debug.HIGH_PRIORITY);
02300 return;
02301 }
02302 Debug.log("Group Link found as " + table + ":" + groupId);
02303
02304
02305
02306
02307
02308 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02309 {
02310 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
02311 _paramObjMap[_STEP_PROC_WHICH_BUFFER]["recordGroupName"] = groupId;
02312 localCreateRecord(table);
02313 Debug.log("Setting up extra buffer level...");
02314 }
02315 else throw("?");
02316
02317
02318 });
02319
02320
02321 }
02322
02324
02325 function localGetExistingSupervisorTargetGroupID(supervisorName)
02326 {
02327 Debug.log("localGetExistingSupervisorTargetGroupID " + supervisorName);
02328
02329 ConfigurationAPI.getTree(
02330 _XDAQAPP_BASE_PATH + "/" + supervisorName,
02331 4 ,
02332 _modifiedTables,
02333 function(tree)
02334 {
02335 console.log(tree);
02336
02337 var table;
02338 var groupId;
02339
02340 try
02341 {
02342
02343 if(tree.children[1].children[4].children[0].nodeName !=
02344 "GroupID")
02345 throw("Invalid GroupID location in tree.");
02346 if(tree.children[1].children[4].children[1].nodeName !=
02347 "LinkConfigurationName")
02348 throw("Invalid Link Table location in tree.");
02349
02350 groupId =
02351 tree.children[1].children[4].children[0].getAttribute("value");
02352 table =
02353 tree.children[1].children[4].children[1].getAttribute("value");
02354
02355 }
02356 catch(e)
02357 {
02358 Debug.log("Error locating group in configuration for the new record. " + e,
02359 Debug.HIGH_PRIORITY);
02360 return;
02361 }
02362 Debug.log("Group Link found as " + table + ":" + groupId);
02363
02364
02365
02366 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
02367 _paramObjMap[_STEP_WHICH_APP]["appChildGroupName"] = groupId;
02368
02369 if(_recordAlias == _RECORD_TYPE_FE)
02370 {
02371 Debug.log("Creating record...");
02372 localCreateRecord(table);
02373 }
02374 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02375 {
02376 Debug.log("Setting up extra buffer level...");
02377 _intermediateLevel = 0;
02378 localHandleIntermediateLevel();
02379 }
02380 else throw("?");
02381
02382
02383 });
02384
02385 }
02386
02387
02389 function localCreateRecord(table)
02390 {
02391 Debug.log("localCreateRecord " + recordName + " in table=" + table);
02392
02394
02395 ConfigurationAPI.addSubsetRecords(
02396 table,
02397 recordName,
02399 function(modifiedTables,err)
02400 {
02401 Debug.log("modifiedTables length " + modifiedTables.length);
02402 if(!modifiedTables.length || err)
02403 {
02404 var reallyAnError = true;
02405 if(_furthestStep >= _STEP_SET_RECORD_FIELDS)
02406 {
02407
02408 if(err.indexOf("Entries in UID are not unique") >= 0)
02409 {
02410 Debug.log("Ignoring UID not unique error since likely already created..." +
02411 err);
02412 reallyAnError = false;
02413 }
02414 }
02415
02416 if(reallyAnError)
02417 {
02418
02419 Debug.log("There was an error while creating the " + _recordAlias +
02420 " record named '" +
02421 recordName + ".' " + err,
02422 Debug.HIGH_PRIORITY);
02423 return;
02424 }
02425 }
02426 else
02427 _modifiedTables = modifiedTables;
02428
02429 console.log("_modifiedTables",_modifiedTables);
02430
02431
02432 Debug.log("New " + _recordAlias + " record named '" + recordName + "' was successfully created!");
02433
02434
02435 localGetHelperValuesForRecord();
02436
02437 },
02438 _modifiedTables,
02439 true );
02440 }
02441
02443
02444 function localGetHelperValuesForRecord()
02445 {
02446 Debug.log("localGetHelperValuesForRecord " + recordName);
02447
02448 ConfigurationAPI.getFieldsOfRecords(
02449 getRecordConfiguration(),
02450 recordName,
02451 "!*Comment*,!*SlowControls*,!Status,!" + getRecordGroupIDField(),
02452 -1 ,
02453 function(recordFields)
02454 {
02455 newParamObj["fields"] = recordFields;
02456 Debug.log("recordFields found = " + recordFields.length);
02457 console.log(recordFields);
02458
02459
02460 showPrompt(_STEP_SET_RECORD_FIELDS,newParamObj);
02461
02462 },
02463 _modifiedTables);
02464
02465 }
02466
02467 }
02468
02469
02470
02471
02472
02473
02475
02476 try
02477 {
02478 document.getElementsByClassName(stepString + "nextButton")[0].onclick =
02479 localNextButtonHandler;
02480 document.getElementsByClassName(stepString + "nextButton")[1].onclick =
02481 localNextButtonHandler;
02482
02483 function localNextButtonHandler()
02484 {
02485
02486
02487 switch(stepIndex)
02488 {
02489 case _STEP_SET_RECORD_FIELDS:
02490
02491
02492 localScopeSetRecordFieldsDoIt();
02493
02495 function localScopeSetRecordFieldsDoIt()
02496 {
02497 Debug.log("localScopeSetRecordFieldsDoIt");
02498
02499 var recordFields = paramObj["fields"];
02500
02501 var groupName = "";
02502
02503 if(_recordAlias == _RECORD_TYPE_FE)
02504 groupName = _paramObjMap[_STEP_WHICH_APP]["appChildGroupName"];
02505 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02506 groupName = _paramObjMap[_STEP_PROC_WHICH_BUFFER]["recordGroupName"];
02507 else throw("?");
02508
02509
02510
02511 var fieldArr = [];
02512 var valueArr = [];
02513
02514
02515 for(var i=0;i<recordFields.length;++i)
02516 {
02517 fieldArr.push(recordFields[i].fieldRelativePath +
02518 recordFields[i].fieldColumnName);
02519 valueArr.push(ConfigurationAPI.getEditableFieldValue(
02520 recordFields[i],
02521 i));
02522 }
02523
02524
02525
02526 fieldArr.push(getRecordGroupIDField());
02527 valueArr.push(groupName);
02528 fieldArr.push("CommentDescription");
02529 valueArr.push(_DEFAULT_WIZ_COMMENT);
02530 fieldArr.push("Status");
02531 valueArr.push("1");
02532
02533 ConfigurationAPI.setFieldValuesForRecords(
02534 getRecordConfiguration(),
02535 recordName,
02536 fieldArr,
02537 valueArr,
02538 function(modifiedTables)
02539 {
02540 Debug.log("modifiedTables length " + modifiedTables.length);
02541
02542 if(!modifiedTables.length)
02543 {
02544 Debug.log("There was an error while writing the values.",
02545 Debug.HIGH_PRIORITY);
02546 return;
02547 }
02548
02549 _modifiedTables = modifiedTables;
02550
02551
02552 ConfigurationAPI.saveModifiedTables(_modifiedTables,
02553 function(savedTables, savedGroups, savedAliases)
02554 {
02555 if(!savedTables.length)
02556 {
02557 Debug.log("There was an error while saving the values.",
02558 Debug.HIGH_PRIORITY);
02559 return;
02560 }
02561
02562 Debug.log("The new " +
02563 _recordAlias + " named '" + recordName + "' was successfully created!",
02564 Debug.INFO_PRIORITY);
02565
02566 _modifiedTables = undefined;
02567
02568 _aRecordWasModified = true;
02569
02570 initRecordWizard();
02571
02572 });
02573
02574 },
02575 _modifiedTables);
02576
02577 }
02578
02579 return;
02580
02581 break;
02582
02583 case _STEP_SET_CONTEXT_HOST:
02584
02585
02586 localHandleSetupContext();
02587
02589 function localHandleSetupContext()
02590 {
02591 Debug.log("localHandleSetupContext");
02592
02593 var context = _paramObjMap[_STEP_WHICH_CONTEXT]["contextName"];
02594 var address = document.getElementById(stepString + "address").value.trim();
02595 var port = document.getElementById(stepString + "port").value.trim();
02596
02597
02598 paramObj["address"] = address;
02599
02600
02601 paramObj["port"] = port;
02602
02603 var appGroupId = context+"Apps";
02604 if(!paramObj["isNewContext"])
02605 appGroupId = paramObj["appGroupId"];
02606 else
02607 paramObj["appGroupId"] = appGroupId;
02608
02609 var fieldArr = ["Status",
02610 "LinkToApplicationConfiguration",
02611 "ApplicationGroupID",
02612 "Address",
02613 "Port",
02614 "CommentDescription"
02615 ];
02616
02617 var valueArr = ["1",
02618 _XDAQAPP_BASE_PATH,
02619 appGroupId,
02620 address,
02621 port,
02622 _DEFAULT_WIZ_COMMENT
02623 ];
02624
02625 ConfigurationAPI.setFieldValuesForRecords(
02626 _XDAQ_BASE_PATH,
02627 context,
02628 fieldArr,
02629 valueArr,
02630 function(modifiedTables)
02631 {
02632 Debug.log("modifiedTables length " + modifiedTables.length);
02633
02634 if(!modifiedTables.length)
02635 {
02636 Debug.log("There was an error while writing the values.",
02637 Debug.HIGH_PRIORITY);
02638 return;
02639 }
02640 _modifiedTables = modifiedTables;
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651 localGetAppInfo();
02652
02653 },
02654 _modifiedTables);
02655
02657 function localGetAppInfo()
02658 {
02659 var appGroupId = paramObj["appGroupId"];
02660 Debug.log("localGetAppInfo for context app group " + appGroupId);
02661
02662
02663 ConfigurationAPI.getSubsetRecords(
02664 _XDAQAPP_BASE_PATH,
02665 "" ,
02666 function(allApps)
02667 {
02668 Debug.log("all apps found = " + allApps.length);
02669
02670 console.log(allApps);
02671
02672 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
02673
02674
02675 _paramObjMap[_STEP_WHICH_APP]["allApps"] = allApps;
02676
02677
02678 ConfigurationAPI.getSubsetRecords(
02679 _XDAQAPP_BASE_PATH,
02680 "Class=" +
02681 encodeURIComponent(getAppClass()) +
02682 ";ApplicationGroupID="+
02683
02684 encodeURIComponent(appGroupId) ,
02685 function(records)
02686 {
02687 Debug.log("apps of appClass found = " + records.length);
02688 console.log(records);
02689
02690 if(records.length == 0)
02691 {
02692
02693
02694
02695 var appName = ConfigurationAPI.createNewRecordName(getApp(),allApps);
02696
02697
02698 _paramObjMap[_STEP_WHICH_APP]["appName"] = appName;
02699
02700 localCreateApp(appName);
02701 }
02702 else
02703 {
02704 _paramObjMap[_STEP_WHICH_APP]["apps"] = records;
02705 showPrompt(_STEP_WHICH_APP);
02706 }
02707
02708 },
02709 _modifiedTables);
02710 },
02711 _modifiedTables);
02712 }
02713
02714 }
02715
02716 return;
02717
02718 break;
02719
02720 case _STEP_GET_RECORD_NAME:
02721
02722
02723 recordName = document.getElementById(stepString + "recordName").value.trim();
02724 paramObj["recordName"] = recordName;
02725
02726 if(recordName.length < 1)
02727 {
02728 Debug.log("Invalid " + _recordAlias + " name ' " +
02729 recordName + "' (too short). Please enter a valid name.",
02730 Debug.HIGH_PRIORITY);
02731 return;
02732 }
02733
02734 for(var i=0;i<_subsetUIDs.length;++i)
02735 if(_subsetUIDs[i] == recordName)
02736 {
02737 Debug.log("Invalid " + _recordAlias + " name ' " +
02738 recordName + "' (name already in use in the active configuration). Please enter a valid name.",
02739 Debug.HIGH_PRIORITY);
02740 return;
02741 }
02742
02743
02744 ConfigurationAPI.getSubsetRecords(
02745 _XDAQ_BASE_PATH,
02746 "",
02747 function(records)
02748 {
02749 newParamObj["contexts"] = records;
02750 Debug.log("contexts found = " + records.length);
02751 console.log(records);
02752
02753 showPrompt(nextStepIndex,newParamObj);
02754
02755 });
02756 return;
02757 break;
02758
02759 case _STEP_WHICH_RECORD_TYPE:
02760
02762 if(scopeWhichRecordTypeNext())
02763 return;
02764
02765 function scopeWhichRecordTypeNext()
02766 {
02767 var newRecordAlias = document.getElementById(stepString + "recordTypes").value.trim();
02768
02769 var needToInit = (_recordAlias != newRecordAlias);
02770
02771 _recordAlias = newRecordAlias;
02772 Debug.log("_recordAlias chosen as " + _recordAlias);
02773
02774 if(needToInit) initRecordWizard();
02775 return needToInit;
02776 }
02777
02778 break;
02779 default:;
02780 }
02781 showPrompt(nextStepIndex,newParamObj);
02782 }
02783 }
02784 catch(e){ Debug.log("Caught ERROR: " + e.stack);}
02785
02786 try
02787 {
02788 document.getElementsByClassName(stepString + "prevButton")[0].onclick =
02789 localPrevButtonHandler;
02790 document.getElementsByClassName(stepString + "prevButton")[1].onclick =
02791 localPrevButtonHandler;
02792
02793 function localPrevButtonHandler()
02794 {
02795
02796 switch(stepIndex)
02797 {
02798 case _STEP_WHICH_RECORD_TYPE:
02799
02800
02801
02802 _subsetUIDs = [];
02803 _modifiedTables = undefined;
02804 _furthestStep = -1;
02805 _paramObjMap = {};
02806 _systemGroups = {};
02807
02808
02809 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
02810 while(el)
02811 {
02812 el.parentNode.removeChild(el);
02813 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
02814 }
02815
02816 if(_doneHandler) _doneHandler(_aRecordWasModified);
02817 return;
02818 break;
02819 default:;
02820 }
02821 showPrompt(prevStepIndex);
02822 }
02823 }
02824 catch(e){ Debug.log("Caught ERROR: " + e.stack);}
02825
02826 }
02827
02828 }
02829
02830
02831
02832
02833 function getApp()
02834 {
02835 var retVal = "";
02836 if(_recordAlias == _RECORD_TYPE_FE)
02837 retVal = "FESupervisor";
02838 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02839 retVal = "DataManagerSupervisor";
02840 else
02841 throw("?");
02842
02843 return retVal;
02844 }
02845
02846
02847
02848 function getAppClass()
02849 {
02850 return "ots::" + getApp();
02851 }
02852
02853
02854
02855 function getAppModule()
02856 {
02857 var otsModule = "";
02858 if(_recordAlias == _RECORD_TYPE_FE)
02859 otsModule = "${OTSDAQ_LIB}/libCoreSupervisors.so";
02860 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02861 otsModule = "${OTSDAQ_LIB}/libCoreSupervisors.so";
02862 else
02863 throw("?");
02864
02865 return otsModule;
02866 }
02867
02868
02869
02870 function getAppConfiguration()
02871 {
02872 var retVal = "";
02873 if(_recordAlias == _RECORD_TYPE_FE)
02874 retVal = "FESupervisorConfiguration";
02875 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02876 retVal = "DataManagerSupervisorConfiguration";
02877 else
02878 throw("?");
02879
02880 return retVal;
02881 }
02882
02883
02884
02885 function getRecordConfiguration()
02886 {
02887 var retVal = "";
02888 if(_recordAlias == _RECORD_TYPE_FE)
02889 retVal = "FEInterfaceConfiguration";
02890 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02891 retVal = "DataBufferConfiguration";
02892 else
02893 throw("?");
02894
02895 return retVal;
02896 }
02897
02898
02899
02900 function getRecordGroupIDField()
02901 {
02902 var retVal = "";
02903 if(_recordAlias == _RECORD_TYPE_FE)
02904 retVal = "FEInterfaceGroupID";
02905 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02906 retVal = "DataBufferGroupID";
02907 else
02908 throw("?");
02909
02910 return retVal;
02911 }
02912
02913
02914
02915
02916 function getRecordFilter()
02917 {
02918 var retVal = "";
02919 if(_recordAlias == _RECORD_TYPE_FE)
02920 retVal = " ";
02921 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02922 retVal = " ";
02923
02924 if(retVal == "")
02925 throw("Invalid getRecordFilter");
02926
02927 return retVal;
02928 }
02929
02930
02931
02932
02933
02934 function getIntermediateTable()
02935 {
02936 var retVal = "";
02937 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02938 {
02939 if(_intermediateLevel == 0)
02940 retVal = "DataManagerConfiguration";
02941 }
02942
02943 if(retVal == "")
02944 throw("Invalid getIntermediateTable");
02945
02946 return retVal;
02947 }
02948
02949
02950
02951
02952 function getIntermediateTypeName()
02953 {
02954 var retVal = "";
02955 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02956 {
02957 if(_intermediateLevel == 0)
02958 retVal = "Buffer";
02959 }
02960
02961 if(retVal == "")
02962 throw("Invalid getIntermediateTypeName");
02963
02964 return retVal;
02965 }
02966
02967
02968
02969
02970 function getParentTable(generationsBack)
02971 {
02972 if(generationsBack == 0) return getRecordConfiguration();
02973
02974 var retVal = "";
02975
02976 if(_recordAlias == _RECORD_TYPE_FE)
02977 {
02978 if(generationsBack == 1)
02979 retVal = "FESupervisorConfiguration";
02980 else if(generationsBack == 2)
02981 retVal = _XDAQAPP_BASE_PATH;
02982 }
02983 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
02984 {
02985 if(generationsBack == 1)
02986 retVal = "DataManagerConfiguration";
02987 else if(generationsBack == 2)
02988 retVal = "DataManagerSupervisorConfiguration";
02989 else if(generationsBack == 3)
02990 retVal = _XDAQAPP_BASE_PATH;
02991 }
02992
02993 if(retVal == "")
02994 throw("Invalid getParentTable");
02995
02996 return retVal;
02997 }
02998
02999
03000
03001
03002 function getParentType(generationsBack)
03003 {
03004 if(generationsBack == 0) return _recordAlias;
03005
03006 var retVal = "";
03007
03008 if(_recordAlias == _RECORD_TYPE_FE)
03009 {
03010 if(generationsBack == 1)
03011 retVal = "FESupervisorConfiguration";
03012 else if(generationsBack == 2)
03013 retVal = "FESupervisor";
03014 }
03015 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
03016 {
03017 if(generationsBack == 1)
03018 retVal = "Buffer";
03019 else if(generationsBack == 2)
03020 retVal = "DataManagerSupervisorConfiguration";
03021 else if(generationsBack == 3)
03022 retVal = "DataManagerSupervisor";
03023 }
03024
03025 if(retVal == "")
03026 throw("Invalid getParentType");
03027
03028 return retVal;
03029 }
03030
03031
03032
03033
03034 function getParentLinkField(generationsBack)
03035 {
03036 var retVal = "";
03037
03038 if(_recordAlias == _RECORD_TYPE_FE)
03039 {
03040 if(generationsBack == 1)
03041 retVal = "LinkToFEInterfaceTable";
03042 else if(generationsBack == 2)
03043 retVal = "LinkToSupervisorConfiguration";
03044 }
03045 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
03046 {
03047 if(generationsBack == 1)
03048 retVal = "LinkToDataProcessorTable";
03049 else if(generationsBack == 2)
03050 retVal = "LinkToDataBufferTable";
03051 else if(generationsBack == 3)
03052 retVal = "LinkToSupervisorConfiguration";
03053 }
03054
03055 if(retVal == "")
03056 throw("Invalid getParentLinkField");
03057
03058 return retVal;
03059 }
03060
03061
03062
03063
03064 function getParentFilter(generationsBack)
03065 {
03066 var retVal = "";
03067
03068 if(_recordAlias == _RECORD_TYPE_FE)
03069 {
03070 if(generationsBack == 1)
03071 retVal = " ";
03072 else if(generationsBack == 2)
03073 retVal = "Class=ots::FESupervisor";
03074 }
03075 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
03076 {
03077 if(generationsBack == 1)
03078 retVal = " ";
03079 else if(generationsBack == 2)
03080 retVal = " ";
03081 else if(generationsBack == 3)
03082 retVal = "Class=ots::DataManagerSupervisor,ots::ARTDAQDataManagerSupervisor," +
03083 "ots::VisualSupervisor";
03084 }
03085
03086 if(retVal == "")
03087 throw("Invalid getParentFilter");
03088
03089 return retVal;
03090 }
03091
03092
03093
03094
03095 function htmlOpen(tag,attObj,innerHTML,doCloseTag)
03096 {
03097 var str = "";
03098 var attKeys = Object.keys(attObj);
03099 str += "<" + tag + " ";
03100 for(var i=0;i<attKeys.length;++i)
03101 str += " " + attKeys[i] + "='" +
03102 attObj[attKeys[i]] + "' ";
03103 str += ">";
03104 if(innerHTML) str += innerHTML;
03105 if(doCloseTag)
03106 str += "</" + tag + ">";
03107 return str;
03108 }
03109
03110
03111
03112 function htmlClearDiv()
03113 {
03114 return "<div id='clearDiv'></div>";
03115 }
03116
03117
03118 };
03119
03120
03121
03122
03123
03124
03125
03126
03127