Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
72:custom_report_tipsandtricks_setting_data [2019/02/07 13:48] – created ext-bkkr72:custom_report_tipsandtricks_setting_data [2019/03/08 18:46] ext-bkkr
Line 1: Line 1:
 ====== Setting Data Source Login Credentials with XML File ====== ====== Setting Data Source Login Credentials with XML File ======
  
 +To configure the Stages Data Source credentials like server url, user name and password it is recommended to use the following XML based method.
 +
 +//Instructions//
 +
 +1. Create an XML file with the name PkitMetrics.xml with the following content:
 +
 +<code>
 +<StagesDatasource>
 + <serverUrl>http://localhost:8080</serverUrl>
 + <user>root</user>
 + <password>pass</password>
 +</StagesDatasource>
 +</code>
 +
 +2. Change the value of the serverUrl to your Stages server URL.
 +
 +3. Save the PkitMetrics.xml in the following directory: .../tomcat/webapps/pkit/WEB-INF/conf/PkitMetrics.xml
 +
 +4. Change username and password
 +
 +5. Copy the following Data Source beforeOpen script.
 +
 +<code>
 +importPackage( Packages.javax.xml.parsers);
 +importPackage( Packages.org.xml.sax);
 +importPackage( Packages.org.w3c.dom);
 +importPackage( Packages.java.io);
 +function load_document(file) {
 + factory = DocumentBuilderFactory.newInstance();
 + builder = factory.newDocumentBuilder();
 + filestream = new FileInputStream( file );
 + document = builder.parse( new InputSource( filestream ));
 + filestream.close();
 + return document;
 +}
 +function getTagValue(document, tagName) {
 +nlist = document.getElementsByTagName(tagName);
 + return nlist.item(0).getFirstChild().getNodeValue();
 +}
 +function find_config() {
 + config_list = Array("tomcat/webapps/pkit/WEB-INF/conf/PkitMetrics.xml",
 + "C:/Program Files/methodpark/projectkit/tomcat/webapps/pkit/WEBINF/conf/PkitMetrics.xml",
 + "C:/methodpark/stages/tomcat/webapps/pkit/WEB-INF/conf/
 +PkitMetrics.xml",
 + "K:/PkitMetrics.xml"
 + );
 + for (var i=0; i<config_list.length; i++)
 + {
 + conf=new File(config_list[i]);
 + if (conf.exists())
 + {
 + return conf;
 + }
 + }
 + throw "PkitMetrics.xml not found";
 +}
 +my_conf = find_config();
 +doc = load_document(my_conf);
 +this.setExtensionProperty("serverUrl",getTagValue(doc, "serverUrl"));
 +this.setExtensionProperty("user",getTagValue(doc, "user"));
 +this.setExtensionProperty("password",getTagValue(doc, "password"));
 +reportContext.setGlobalVariable("serverUrl",this.getExtensionProperty("serverUrl"));
 +</code>