123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673 |
- /****************************************************************
- ** Licensed Materials - Property of IBM
- **
- ** IBM Cognos Products: mdsrv
- **
- ** (C) Copyright IBM Corp. 2008, 2017
- **
- ** US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *****************************************************************/
- //***********************************************************************************************
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- //***********************************************************************************************
- // Declare the LINEAGE namespace
- if ( ! LNS )
- var LNS = {};
- LNS.g_idTimer = null;
- LNS.g_idLoadTimer = null;
- LNS.g_defDocumentCursor = null;
- LNS.g_defTechTabCursor = null;
- LNS.idBusinessView = 0;
- LNS.idTechnicalView = 1;
- LNS.sTabCtrlId = 'idTabCtrl';
- LNS.tabNames = [];
- LNS.tabNames[ LNS.idBusinessView ] = 'id_tab_business_view';
- LNS.tabNames[ LNS.idTechnicalView ] = 'id_tab_technical_view';
- LNS.idCurTab = 0;
- LNS.textGraphCreated = false;
- LNS.getTabName = function ( nTab )
- {
- return this.tabNames[ nTab ];
- }
- LNS.getCurTabName = function()
- {
- return this.tabNames[ this.idCurTab ];
- }
- LNS.switchTabs = function( keyEvent )
- {
- var bProcessed = false;
- var evt = new CKeyboardEvent ( keyEvent );
- // When a user presses the TAB button -> switch the tab
- if ( evt.key === UTIL.KEYCODE_TAB )
- {
- if ( ++this.idCurTab >= this.tabNames.length )
- this.idCurTab = 0;
- // alert( this.getCurTabName() );
- this.OnSelectTab( this.getCurTabName() );
- bProcessed = true;
- }
- else
- if ( evt.key === UTIL.KEYCODE_ARROW_LEFT && evt.evt.altKey )
- {
- // Try to catch Alt+LeftArrow -> it's a shortcut for browser's BACK button
- bProcessed = true;
- }
- else
- if ( evt.key === UTIL.KEYCODE_ARROW_RIGHT && evt.evt.altKey )
- {
- // Try to catch Alt+RightArrow -> it's a shortcut for browser's FORWARD button
- bProcessed = true;
- }
- else
- {
- if ( this.idCurTab === this.idTechnicalView && this.g_TechnicalView && this.g_TechnicalView.bInitialized )
- {
- bProcessed = this.g_TechnicalView.processKeyEvent( keyEvent );
- }
- }
- return ! bProcessed;
- }
- LNS.showHourglassCursor = function ( bShow )
- {
- var cssHelper = new CElementStyleHelper ( 'id_tab_technical_view_span' );
- var defDocumentCursor = LNS.g_defDocumentCursor;
- var defTechTabCursor = LNS.g_defTechTabCursor;
- if ( bShow )
- {
- if (document.documentElement.clientHeight == 0)
- this.g_defDocumentCursor = document.body.style.cursor;
- else
- this.g_defDocumentCursor = document.documentElement.style.cursor;
- this.g_defTechTabCursor = cssHelper.getCursor();
- defDocumentCursor = "wait";
- defTechTabCursor = "wait";
- }
- if (document.documentElement.clientHeight == 0)
- document.body.style.cursor = defDocumentCursor;
- else
- document.documentElement.style.cursor = defDocumentCursor;
- cssHelper.setCursor( defTechTabCursor );
- }
- LNS.OnSelectTab = function ( sTabId )
- {
- var activeTab = document.getElementById( sTabId );
- activeTab.className = "classActiveTab";
- if ( sTabId === this.tabNames[ this.idBusinessView ] )
- {
- var techViewTab = document.getElementById( "id_tab_technical_view" );
- techViewTab.className = "classInactiveTab";
- var busView = document.getElementById( "id_business_view" );
- var techView = document.getElementById( "id_technical_view" );
- techView.style.display = "none";
- busView.style.display = "block";
- }
- else
- if ( sTabId === this.tabNames[ this.idTechnicalView ] )
- {
- var busViewTab = document.getElementById( "id_tab_business_view" );
- busViewTab.className = "classInactiveTab";
- var busView = document.getElementById( "id_business_view" );
- var techView = document.getElementById( "id_technical_view" );
- busView.style.display = "none";
- techView.style.display = "block";
- //defined in techView.jspf
- // MDSRV_initialize();
- // HACK: to display the hourglass cursor while the technical view is being initialized
- if ( ! this.TECH_VIEW_INITED )
- {
- this.showHourglassCursor ( true );
- this.g_idTimer = window.setTimeout( "LNS.initTechnicalView()", 100 );
- }
- //HACK: If we "draw" the graph while the techincal view tab isn't selected, the div we place the graph in won't be redrawn until we resize the window (there has got to be a better way to do this)
- if(!LNS.techincalTabHasBeenSelected){
- LNS.techincalTabHasBeenSelected = true;
- window.resizeBy(1,0)
- }
- }
- }
- LNS.initBusinessView = function()
- {
- window.clearTimeout ( this.g_idLoadTimer );
- this.OnSelectTab( this.getCurTabName() );
- var tabCtrl = document.getElementById( this.sTabCtrlId );
- tabCtrl.focus();
- // tabCtrl.releaseCapture();
- }
- LNS.OnLoad = function()
- {
- // document.onkeydown = this.switchTabs;
- // Select the initial TAB
- this.g_idLoadTimer = window.setTimeout( "LNS.initBusinessView()", 100 );
- var tabCtrl = document.getElementById( this.sTabCtrlId );
- tabCtrl.focus();
- // tabCtrl.setCapture();
- LNS.replaceBlankTableCells(document.getElementById('id_business_view'));
- }
- LNS.initTechnicalView = function()
- {
- if ( ! this.TECH_VIEW_INITED )
- {
- var techView = document.getElementById( "id_technical_view" );
-
- //The technical view div needs to be visible when calculating the pane widths on the graph, otherwise the panes will overlap.
- //This style will only be applied while the technical view is being initialized, and is removed once it has been (see below).
- techView.style.opacity = 0;
- techView.style.display = "block";
- techView.style.position = "absolute";
-
- window.clearTimeout ( this.g_idTimer );
- MDSRV_initialize();
-
- //Reset the opacity
- techView.style.opacity = 1; // fully opaque
- techView.style.position = "relative";
-
- this.showHourglassCursor ( false );
-
- }
- }
- //hide the text based graph, show the Normal View tables and nesting tables, and indicate the Normal view is selected
- LNS.showBusinessDiv = function()
- {
- document.getElementById("textgraph").style.display = "none";
- document.getElementById("normalViewTables").style.display = "";
- }
- //same as above, but show the text based graph
- LNS.showTextGraphDiv = function()
- {
- if ( ! this.textGraphCreated )
- {
- LNS.initTechnicalView();
-
- // make sure the technicalView isn't displayed
- var techView = document.getElementById( "id_technical_view" );
- techView.style.display = "none";
-
- var textgraph = new CTextGraph(LNS.g_TechnicalView.GraphCtrl, LNS.g_modelData.responseHelper);
- textgraph.Init();
- this.textGraphCreated = true;
- }
- document.getElementById("textgraph").style.display = "";
- document.getElementById("normalViewTables").style.display = "none";
- }
- LNS.switchBusinessViews = function()
- {
- if(document.getElementById("NormalView").checked === true && document.getElementById("NormalView").style.display !== "none")
- {
- LNS.showBusinessDiv();
- }
-
- else if(document.getElementById("DetailedView").checked === true && document.getElementById("DetailedView").style.display !== "none")
- {
- LNS.showTextGraphDiv();
- }
- }
- LNS.replaceBlankTableCells = function (rootNode)
- {
- var tableCellsNodeList = rootNode.getElementsByTagName('td');
- var onlyWhitespace = /^\s*$/g;
- var emptyCells = [];
- for(var i = 0; i < tableCellsNodeList.length; i++)
- {
- var node = tableCellsNodeList[i];
-
- if(onlyWhitespace.test(node.innerHTML))
- {
- emptyCells.push(node);
- }
- //this catches the empty cells in the normal view that have a span with no text
- else if(node.childNodes.length === 1 && node.childNodes[0].className === "dataCell" && onlyWhitespace.test(node.childNodes[0].innerHTML))
- {
- emptyCells.push(node);
- }
- }
- for(var i = 0; i < emptyCells.length; i++)
- {
- emptyCells[i].parentNode.parentNode.removeChild(emptyCells[i].parentNode);
- }
- }
- //-------------------------------------------------------------------------
- function GetScreenXresolution()
- {
- return screen.width;
- }
- function GetScreenYresolution()
- {
- return screen.height;
- }
- function GetWindowClientHeight()
- {
- if (document.documentElement.clientHeight == 0)
- return window.innerHeight ? window.innerHeight : document.body.clientHeight;
- return window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
- }
- function GetWindowClientWidth()
- {
- if (document.documentElement.clientHeight == 0)
- return window.innerWidth ? window.innerWidth : document.body.clientWidth;
- return window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
- }
- function GetWindowOuterHeight()
- {
- if (document.documentElement.clientHeight == 0)
- return window.innerHeight ? window.innerHeight : document.body.clientHeight;
- return window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
- // return window.outerHeight;
- }
- function GetWindowOuterWidth()
- {
- if (document.documentElement.clientHeight == 0)
- return window.innerWidth ? window.innerWidth : document.body.clientWidth;
- return window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
- // return window.innerWidth;
- }
- function GetWindowXoffset()
- {
- return window.screenLeft ? window.screenLeft : window.screenX;
- }
- function GetWindowYoffset()
- {
- return window.screenTop ? window.screenTop : window.screenY;
- }
- /** This function resizes the lineage window to 80% the width and height of the screen. */
- function MDSRV_ResizeWindow()
- {
- var width = GetWindowOuterWidth();
- var height = GetWindowOuterHeight();
- var prefWidth = screen.availWidth * 0.80;
- var prefHeight = screen.availHeight * 0.80;
- if (width < prefWidth || width > screen.availWidth)
- {
- width = prefWidth;
- }
- if (height < prefHeight || height > screen.availHeight)
- {
- height = prefHeight;
- }
- window.resizeTo( width, height );
- var x = GetWindowXoffset();
- var y = GetWindowYoffset();
- if ( x + width > screen.availWidth )
- x = screen.availWidth - width;
- if ( y + height > screen.availHeight )
- y = screen.availHeight - height;
- window.moveTo( x, y );
- }
- function MDSRV_CheckForDebug(evt)
- {
- if (evt.shiftKey && evt.ctrlKey && evt.altKey)
- {
- if (evt.charCode == 68 || evt.keyCode == 68)
- {
- document.getElementById("MDSRV_debugForm").style.display="block";
- }
- }
- }
- function MDSRV_InitDebugKeyHandler()
- {
- if (document.addEventListener)
- {
- document.addEventListener('keypress', MDSRV_CheckForDebug, false);
- }
- else if (document.attachEvent)
- {
- document.attachEvent("onkeydown", MDSRV_CheckForDebug);
- }
- }
- //-----------------------------------------------------------------------------
- // class MDSRV_LineageResponse
- //
- // Creates an object structure from the given JS lineage representation
- // sent by the lineage ui service.
- //-----------------------------------------------------------------------------
- function MDSRV_LineageResponse( representation )
- {
- var linObj = "object";
- var i = 1;
- var lineageObject = representation[linObj+i];
- //first get all of the objects and put them into a map
- this.m_lineageObjects = new Array();
- while (lineageObject)
- {
- this.m_lineageObjects[MDSRV_decodeString(lineageObject['id'])] = new MDSRV_LineageObject(lineageObject);
- i++;
- lineageObject = representation[linObj+i];
- }
- //now get the objects that were asked about
- var queryStr = "query";
- var queryIdx = 1;
- var queryObj = representation[queryStr+queryIdx];
- this.m_queries = new Array();
- i = -1;
- while (queryObj)
- {
- objRef = MDSRV_decodeString(queryObj["objRef"]);
- this.m_queries[++i] = this.m_lineageObjects[objRef];
- // if ( this.m_lineageObjects[objRef].m_type == "filterDefinition" )
- // alert ( "MDSRV_LineageResponse: refObj type = " + this.m_lineageObjects[objRef].m_type );
- queryIdx++;
- queryObj = representation[queryStr+queryIdx];
- }
- }
- function MDSRV_LineageObject( lineageObject )
- {
- this.m_type = MDSRV_decodeString(lineageObject['type']);
- this.m_id = MDSRV_decodeString(lineageObject['id']);
- this.m_name = MDSRV_decodeString(lineageObject['name']);
- this.m_dispName = MDSRV_decodeString(lineageObject['dispName']);
- var props = lineageObject['properties'];
- this.m_properties = new Array();
- this.m_childRefs = new Array();
- //debugger;
- var property = "param";
- var propIdx = 1;
- var propObj = props[property+propIdx];
- var idx = 0;
- while ( propObj )
- {
- this.m_properties[idx] = new MDSRV_Property( MDSRV_decodeString(propObj['name']),
- MDSRV_decodeString(propObj['dispName']),
- MDSRV_decodeString(propObj['value']) );
- propIdx++;
- propObj = props[property+propIdx];
- idx++;
- }
- this.m_parentRef = MDSRV_decodeString( lineageObject['parent_ref'] );
- //now gather up any children we may have had
- var childObj = "child_ref";
- var childIdx = 1;
- var childObject = lineageObject[childObj+childIdx];
- while ( childObject )
- {
- this.m_childRefs.push( MDSRV_decodeString(childObject) );
- childIdx++;
- childObject = lineageObject[childObj+childIdx];
- }
- this.m_transformation = new MDSRV_Transformation(lineageObject['transformation']);
- }
- function MDSRV_Transformation( objTransformation )
- {
- var sources = objTransformation['source'];
- this.m_sources = new Array();
- var sourceStr = "source";
- var sourceIdx = 1;
- var sourceObj = objTransformation[sourceStr+sourceIdx];
- while (sourceObj)
- {
- var transSource = new MDSRV_TransformationSource(sourceObj);
- this.m_sources[sourceIdx-1] = transSource;
- sourceIdx++;
- sourceObj = objTransformation[sourceStr+sourceIdx];
- }
- }
- function MDSRV_TransformationSource(representation)
- {
- this.m_objectRef = MDSRV_decodeString( representation['objRef'] );
- }
- function MDSRV_Property(propName, propDispName, propValue)
- {
- this.m_name = propName;
- this.m_dispName = propDispName;
- this.m_value = propValue;
- }
- function MDSRV_decodeString(str)
- {
- if (str)
- {
- var str1 = str.replace(/'/g, "'");
- str1 = str1.replace(/"/g, "\"");
- str1 = str1.replace(/>/g, ">");
- str1 = str1.replace(/</g, "<");
- return str1;
- }
- return "";
- }
- /* Public API */
- /** For this lineage request returns an array of MDSRV_LineageObjects representing the query'd objects.
- Return type array of MDSRV_LineageObjects. */
- MDSRV_LineageResponse.prototype.getQueryResults = function()
- {
- return this.m_queries;
- }
- /** Returns a MDSRV_LineageObject for the object with the given id. Return type MDSRV_LineageObject */
- MDSRV_LineageResponse.prototype.lookup = function(objectRef)
- {
- return this.m_lineageObjects[objectRef];
- }
- /** For the given lineage object returns the objects id. Return type string.*/
- MDSRV_LineageObject.prototype.getId = function()
- {
- return this.m_id;
- }
- MDSRV_LineageObject.prototype.toString = function()
- {
- var result = "name:" + this.m_name;
- result += ", type: " + this.m_type;
- result += ", parentRef: " + this.m_parentRef;
- result += " properties: {";
- for (var i=0; i < this.m_properties.length; i++)
- {
- result += this.m_properties[i].getName();
- result += ":";
- result += this.m_properties[i].getValue();
- if ( i + 1 < this.m_properties.length )
- {
- result += ",";
- }
- }
- result += "}";
- return result;
- }
- /** Returns the name of this lineage object. Return type strnig.*/
- MDSRV_LineageObject.prototype.getName = function()
- {
- return this.m_name;
- }
- /** Returns the type of this lineage object. Return type string.*/
- MDSRV_LineageObject.prototype.getType = function()
- {
- return this.m_type;
- }
- /*Returns array of properties of this lineage object. Return type Array of MDSRV_Property objects. */
- MDSRV_LineageObject.prototype.getProperties = function()
- {
- return this.m_properties;
- }
- /** Returns the transformation [if any] for this lineage object. Return type MDSRV_Transformation */
- MDSRV_LineageObject.prototype.getTransformation = function()
- {
- return this.m_transformation;
- }
- /** Returns the id of the parent of this LineageObject. Return type string.*/
- MDSRV_LineageObject.prototype.getParentRef = function()
- {
- return this.m_parentRef;
- }
- /** Returns the list of id's of child objects. Return type array of strings representing child id's. */
- MDSRV_LineageObject.prototype.getChildRefs = function()
- {
- return this.m_childRefs;
- }
- /** Returns the sources of this transformation. Return type Array of MDSRV_TransformationSource objects. */
- MDSRV_Transformation.prototype.getTransformationSourceList = function()
- {
- return this.m_sources;
- }
- /** Returns a string representing the id of the source object. Return type string. */
- MDSRV_TransformationSource.prototype.getObjectRef = function()
- {
- return this.m_objectRef;
- }
- /** Returns the name of this property. Return type string. */
- MDSRV_Property.prototype.getName = function()
- {
- return this.m_name;
- }
- /** Returns the display name of this property. Return type string. */
- MDSRV_Property.prototype.getDisplayName = function()
- {
- return this.m_dispName;
- }
- /** Returns the value of this property. Return type string. */
- MDSRV_Property.prototype.getValue = function()
- {
- return this.m_value;
- }
- /** Used to retrieve localized values. String map is an array of the form {key:'value', key:'value'}. Keys must be
- unique.*/
- function MDSRV_StringManager(stringMap)
- {
- this.m_stringMap = stringMap;
- }
- /** Returns the localized value for the given key. If a param is present,
- then the param will be subsituted if the param was a parameterized string.
- A parameterized string will contain '$$' whereever a param is locaed */
- MDSRV_StringManager.prototype.stringLookup = function(key, param)
- {
- var locStr = this.m_stringMap[key];
- //replace any occurences of $$ with param
- if (param)
- {
- locStr = locStr.replace("$$", param);
- }
- return locStr;
- }
|