<@doc> Class provides some methods to retrieve the metadata of BusinessObjects #INCLUDE[gml:defs.inc] Class SearchConnector inherit gml:Object; property id = '#NS[SearchConnector]'; //the id used to identify the helper object property SearchService = "SearchService"; property SDIService = "VCSDIProxyService"; property httpRequest = null; property unifiedSearchElm = null; property unifiedBrowseElm = null; virtual property urlPrefix='#URL[]'; virtual property localProvider=''; constructor (elem) this.localProvider='local_DriveC/local_DriveC'; this.urlPrefix = this.urlPrefix.substr(0,this.urlPrefix.indexOf("=")+1); currentObj = this; if (!elem) return; // this.unifiedSearchElm, this.unifiedBrowseElm will be set afterwards if(elem.tagName == "UnifiedSearch"){ this.unifiedSearchElm = elem; } else if(elem.tagName == "UnifiedBrowse"){ this.unifiedBrowseElm = elem; } end //---------------- search methods ------------------------------------ <@doc> Get all the searchProviders which are related to the model the production kit in the model /* XML: */ method getProvidersList(productionKit) // DEVTIME [] workaround var devTime = false; var providersList = []; var params=[]; var services = [this.SearchService, this.SDIService]; params[0] = productionKit; for (var k in services) { var xml = $ENV.channel2.executeService(services[k],"getSearchProviderList", params); if (xml == null) { #LOG[4, 'Error in Search: '+$ENV.channel2.error]; continue; } else if (typeof xml == 'string') { WRITE('Error in Search:'+ xml); continue; } providersList = providersList.concat(this.parseProvidersList(xml)); } var searchProvider; // Search for local components if($CTL.getVar('LocalObjectsEnabled') == true) { searchProvider = {}; searchProvider.value = 'local_DriveC'; searchProvider.text= "  local_objects directory"; providersList.unshift(searchProvider); } return(providersList); end <@doc> Parse providersList xml the xml /* XML: */ method parseProvidersList(xml) var searchProvider, items, icon, item,searchProviders=[]; // DEVTIME [] workaround var devTime = false; if (!xml) return(searchProviders); var technologiesInfo = xml.getElementsByTagName("provider"); for (var i=0, len=technologiesInfo.length;i Get search providers data for a selected searchProvider the searchProvider ID /* XML: */ method getProviderData(providerID) //set type to HashMap var params=[]; if(providerID == 'local_DriveC'){ var xmlStr = '' return PARSEXML(xmlStr); } var serviceToCall = this.isSDIProvider(providerID) ? this.SDIService : this.SearchService; params[0] = providerID; var xml = $ENV.channel2.executeService(serviceToCall,"getSearchProviderDetails", params); if (xml == null) { #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return(null); } else if (typeof xml == 'string') { WRITE('Error in Search:'+ xml); return(null); } return(xml); end <@doc> Parse LinksInfo xml the xml /* XML: ... */ method parseProviderLinks(providerXml) var link, items, item,links=[]; var xml = providerXml && providerXml.getElementsByTagName("links")[0] ; if (!xml) return(links); //retreive the title - use it later in the method var title = xml.getAttribute("title") || ''; //add the title, if it's needed. title is a link of type "TITLE" if (title ) links.push({name:title,type:"TITLE"}); var currentSys='#SYS[COM_SAP_VDS_PLATFORMSPECIFIC_PROPERTIES_PLATFORM]'=='eclipse'?'service':'href'; var linksInfo = xml.getElementsByTagName("link"); for (var i=0, len=linksInfo.length;i0) links.push(link); return(links); end <@doc> Parse wizard xml the provider Xml /* XML: */ method parseProviderWizardButton(providerXml, expectedType) { var url = "",link={}; var wizards = providerXml && providerXml.getElementsByTagName("wizard"); if (wizards.length>0) { var wizard = wizards[0]; if (wizard && wizard.getAttribute("type") == expectedType) { link.type="WIZARD"; // wizard link is a link of type "WIZARD" link.urn=wizard.getAttribute("urn"); link.name=wizard.getAttribute("label"); } } return(link); } <@doc> Get value of a provider's hasSystems proeprty the xml method parseHasSystems(providerXml) { var hasSystems = true; var hasSystemsNodes = providerXml && providerXml.getElementsByTagName("hasSystems"); if (hasSystemsNodes.length > 0) { var hasSystemsNode = hasSystemsNodes[0]; hasSystems = BOOL(LOWER(hasSystemsNode.getAttribute("value"))); } return(hasSystems); } <@doc> Get a provider's SearchButton definition the xml method parseSearchButton(providerXml) { var searchButton = {visible:true}; var searchButtonNodes = providerXml && providerXml.getElementsByTagName("searchButton"); if (searchButtonNodes.length > 0) { var searchButtonNode = searchButtonNodes[0]; searchButton.visible = BOOL(LOWER(searchButtonNode.getAttribute("visible"))); } return(searchButton); } <@doc> Get a provider's SearchString definition the xml method parseSearchString(providerXml) { var searchString = {visible:true}; var searchStringNodes = providerXml && providerXml.getElementsByTagName("searchString"); if (searchStringNodes.length > 0) { var searchStringNode = searchStringNodes[0]; searchString.visible = BOOL(LOWER(searchStringNode.getAttribute("visible"))); } return(searchString); } <@doc> Prase provider xml the xml method parseProviderSystems(providerData) var systemNodes = providerData.getElementsByTagName("system"); var arr=[]; for (var i=0, len=systemNodes.length;i Parse provider xml. If there is systemError returns the error message. Else returns null. the xml method parseProviderSystemError(providerData) var systemNodes = providerData.getElementsByTagName("system"); for (var i=0, len=systemNodes.length;i=0){ return systemNodes[i].getAttribute("value"); } } return null; end <@doc> Prase provider xml the xml method parseObjectTypes(providerData) var xml = providerData.getElementsByTagName("objectTypes")[0]; var arr=[]; for (var i=0, len=xml.childNodes.length;i open an IDE link the corresponding provider the link to open method activateLink(providerID, linkID) var params = []; params[0] = providerID; params[1] = linkID; var serviceToCall = this.isSDIProvider(providerID) ? this.SDIService : this.SearchService; $ENV.channel2.executeService(serviceToCall,"openIDELink", params); end <@doc> Get all the search providers which are related to the model the production kit in the model the object key is the provider name and the value is the deisplayed name method getSearchProviders(productionKit) var types = {}; // DEVTIME [] workaround var devTime = false; // Search for local components if($CTL.getVar('LocalObjectsEnabled') == true) types['local_DriveC'] = 'local_objects directory'; if($ENV.channel2.protocol == 'j2ee/dev') { var params = []; params[0] = productionKit; var results = $ENV.channel2.executeService(this.SearchService,"getSearchProviders", params); if (results == null) { #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof results == 'string') { WRITE('Error in Search:'+ results); return; } var items = results.childNodes; var item; while (item = items.nextNode) { types[REPLACE(unescape(item.getAttribute('key')), '+', ' ')] = REPLACE(unescape(item.getAttribute('value')), '+', ' '); } //Search also for systems from SDI providers try { results = $ENV.channel2.executeService(this.SDIService,"getSearchProviders", params); if (results == null) { #LOG[4, 'Error in SDI getSystems: '+ (($ENV.channel2 && $ENV.channel2.error) || exn.description || 'Unknown')]; return; } else if (typeof results == 'string') { WRITE('Error in SDI getSystems: '+ results); return; } items = results.childNodes; while (item = items.nextNode) { types[REPLACE(unescape(item.getAttribute('key')), '+', ' ')] = REPLACE(unescape(item.getAttribute('value')), '+', ' '); } } catch (exn) { #LOG[4, 'Error in SDI getSystems: '+ (($ENV.channel2 && $ENV.channel2.error) || exn.description || 'Unknown')]; return types; } } //Sort the returned systems: create an array, sort it, and convert it back to the map var a = []; for (var k in types) a.push({name:types[k],key:k}); var sorted = SORT(a,'name'); var ret = {}; for (var i = 0; i < sorted.length; i++) ret[sorted[i].key] = sorted[i].name; //return types; return ret; end <@doc> return true if the provider support paging the id of the provider to check with the destination name, separated by a slash TRUE iff the provider is a 'new' provider (SDI) method isSDIProvider(providerID) var sdiProviderIDs = ["SDIJDBCProvider","SDIJDBCSearchProvider", "WDSearchProvider", "WDDiscoveryProvider", "SDINEWDBProvider","SDINEWDBSearchProvider"]; var lowerCaseID = providerID.toLowerCase(); for (var i = 0; i < sdiProviderIDs.length; i++) { if (lowerCaseID.indexOf(sdiProviderIDs[i].toLowerCase()) >= 0) return true; } return false; end <@doc> return true if the provider support paging the provider to check method supportPaging(provider) var params = []; params[0] = provider; var result = $ENV.channel2.executeService(this.SearchService,"supportPaging", params, null, this.onFailed); return result; end <@doc> get the object types of the selected provider the selected provider the object key is the object type id and the value is the object type name method getObjectTypes(provider) var types = {}; if(provider == this.localProvider){ types['components'] = 'Components'; // Search for local components return types; } var serviceToCall = this.isSDIProvider(provider) ? this.SDIService : this.SearchService; var params = []; var configurationParameters = {}; //set type to HashMap configurationParameters['_objectType'] = "HASHMAP"; configurationParameters[#[DISCOVERY_PARAMETER_SYSTEM]] = provider; //Can be sent always - the search provider will get the map only if it overides the getObjectTypes() method configurationParameters[#[DISCOVERY_PARAMETER_SEARCH_CONTEXT]] = this.unifiedSearchElm.getSearchContext(); params[0] = configurationParameters; var result = $ENV.channel2.executeService(serviceToCall,"getObjectTypes", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in getObjectTypes: '+$ENV.channel2.error]; return; } else if (typeof result == 'string'){ WRITE('Error getting the object types:'+ result); return; } var items = result.childNodes; var item; while (item = items.nextNode){ types[REPLACE(unescape(item.getAttribute('key')), '+', ' ')] = REPLACE(unescape(item.getAttribute('value')), '+', ' '); } return types; end <@doc> get the additional parameters for the search the selected provider the selected object type object with the additional parameters method getAdditionalParamsEditor(provider, objectType) if(provider == 'local_DriveC') return; // Search for local components var params = []; params[0] = provider; params[1] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getAdditionalParamsEditor", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } if(typeof result == 'string') return result; else{ var objRes = this.getResultsList(result); return objRes; } end method getResultsList(result) if (!result) return []; var items = result.childNodes; if (!items) return []; var resultParams = []; var item; try { while (item = items.nextNode){ var obj = { name: REPLACE(unescape(item.getAttribute('name')), '+', ' '), label: REPLACE(unescape(item.getAttribute('label')), '+', ' '), type: REPLACE(unescape(item.getAttribute('type')), '+', ' ') } resultParams.push(obj); } } catch (e) { var errMsg = 'Error while parsing additional params: '+(e.description || 'NA'); #LOG[4, errMsg]; WRITE(errMsg); return []; } return resultParams; end <@doc> execute the search operation. this is an asynchronous operation. when it finished, it execute the function parseResults, which parse the results and pass them to the search element. key:value object with parameters for the search the selected provider page size if the provider support paging //searchParams is key:value object with params for the search method search(searchParams, provider, pageSize) if(provider == this.localProvider) { this.localSearch(searchParams,provider); } else { searchParams['_objectType'] = "HASHMAP"; searchParams[#[DISCOVERY_PARAMETER_SEARCH_CONTEXT]] = this.unifiedSearchElm.getSearchContext(); var params =[]; params[0] = searchParams; params[1] = pageSize; params[2] = provider; var serviceToCall = this.isSDIProvider(provider) ? this.SDIService : this.SearchService; var result = $ENV.channel2.executeServiceAsync(serviceToCall,"search", params, this.parseResults, this.onError, {elem:this.unifiedSearchElm,provider:provider}); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof(result) == 'string') { var errMsg = "Error in Search: " + result; #LOG[4, errMsg]; WRITE(errMsg); return; } this.httpRequest = result; return; } end <@doc> execute a local search operation. key:value object with parameters for the search //searchParams is key:value object with params for the search method localSearch(searchParams,provider) if(searchParams.objectType == 'components'){ var fso, folder, file, fileText, fc, name, counter=0; var obj; var resultParams = []; var elem = this.unifiedSearchElm; try{ fso = new ActiveXObject("Scripting.FileSystemObject"); } catch (e) { PROMPT('#TEXT[YMSG_ACTIVEX]'); resultParams['tsize'] = 0; resultParams['csize'] = 0; elem.showResults(resultParams); return; } try { var searchString = searchParams.searchString; if(searchString == '*'){ folder = fso.GetFolder("c:\\local_objects"); fc = new Enumerator(folder.files); for (; !fc.atEnd(); fc.moveNext()){ counter++; fullname = fc.item().Name; file = fso.OpenTextFile("c:\\local_objects\\"+fullname, 1); fileText = file.ReadAll(); obj = {}; var type = ''; var xml = PARSEXML(fileText); if (xml) { var metadataNode = XMLNODES(xml, '/metadata'); if(metadataNode && metadataNode[0]) type = 'core.'+metadataNode[0].getAttribute('type'); } obj['name'] = fullname.replace('.xml','').replace('.XML',''); obj['id'] = obj.name; obj['icon'] = ''; obj['gmlObject'] = type; obj['data'] = ''; //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.localPopulateDynamicProperties(obj,obj['id'],obj['name'],obj['icon'],obj['gmlObject'],provider,searchParams.objectType); resultParams.push(obj); } resultParams['tsize'] = counter; resultParams['csize'] = counter; } else{ fullname = searchString+".xml"; file = fso.OpenTextFile("c:\\local_objects\\"+fullname, 1); fileText = file.ReadAll(); obj = {}; var type = ''; var xml = PARSEXML(fileText); if(xml){ var metadataNode = XMLNODES(xml,'/metadata'); if(metadataNode && metadataNode[0]) type = 'core.'+metadataNode[0].getAttribute('type'); } obj['name'] = fullname.replace('.xml','').replace('.XML',''); obj['id'] = fullname; obj['icon'] = ''; obj['gmlObject'] = type; obj['data'] = ''; //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.localPopulateDynamicProperties(obj,obj['id'],obj['name'],obj['icon'],obj['gmlObject'],provider,searchParams.objectType); resultParams.push(obj); resultParams['tsize'] = 1; resultParams['csize'] = 1; } } catch(e){ resultParams = []; resultParams['tsize'] = 0; resultParams['csize'] = 0; #LOG[4, 'Failed to search. Error - '+e.description]; if (e.description=='Path not found') PROMPT('#TEXT[XMSG_LOCALOBJ_DIRECTORY]'); } elem.showResults(resultParams); } end method parseResults(response, elemContainer) //unified Search element reference var elem = elemContainer.elem||null; var providerString = elemContainer.provider||''; var index = providerString.indexOf('/'); var provider; //Proboably in all cases the provider string will be conactenated with the system e.g. R3Provider/ILSTORM if (index > 0) { provider = providerString.substring(0,index); } else { provider = providerString; } if(elem.searchCancelled){ return; } var results = $ENV.channel2.analyseresults(response); if (typeof results == 'string'){ WRITE('Error in search: ' + (results ||'')); elem.showResults(null); return; } var items = results.childNodes; var resultParams = []; var item; var counter = 0; while (item = items.nextNode){ if (item.getAttribute('name') == 'tsize'){ resultParams['tsize'] = item.getAttribute('value'); } else if (item.getAttribute('name') == 'csize'){ resultParams['csize'] = item.getAttribute('value'); } else if(counter < parseInt(resultParams['csize']) ){ counter++; var obj = {}; obj['id'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); obj['name'] = REPLACE(unescape(item.getAttribute('name')), '+', ' '); obj['system'] = REPLACE(unescape(item.getAttribute('system')), '+', ' '); obj['icon'] = REPLACE(currentObj.getIconFromVCNode(item), '+', ' '); obj['gmlObject'] = REPLACE(unescape(item.getAttribute('gmlObject')), '+', ' '); obj['objectType'] = REPLACE(unescape(item.getAttribute('objectType')), '+', ' '); obj['hasChildNodes'] = REPLACE(unescape(item.getAttribute('hasChildNodes')), '+', ' '); obj['event'] = REPLACE(unescape(item.getAttribute('event')), '+', ' '); //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.populateDynamicProperties(item,obj,provider); resultParams.push(obj); } } elem.showResults(resultParams); end method localPopulateDynamicProperties(resultObject,id,name,icon,gmlObject,providerString,objectType) var index = providerString.indexOf('/'); var provider; //Proboably in all cases the provider string will be conactenated with the system e.g. R3Provider/ILSTORM if (index > 0) { provider = providerString.substring(0,index); } else { provider = providerString; } var discoveryParameters = {}; //Update the discovery common parameters discoveryParameters[#[DISCOVERY_PARAMETER_NODE_ID]] = id; discoveryParameters[#[DISCOVERY_PARAMETER_NODE_NAME]] = name; discoveryParameters[#[DISCOVERY_PARAMETER_ICON]] = icon; discoveryParameters[#[DISCOVERY_PARAMETER_OBJECT_TYPE]] = objectType; discoveryParameters[#[DISCOVERY_PARAMETER_PROVIDER_NAME]] = provider; //discoveryParameters[#[DISCOVERY_PARAMETER_SYSTEM]] = system; //VC Specific discoveryParameters[#[DISCOVERY_PARAMETER_VC_GML_OBJECT]] = gmlObject; resultObject['discoveryParameters'] = discoveryParameters; end method populateDynamicProperties(vcnode, resultObject,provider) var innerItem; //Additional Parameters var additionalParametersNode = vcnode.firstChild; var parameters = additionalParametersNode.childNodes; var data = {}; while (innerItem = parameters.nextNode) { data[REPLACE(unescape(innerItem.getAttribute('key')), '+', ' ')] = REPLACE(unescape(innerItem.getAttribute('value')), '+', ' '); } resultObject['data'] = data; //Discovery Parameters var discoveryParametersNode = additionalParametersNode.nextSibling; parameters = discoveryParametersNode.childNodes; var discoveryParameters = {}; while (innerItem = parameters.nextNode) { discoveryParameters[REPLACE(unescape(innerItem.getAttribute('key')), '+', ' ')] = REPLACE(unescape(innerItem.getAttribute('value')), '+', ' '); } //Update the discovery common parameters discoveryParameters[#[DISCOVERY_PARAMETER_NODE_ID]] = resultObject['id']; discoveryParameters[#[DISCOVERY_PARAMETER_NODE_NAME]] = resultObject['name']; discoveryParameters[#[DISCOVERY_PARAMETER_SYSTEM]] = resultObject['system']; discoveryParameters[#[DISCOVERY_PARAMETER_ICON]] = resultObject['icon']; discoveryParameters[#[DISCOVERY_PARAMETER_OBJECT_TYPE]] = resultObject['objectType']; //VC Specific discoveryParameters[#[DISCOVERY_PARAMETER_VC_GML_OBJECT]] = resultObject['gmlObject']; discoveryParameters[#[DISCOVERY_PARAMETER_VC_HAS_CHILDREN]] = resultObject['hasChildNodes']; discoveryParameters[#[DISCOVERY_PARAMETER_PROVIDER_NAME]] = provider; //discoveryParameters['event'] = resultObject['event']; resultObject['discoveryParameters'] = discoveryParameters; end method onError(res, str, params, xmlhttp) // WRITE("error: " + str); #LOG[4, 'Error in Search: '+str]; var errStr = null; if (xmlhttp && xmlhttp.status == 500){ // Internal Server Error - probably time out errStr = '#TEXT[XMSG_TIMEOUT]'; } if (params && params.elem) { var elem = params.elem; elem.onServerError(errStr); elem.enableSearch(true); } end <@doc> get the next results page of the provider, if it support paging. true for next results and false for previous results the selected provider the last record shown already the page size object with the search results method getNextResults(next, provider, lastRec, pageSize) var params =[]; params[0] = next; params[1] = provider; params[2] = pageSize; params[3] = lastRec; var result = $ENV.channel2.executeService(this.SearchService,"nextResults", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return null; } else if (typeof result == 'string'){ WRITE(result); return null; } var searchResults = this.getSearchResultsList(result,provider); return searchResults; end method getSearchResultsList(results,provider) var items = results.childNodes; var resultParams = []; var item; while (item = items.nextNode){ if (item.getAttribute('name') == 'tsize'){ resultParams['tsize'] = item.getAttribute('value'); } else if (item.getAttribute('name') == 'csize'){ resultParams['csize'] = item.getAttribute('value'); } else { var innerItems = item.childNodes; var obj = {}; obj['name'] = REPLACE(unescape(item.getAttribute('name')), '+', ' '); obj['id'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); obj['icon'] = REPLACE(currentObj.getIconFromVCNode(item), '+', ' '); obj['gmlObject'] = REPLACE(unescape(item.getAttribute('gmlObject')), '+', ' '); obj['hasChildNodes'] = REPLACE(unescape(item.getAttribute('hasChildNodes')), '+', ' '); obj['system'] = REPLACE(unescape(item.getAttribute('system')), '+', ' '); //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.populateDynamicProperties(item,obj,provider); resultParams.push(obj); } } return resultParams; end <@doc> cancel the search operation method cancel() this.httpRequest.abort(); end <@doc> get more details on a local selected result the name of the selected result method localGetDetailsForItem(name, objectType) if(objectType == 'components'){ var fso, file, fileText, fc, name, counter=0; fso = new ActiveXObject("Scripting.FileSystemObject"); file = fso.OpenTextFile("c:\\local_objects\\"+name+".xml", 1); fileText = file.ReadAll(); var result = []; result.xml = fileText; return result; } end <@doc> get the related browse provider for the locate in tree operation the selected provider the related provider method getRelatedBrowseProvider(provider) var params =[]; params[0] = provider; var result = $ENV.channel2.executeService(this.SearchService,"getRelatedBrowseProvider", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } return result; end <@doc> get the search context menu for specific object type the selected provider the selected object type object with the context menu method getSearchContextMenu(provider, objectType) var params = []; params[0] = provider; params[1] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getSearchContextMenu", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof result == 'string'){ WRITE(result); return null; } var items = result.childNodes; var resultParams = []; var item; while (item = items.nextNode){ var obj = { name: REPLACE(unescape(item.getAttribute('name')), '+', ' '), label: REPLACE(unescape(item.getAttribute('label')), '+', ' '), icon: REPLACE(unescape(item.getAttribute('icon')), '+', ' ') } resultParams.push(obj); } return resultParams; end <@doc> get the search context menu for specific object type the selected provider the node's id the selected object type object with the context menu method getSearchContextMenuWithID(provider, id,objectType) var params = []; params[0] = provider; params[1] = id; params[2] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getSearchContextMenu", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof result == 'string'){ WRITE(result); return null; } var items = result.childNodes; var resultParams = []; var item; while (item = items.nextNode){ var obj = { name: REPLACE(unescape(item.getAttribute('name')), '+', ' '), label: REPLACE(unescape(item.getAttribute('label')), '+', ' '), icon: REPLACE(unescape(item.getAttribute('icon')), '+', ' ') } resultParams.push(obj); } return resultParams; end //----------------------------browse methods---------------------------------------------- <@doc> Get all the browse providers which are related to the model the production kit in the model list of provider nodes method getBrowseProviders(productionKit) var params = []; params[0] = productionKit; var results = $ENV.channel2.executeService(this.SearchService,"getBrowseProviders", params, null, this.onFailed); if (results == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof results == 'string'){ WRITE(results); return null; } return this.getNodesList(results, "", true); end <@doc> get specific node according to its id the selected provider the node's id node method getNode(provider, id) var params = []; params[0] = provider; params[1] = id; var result = $ENV.channel2.executeService(this.SearchService,"getNode", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } return this.getNodeObj(result, provider); end <@doc> get all the child nodes of the gived node the selected provider the node's id the node list of child nodes method getChildNodes(provider, id, parentNode) var params = []; var propertyBag = {}; params[0] = provider; params[1] = id; if(parentNode.isRoot){ var name = parentNode.name; var str = name.substring(name.indexOf('>') +1, name.lastIndexOf('<')); params[2] = str; } else params[2] = parentNode.name; params[3] = parentNode.system; params[4] = parentNode.icon; params[5] = parentNode.gmlObject; params[6] = parentNode.objectType; //parentNode.data['_objectType'] = "HASHMAP"; //params[7] = parentNode.data; //Joining both discovery parameters and additional parameters into the same map //Best solution was to padd only the discovery parameters, but due to backward //compatibility reasons, we will pass both propertyBag['_objectType'] = "HASHMAP"; //Copy the discovery parameters for(var k in parentNode.discoveryParameters) { propertyBag[k] = parentNode.discoveryParameters[k]; } //Copy the additional parameters - if there is an overlapping //between two keys from the two map - additional map takes due to bckwrd comptb. for(var l in parentNode.data) { propertyBag[l] = parentNode.data[l]; } params[7] = propertyBag; if(parentNode.hasChildNodes == undefined) parentNode.hasChildNodes = true; params[8] = parentNode.hasChildNodes; var serviceToCall = this.isSDIProvider(provider) ? this.SDIService : this.SearchService; var results = $ENV.channel2.executeService(serviceToCall,"getChildNodes", params, null, null); //delete parentNode.data['_objectType']; if (results == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof results == 'string'){ WRITE(results); return null; } return this.getNodesList(results, provider, false); end /* <@doc> get all the child nodes of the gived node the node's id the node list of child nodes method retrieveDiscoveryChildNodes(id,parentNode) var params = []; var discoveryParameters = {}; var parentDiscoveryParameters = parentNode.discoveryParameters; //Copy the discovery parameters map for(var i in parentDiscoveryParameters) { var keyNameToCompare = i.substring(0,11); if(typeof parentDiscoveryParameters[i] == 'string' && keyNameToCompare == 'com.sap.sbi') discoveryParameters[i] = parentDiscoveryParameters[i]; } var provider = discoveryParameters[#[DISCOVERY_PARAMETER_PROVIDER_NAME]]; //update the selection id discoveryParameters[#[DISCOVERY_PARAMETER_NODE_ID]] = id; //Update then name if(parentNode.isRoot) { var name = parentNode.name; var str = name.substring(name.indexOf('>') +1, name.lastIndexOf('<')); discoveryParameters[#[DISCOVERY_PARAMETER_NODE_NAME]] = str; } else discoveryParameters[#[DISCOVERY_PARAMETER_NODE_NAME]] = parentNode.name; //set type to HashMap discoveryParameters['_objectType'] = "HASHMAP"; if(parentNode.hasChildNodes == undefined) parentNode.hasChildNodes = true; //Set the hasChildNodes discoveryParameters[#[DISCOVERY_PARAMETER_VC_HAS_CHILDREN]] = parentNode.hasChildNodes; params[0] = discoveryParameters; var results = $ENV.channel2.executeService(this.SearchService,"retrieveDiscoveryChildNodes", params, null, null); if (results == null) { #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof results == 'string') { WRITE(results); return null; } return this.getNodesList(results, provider, false); end */ <@doc> Returns the ancestors path leading to and including the specified node the selected provider the node's id Array of ids ehich is the path leading to the node method getNodePath(provider, id) var params = []; params[0] = provider; params[1] = id; var results = $ENV.channel2.executeService(this.SearchService,"getNodePath", params, null, null); if (results == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if(!results.values) return null; return results.values; end <@doc> get the browse context menu for specific node id the selected provider the node's id the node's system the selected object type object with the context menu method getBrowseContextMenu(provider, id, system, objectType) var params = []; params[0] = provider params[1] = id; params[2] = system; params[3] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getBrowseContextMenu", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof results == 'string'){ WRITE(results); return null; } var items = result.childNodes; var resultParams = []; var item; while (item = items.nextNode){ var obj = { name: REPLACE(unescape(item.getAttribute('name')), '+', ' '), label: REPLACE(unescape(item.getAttribute('label')), '+', ' '), icon: REPLACE(unescape(item.getAttribute('icon')), '+', ' ') } resultParams.push(obj); } return resultParams; end method getAsyncNodesList(response, params){ var provider = params[0]; var elem = params[1]; if(elem.browseCancelled){ return; } var results = $ENV.channel2.analyseresults(response); var provider = params[0]; var elem = params[1]; var items = results.childNodes; var resultParams = []; var item; while (item = items.nextNode){ var innerItems = item.childNodes; var obj = {}; obj['id'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); obj['name'] = REPLACE(unescape(item.getAttribute('name')), '+', ' '); if(provider == "") obj['provider'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); else obj['provider'] = provider; obj['system'] = REPLACE(unescape(item.getAttribute('system')), '+', ' '); obj['icon'] = REPLACE(currentObj.getIconFromVCNode(item), '+', ' '); obj['gmlObject'] = REPLACE(unescape(item.getAttribute('gmlObject')), '+', ' '); obj['objectType'] = REPLACE(unescape(item.getAttribute('objectType')), '+', ' '); obj['hasChildNodes'] = REPLACE(unescape(item.getAttribute('hasChildNodes')), '+', ' '); //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.populateDynamicProperties(item,obj,obj['provider']); resultParams.push(obj); } elem.insertChildNodes(resultParams); } method getNodesList(results, provider, isRoot) var items = results.childNodes; var resultParams = []; var item; while (item = items.nextNode){ var obj = this.getNodeObj(item, provider, isRoot); resultParams.push(obj); } return resultParams; end method getNodeObj(item, provider, isRoot) var innerItems = item.childNodes; var obj = {}; obj['id'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); obj['name'] = REPLACE(unescape(item.getAttribute('name')), '+', ' '); if(provider == "") obj['provider'] = REPLACE(unescape(item.getAttribute('id')), '+', ' '); else obj['provider'] = provider; obj['system'] = REPLACE(unescape(item.getAttribute('system')), '+', ' '); obj['icon'] = REPLACE(currentObj.getIconFromVCNode(item), '+', ' '); obj['gmlObject'] = REPLACE(unescape(item.getAttribute('gmlObject')), '+', ' '); obj['objectType'] = REPLACE(unescape(item.getAttribute('objectType')), '+', ' '); obj['hasChildNodes'] = REPLACE(unescape(item.getAttribute('hasChildNodes')), '+', ' '); obj['event'] = REPLACE(unescape(item.getAttribute('event')), '+', ' '); obj['isRoot'] = isRoot; //Since returning from async call var searchConnector = $ENV.searchlpr || $ENV.getHelper('#NS[SearchConnector]'); searchConnector.populateDynamicProperties(item,obj,provider); return obj; end //-------------------- common methods ------------------------------------------------ <@doc> return true if the provider support get quick details on demand the provider to check the system the object type method supportsQuickDetailsOnDemand(provider, system, objectType) if(provider == 'local_DriveC') return false; var params = []; params[0] = provider; params[1] = system; params[2] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"supportsQuickDetailsOnDemand", params, null, null); return result; end <@doc> get more details on the result. those details will be displayed in the .htm opened from the "show more" link in the additional information view. the selected provider the id of the selected result the name of the selected result the system the object type the details method getQuickDetailsOnDemand(provider, id, name, system, objectType) var params =[]; params[0] = provider; params[1] = id; params[2] = name; params[3] = system; params[4] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getQuickDetailsOnDemand", params, null, null); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } var items = result.childNodes; var resultParams = {}; var item = items.nextNode; if(!item) return null; var type = item.getAttribute('type'); resultParams.type = type; item = items.nextNode; if (type == "smartform"){ var list = []; var innerItems = item.childNodes; var innerItem; while (innerItem = innerItems.nextNode){ var value = innerItem.getAttribute('value'); if(value!=null){ value = REPLACE(unescape(value), '+', ' ') } var obj = { name: REPLACE(unescape(innerItem.getAttribute('name')), '+', ' '), label: REPLACE(unescape(innerItem.getAttribute('label')), '+', ' '), type: REPLACE(unescape(innerItem.getAttribute('type')), '+', ' '), value: value } list.push(obj); } resultParams.list = list; } else{ resultParams.text = REPLACE(unescape(item.text), '+', ' '); } return resultParams; end <@doc> get all the details on the selected result - infoshapes, ports etc. returns in the format of the standard xml Depreacted! - use retrieveComponentMetadata(...) instead the selected provider the id of the selected result the name of the selected result the system the object type the details in the standard xml format method getDetailsForItem(provider, id, name, system, objectType) if(provider == 'local_DriveC'){ // Search for local components var result = this.localGetDetailsForItem(name, objectType); return result; } var params =[]; params[0] = provider; params[1] = id; params[2] = name; params[3] = system; params[4] = objectType; var result = $ENV.channel2.executeService(this.SearchService,"getDetailsForItem", params, null, this.onFailed); if (result == null){ #LOG[4, 'Error in Search: '+$ENV.channel2.error]; return; } else if (typeof result == 'string'){ WRITE(result); return null; } return result; end <@doc> get all the details on the selected result - infoshapes, ports etc. returns in the format of the standard xml or error Discovery Parameters success status and either the details in the standard xml format(in case of success) or the error message (failure) method retrieveComponentMetadataEx(discoveryParameters) var result = this.executeMetaDataRetrieval(discoveryParameters); if (result == null){ #LOG[4, 'Error in Discovery: '+$ENV.channel2.error]; return {success:false, result:''}; } else if (typeof result == 'string') { var errMsg = "Error in Discovery: " + result; WRITE(errMsg); #LOG[4, errMsg]; return {success:false, result:result}; } return {success:true, result:result.xml}; end <@doc> get all the details on the selected result - infoshapes, ports etc. returns in the format of the standard xml or error Discovery Parameters the details in the standard xml format method retrieveComponentMetadata(discoveryParameters) var result = this.executeMetaDataRetrieval(discoveryParameters); if (result == null){ #LOG[4, 'Error in Discovery: '+$ENV.channel2.error]; return null; } else if (typeof result == 'string') { var errMsg = "Error in Discovery: " + result; WRITE(errMsg); #LOG[4, errMsg]; return null; } return result; end <@doc> returns metadata upon given search parameters Discovery Parameters the details in the standard xml format method executeMetaDataRetrieval(discoveryParameters) var provider = discoveryParameters[#[DISCOVERY_PARAMETER_PROVIDER_NAME]]; if(provider == 'local_DriveC'){ // Search for local components var name = discoveryParameters[#[DISCOVERY_PARAMETER_NODE_NAME]]; var objectType = discoveryParameters[#[DISCOVERY_PARAMETER_OBJECT_TYPE]]; var result = this.localGetDetailsForItem(name, objectType); return result; } discoveryParameters['_objectType'] = "HASHMAP"; var params =[]; params[0] = discoveryParameters; var serviceToCall = this.isSDIProvider(provider) ? this.SDIService : this.SearchService; var result = $ENV.channel2.executeService(serviceToCall,"retrieveComponentMetadata", params, null, this.onFailed); //In case of SRProvider - there will be 3 steps for trying to discover the service: //1. Using destination - if configured //2. Using No Authentication - direct call to the WSDL //3. Request for Username & password from the user //cases 1 & 2 were covered on the first calll to retrieveComponentMetadata, if the result is null, we wiil try the 3rd option using //user credentials if(provider == 'SRProvider') { if(!this.isDiscoveryFinishedOK(result)) { result = null; var counter = 0; var authenticaionDialogPath = "com.sap.vc.bcksrv:common.AuthenticationDlg.htm"; var connectionDetails = {}; connectionDetails.psName = discoveryParameters['com.sap.sbi:system']; connectionDetails.endPointURL = discoveryParameters['com.sap.sbi.vc.sr:wsdl_url']; while(counter<3) { var credentials = MODAL('Fetcher?urn='+ authenticaionDialogPath, connectionDetails, true); if(credentials != null) { discoveryParameters['com.sap.sbi.vc.sr:username'] = credentials.userName; discoveryParameters['com.sap.sbi.vc.sr:password'] = credentials.password; discoveryParameters['com.sap.sbi.vc.sr:avoid_logical'] = "true"; var params2 =[]; params2[0] = discoveryParameters; result = $ENV.channel2.executeService(serviceToCall,"retrieveComponentMetadata", params2, null, this.onFailed); } else break; if(!this.isDiscoveryFinishedOK(result)) counter++; else break; } } } return result; end <@doc> checks the return metadata if not null or error Discovery Result indicator whether ok or not method isDiscoveryFinishedOK(discoveryResult) var ret = true; if(!discoveryResult) { ret = false; } else if(typeof(discoveryResult) == 'string') { var errorCode = discoveryResult.substring(4,0); if(errorCode == "401:") //Authentication failed { ret = false; } else if(errorCode == "404:") ////URL is not valid { #LOG[4, 'Error in Discovry:WSDL URL is not valid.']; } } return ret; end <@doc> return the icon for the VC node the VC node to extract the icon from the icon string method getIconFromVCNode( item ) var iconStr = unescape(item.getAttribute('icon')); if( "" == iconStr ) { iconStr = unescape($ENV.getIconFromClass(unescape(item.getAttribute('gmlObject')))); // remove the fetcher urn from the string var i, j; if( "" != iconStr && (i = iconStr.lastIndexOf('urn=')) > 0 ) { iconStr = iconStr.substring( i + 4 ); if((j = iconStr.lastIndexOf('=')) > 0) //if there's version no. after the gif name - clean it iconStr = iconStr.substring(0, j); } } return iconStr; end <@doc> Parse LinksInfo xml the xml /* XML: */ method getProviderLinks() //var pseudoLinks=''; //var providerXml = PARSEXML(pseudoLinks); //var xml = providerXml && providerXml.getElementsByTagName("links")[0] ; //TODO: this method should be changed in order to be generic for all SearchProviders var xml = $ENV.channel2.executeService("SRComponentHelper","getLinksInformation"); var link, items, item,links=[]; if (!xml) return(links); //retreive the title - use it later in the method var title = xml.getAttribute("title") || ''; if (title) links.push({name:title,type:"TITLE"}); var currentSys='#SYS[COM_SAP_VDS_PLATFORMSPECIFIC_PROPERTIES_PLATFORM]'=='eclipse'?'service':'href'; var linksInfo = xml.getElementsByTagName("link"); for (var i=0, len=linksInfo.length;i Fires when choosing the locate in tree option in the search results context menu the provider's name the search result id to locate event onLocateInTree(provider, id); <@doc> Fires when dropping search result item the smartform object id of the connector to the server.by calling its method getDetailsForItem it is possible to get the additional metadata needed the provider's name the search object type the element id event onSearchDrop(def, dnd, connector, provider, system, objectType, id); <@doc> Fires when loading search from context menu the provider's name the search object type event onSearchLoad(provider, objectType); <@doc> Fires when dropping tree node item the smartform object id of the connector to the server.by calling its method getDetailsForItem it is possible to get the additional metadata needed the provider's name the search object type the element id event onBrowseDrop(def, dnd, connector, provider, objectType, id); <@doc> Fires when choosing search or browse provider the provider's name id of the connector to the server event onSearchLogin(provider, system, connector);