123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- if ( ! LNS )
- var LNS = {};
- LNS.typeDataItem = "dataItem";
- LNS.typeReportItem = "reportItem";
- LNS.typeObjectSubclassRegular = "regular";
- LNS.sReportID = "[Report]";
- LNS.sPaneReportResId = "report";
- LNS.sPanePackageResId = "package";
- LNS.sPaneDatabaseResId = "dataSources";
- LNS.sPaneReportName = "Report";
- LNS.sPanePackageName = "Package";
- LNS.sPaneDatabaseName = "Data Sources";
- LNS.sObjectLocationByType = [];
- LNS.sObjectLocationByType["query"] = 'report';
- LNS.sObjectLocationByType["dataItem"] = 'report';
- LNS.sObjectLocationByType["reportItem"] = 'report';
- LNS.sObjectLocationByType["summaryFilter"] = 'report';
- LNS.sObjectLocationByType["detailFilter"] = 'report';
- LNS.sObjectLocationByType["dataSource"] = 'datasources';
- LNS.mapAllowedParentTypes = [];
- LNS.mapAllowedParentTypes["querySubject"] = true;
- LNS.mapAllowedParentTypes["dimension"] = true;
- LNS.mapAllowedParentTypes["query"] = true;
- LNS.mapIgnoreShortcutsByType = [];
- LNS.mapIgnoreShortcutsByType["detailFilter"] = true;
- LNS.mapIgnoreShortcutsByType["filterDefinition"] = true;
- LNS.mapIgnoreShortcutsByType["summaryFilter"] = true;
- LNS.mapIgnoreShortcutsByType["slicerMemberSet"] = true;
- LNS.mapIgnoreShortcutsByType["reportItem"] = true;
- function CModelData ( mdsrv_LineageResponseHelper )
- {
- this.responseHelper = mdsrv_LineageResponseHelper;
- this.arrNodes = new Array();
- this.arrNodes.numberOfRegisteredObjects = 0;
- this.mapObjectInclusionById = new Array();
- this.arrConnections = new Array();
- this.mapConnectionNames = new Array();
- this.arrRegisteredObjects = new Array();
- this.paneNames = new Array();
- this.arrParentModelObjects = new Array();
-
-
-
-
-
- var lineageObjs = this.responseHelper.getQueryResults();
- for ( var i = 0; i < lineageObjs.length; i++ )
- {
- this.examineForChildRefs( lineageObjs[i] );
- }
-
- this.processChildren ();
- }
- CModelData.prototype.examineForChildRefs = function( lineageObj )
- {
- var hasChildren = false;
- var childObjIds = lineageObj.getChildRefs();
-
- if ( childObjIds && childObjIds.length > 0 )
- {
- hasChildren = true;
- }
-
- if ( ! hasChildren )
- {
- this.examineLineageObject( lineageObj );
- }
- else
- {
-
- var hasTrans = false;
- var trans = lineageObj.getTransformation();
- if ( trans )
- {
- var sources = trans.getTransformationSourceList();
- if ( sources && sources.length > 0 )
- {
- hasTrans = true;
- }
- }
- if ( hasTrans )
- {
- this.examineLineageObject( lineageObj );
- }
- else
- {
-
- for (var childIdx = 0; childIdx < childObjIds.length; childIdx++)
- {
- var childObj = this.responseHelper.lookup( childObjIds[childIdx] );
- this.examineForChildRefs( childObj );
- }
- }
- }
- }
- CModelData.prototype.examineLineageObject = function( lineageObj )
- {
- var nColumnIndex = 0;
- var scObj = this.registerShortcutObject( lineageObj );
- if ( scObj )
- {
- var bAdded = this.addToNodes( scObj );
- if ( bAdded )
- {
- this.addConnection( scObj.getId(), lineageObj.getId() );
- scObj.nColumnIndex = nColumnIndex++;
- }
- }
- var modelObj = this.registerObject( lineageObj );
- modelObj.setMainObject( nColumnIndex === 0 );
- this.visitObject( modelObj, nColumnIndex );
- }
- CModelData.prototype.registerObject = function( lineageObj )
- {
- var bNew = false;
- var modelObj = this.arrRegisteredObjects[ lineageObj.getId() ];
- if ( ! modelObj )
- {
- modelObj = new CModelObject( lineageObj );
- bNew = true;
- this.arrRegisteredObjects[ modelObj.getId() ] = modelObj;
- if ( Array.indexOf( this.paneNames, modelObj.getObjLocation() ) === -1 )
- this.paneNames[ this.paneNames.length ] = modelObj.getObjLocation();
- modelObj.isPackageDataSourceObject();
- }
- modelObj.bNew = bNew;
- return modelObj;
- }
-
- CModelData.prototype.registerShortcutObject = function( lineageObj )
- {
- if ( ! LNS.mapIgnoreShortcutsByType[ lineageObj.m_type ] )
- {
- var modelObj = this.registerObject( lineageObj );
- if ( modelObj.bNew )
- {
- var shortcutModelObj = new CModelObject( lineageObj, modelObj );
- this.arrRegisteredObjects[ shortcutModelObj.getId() ] = shortcutModelObj;
- return shortcutModelObj;
- }
- }
- return null;
- }
- CModelData.prototype.addObject = function( refObjId, origModelObj, bIncrementColumnIndex )
- {
- var refLinObj = this.responseHelper.lookup( refObjId );
- ASSERT ( refLinObj, "responseHelper.lookup: object '" + refObjId + "' is not found in the lineage response !!!" );
- if ( refLinObj )
- {
- this.addConnection( origModelObj.getId(), refObjId );
- var refModelObj = this.registerObject( refLinObj );
- if ( refModelObj.bNew )
- {
- var nNewIndex = bIncrementColumnIndex ? origModelObj.nColumnIndex + 1 : origModelObj.nColumnIndex;
- if ( origModelObj.getObjLocation() != refModelObj.getObjLocation() )
- {
-
-
- nNewIndex = 0;
- }
- this.visitObject( refModelObj, nNewIndex );
- }
- }
- }
- CModelData.prototype.visitObject = function( modelObj, nColumnIndex )
- {
-
-
- modelObj.nColumnIndex = nColumnIndex;
- if ( ! this.visitParent( modelObj ) )
- {
- this.addToNodes( modelObj );
- }
- var transformationObj = modelObj.lineageObj.getTransformation();
- var bHasReferences = transformationObj && transformationObj.getTransformationSourceList().length > 0;
- if ( bHasReferences )
- {
- var transObjs = transformationObj.getTransformationSourceList();
- for ( var nIndex = 0; nIndex < transObjs.length; ++nIndex )
- {
- var refObjId = transObjs[ nIndex ].getObjectRef();
- this.addObject ( refObjId, modelObj, true );
- }
- }
- else
- {
- var childObjIds = modelObj.lineageObj.getChildRefs();
-
- for ( var nIndex = 0; nIndex < childObjIds.length; ++nIndex )
- {
- var refChildObjId = childObjIds[ nIndex ];
- this.addObject ( refChildObjId, modelObj, false );
- }
- }
- }
- CModelData.prototype.addConnection = function( leftId, rightId )
- {
- var sConnName = leftId + "-&&-" + rightId;
- if ( ! this.mapConnectionNames[ sConnName ] )
- {
- this.arrConnections[ this.arrConnections.length ] = [ leftId, rightId ];
- this.mapConnectionNames[ sConnName ] = true;
- }
- }
- CModelData.prototype.registerConnections = function ( origModelObj )
- {
- transformationObj = origModelObj.lineageObj.getTransformation();
- if ( transformationObj )
- {
- var transObjs = transformationObj.getTransformationSourceList();
- for ( var t = 0; t < transObjs.length; t++)
- {
- var refObjId = transObjs[t].getObjectRef();
- var refModelObj = this.registerObject( this.responseHelper.lookup( refObjId ) );
- this.addConnection( origModelObj.getId(), refModelObj.getId() );
- }
- }
- }
- CModelData.prototype.processChildren = function()
- {
- for ( var i = 0; i < this.arrParentModelObjects.length; i++ )
- {
- var parentModelObj = this.arrParentModelObjects[i];
- var childObjIds = parentModelObj.lineageObj.getChildRefs();
-
-
- for ( var j = 0; j < childObjIds.length; j++ )
- {
- var lineageObject = this.responseHelper.lookup( childObjIds[j] );
- if ( lineageObject )
- {
- var childModelObj = this.registerObject( lineageObject );
- if ( childModelObj.bNew )
- {
-
- this.visitObject ( childModelObj, parentModelObj.nColumnIndex );
- }
- }
- }
- }
- }
- CModelData.prototype.visitParent = function( modelObj )
- {
- var bAddedParent = false;
- var currentLinObj = modelObj.lineageObj;
- while ( true )
- {
- var parentObjId = currentLinObj.getParentRef();
- if ( ! parentObjId || parentObjId === "null" || parentObjId === LNS.sReportID )
- break;
- var parentLinObj = this.responseHelper.lookup( parentObjId );
- var type = parentLinObj.getType();
- if ( LNS.mapAllowedParentTypes[ type ] )
- {
- var childObjIds = parentLinObj.getChildRefs();
-
- var parentModelObj = this.registerObject( parentLinObj );
- bAddedParent = true;
- if ( parentModelObj.bNew )
- {
- this.arrParentModelObjects.push( parentModelObj );
- this.addToNodes( parentModelObj );
- if ( parentModelObj.nColumnIndex === 0 )
- {
- parentModelObj.nColumnIndex = modelObj.nColumnIndex;
- }
- }
- parentModelObj.addChild( modelObj );
- break;
- }
- currentLinObj = parentLinObj;
- }
- return bAddedParent;
- }
- CModelData.prototype.addToNodes = function( modelObj )
- {
- var bAdded = false;
- var objId = modelObj.getId();
- if ( ! this.mapObjectInclusionById[ objId ] )
- {
- this.arrNodes[ objId ] = this.arrRegisteredObjects[ objId ];
- this.arrNodes[ this.arrNodes.numberOfRegisteredObjects ] = this.arrRegisteredObjects[ objId ];
- this.arrNodes.numberOfRegisteredObjects++;
- this.mapObjectInclusionById[ objId ] = true;
- bAdded = true;
- }
- return bAdded;
- }
- CModelData.prototype.getPaneCount = function()
- {
- return this.paneNames.length;
- }
- CModelData.prototype.getPaneName = function( i )
- {
- return this.paneNames[ i ];
- }
- CModelData.prototype.getQueryCount = function ()
- {
- return this.arrNodes.numberOfRegisteredObjects;
-
- }
- CModelData.prototype.getObjectCount = function ()
- {
- return this.arrNodes.numberOfRegisteredObjects;
- }
- CModelData.prototype.getQuery = function ( i )
- {
- return this.arrNodes[i];
- }
- CModelData.prototype.getObject = function ( i )
- {
- return this.arrNodes[i];
- }
- CModelData.prototype.getConnectionCount = function()
- {
- return this.arrConnections.length;
- }
- CModelData.prototype.getConnection = function( i )
- {
- return this.arrConnections[i];
- }
- CModelData.prototype.getConnectionLeft = function( i )
- {
- return this.arrConnections[i][0];
- }
- CModelData.prototype.getConnectionRight = function( i )
- {
- return this.arrConnections[i][1];
- }
- function CModelObject( mdsrv_LineageObject, modelObject )
- {
- this.lineageObj = mdsrv_LineageObject;
- this.shortcutTo = null;
- this.nColumnIndex = 0;
- this.bMain = false;
- if ( modelObject )
- {
-
- this.shortcutTo = modelObject;
- }
- }
- CModelObject.prototype.getItemCount = function()
- {
- if ( this.model_data_childList )
- {
- return this.model_data_childList.numberOfRegisteredObjects;
- }
- return 0;
- }
- CModelObject.prototype.getItem = function( i )
- {
- if ( this.model_data_childList )
- {
- return this.model_data_childList[i];
- }
- return null;
- }
- CModelObject.prototype.addChild = function( childObj )
- {
- if ( ! this.model_data_childList )
- {
- this.mapChildInclusionById = new Array();
- this.model_data_childList = new Array();
- this.model_data_childList.numberOfRegisteredObjects = 0;
- }
- if ( ! this.mapChildInclusionById[ childObj.getId() ] )
- {
- this.model_data_childList[ childObj.getId() ] = childObj;
- this.model_data_childList[ this.model_data_childList.numberOfRegisteredObjects ] = childObj;
- this.model_data_childList.numberOfRegisteredObjects++;
- this.mapChildInclusionById[ childObj.getId() ] = true;
- }
- }
- CModelObject.prototype.getPropertyCount = function()
- {
- var propArray = this.lineageObj.getProperties();
-
- return propArray.length;
- }
- CModelObject.prototype.getPropertyName = function( nProp )
- {
- var propArray = this.lineageObj.getProperties();
- return propArray[nProp].getName();
-
-
- }
- CModelObject.prototype.getPropertyDisplayName = function( nProp )
- {
- var propArray = this.lineageObj.getProperties();
- return propArray[nProp].getDisplayName();
- }
- CModelObject.prototype.getPropertyValue = function( nProp )
- {
- var propArray = this.lineageObj.getProperties();
- return propArray[nProp].getValue();
- }
- CModelObject.prototype.findPropertyValue = function ( sPropName )
- {
- var sPropValue = "";
- var cProperties = this.getPropertyCount();
- for ( var i = 0; i < cProperties; i++ )
- {
- if ( this.getPropertyName(i) === sPropName )
- {
- sPropValue = this.getPropertyValue(i);
- break;
- }
- }
- return sPropValue;
- }
- CModelObject.prototype.isPackageDataSourceObject = function ()
- {
- this.bPackageDataSourceObject = false;
- var sPropValue = this.findPropertyValue( 'definitionType' );
- if ( sPropValue === 'Data Source' )
- {
- this.bPackageDataSourceObject = true;
- }
- else
- {
- sPropValue = this.findPropertyValue( 'externalName' );
- if ( sPropValue.length > 0 )
- this.bPackageDataSourceObject = true;
- }
- return this.bPackageDataSourceObject;
- }
- CModelObject.prototype.getObjLocation = function()
- {
- var sObjectLocation = LNS.sObjectLocationByType[ this.lineageObj.getType() ];
-
-
-
-
- if (sObjectLocation != "report" && sObjectLocation != "datasources")
- sObjectLocation = null;
- if ( ! sObjectLocation )
- sObjectLocation = LNS.sPanePackageResId;
- var sPaneName = MDSRV_techView_StringManager.stringLookup( sObjectLocation );
- return sPaneName;
- }
- CModelObject.prototype.isReportPane = function()
- {
- return ( this.getObjLocation() === LNS.sPaneReportName );
- }
- CModelObject.prototype.isModelPane = function()
- {
- return ( this.getObjLocation() === LNS.sPanePackageName );
- }
- CModelObject.prototype.isDatabasePane = function()
- {
- return ( this.getObjLocation() === LNS.sPaneDatabaseName );
- }
- CModelObject.prototype.getPaneName = function()
- {
- return this.getObjLocation();
- }
- CModelObject.prototype.setMainObject = function( bMain )
- {
- this.bMain = ( true ? bMain === true : false );
- }
- CModelObject.prototype.isMainObject = function()
- {
- var bRet = false;
- if ( this.bMain || this.shortcutTo )
- {
- bRet = true;
- }
- return bRet;
- }
- CModelObject.prototype.getColumnIndex = function()
- {
- var nColumnIndex = 0;
- if ( this.nColumnIndex )
- {
- nColumnIndex = this.nColumnIndex;
- }
- return nColumnIndex;
- }
- CModelObject.prototype.isRootObject = function()
- {
- return ( this.nColumnIndex === 0 );
- }
- CModelObject.prototype.getObjClass = function()
- {
- return this.lineageObj.getType();
- }
- CModelObject.prototype.getObjSubClass = function()
- {
- return LNS.typeObjectSubclassRegular;
- }
- CModelObject.prototype.getName = function()
- {
- return this.lineageObj.getName();
- }
- CModelObject.prototype.getShortcutTo = function()
- {
- if ( this.shortcutTo )
- {
- return this.shortcutTo;
- }
- return null;
- }
- CModelObject.prototype.getId = function()
- {
- var id = this.lineageObj.getId();
- if ( this.shortcutTo )
- {
- id = '_' + id;
- }
- return id;
- }
- CModelObject.prototype.findObjectById = function( objectArray, objId )
- {
- var index = -1;
- for ( var i = 0; i < objectArray.length; i++ )
- {
- if ( objectArray[i].getId() === objId )
- {
- index = i;
- break;
- }
- }
- return index;
- }
|