COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => SDK => Topic started by: jdzurek on 06 Oct 2011 03:31:52 PM

Title: How can I get the Report Package Name?
Post by: jdzurek on 06 Oct 2011 03:31:52 PM
Is there a way to get the package being used for a given report WITHOUT parsing through the report XML Spec?

thanks!
Title: Re: How can I get the Report Package Name?
Post by: bdbits on 06 Oct 2011 05:21:31 PM
It's listed near the bottom on the general properties for the report.
Title: Re: How can I get the Report Package Name?
Post by: jdzurek on 07 Oct 2011 02:33:14 PM
Within the SDK? (java or c#)?
Title: Re: How can I get the Report Package Name?
Post by: jdzurek on 12 Oct 2011 02:04:57 PM
So this is kind of a round about way that has worked for me... i still feel like there should be a property or maybe there is and im missing it to get the package used in a given report.... this is the work around I came up with that seems to be working....(fingers crossed lol)....



        String sReportSpec = null;
        PropEnum props[] = new PropEnum[]{PropEnum.searchPath, PropEnum.defaultName, PropEnum.specification};
        SearchPathMultipleObject spMulti = new SearchPathMultipleObject();
        spMulti.set_value(this.getReportPath());

           BaseClass[] repPth = cognosConnection.getCmService().query(spMulti, props, new Sort[]{}, new QueryOptions());

            // There should be only one report with the specified searchPath
            if (repPth != null && repPth.length > 0) {
                // extract the report spec
                sReportSpec = (((Report) repPth[0]).getSpecification().getValue());
                DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = builderFactory.newDocumentBuilder();
                InputStream is = new ByteArrayInputStream(sReportSpec.getBytes("UTF-8"));
                this.xmlDoc = builder.parse(is);
            }


           if (this.xmlDoc != null) {
                XPath xpath3 = XPathFactory.newInstance().newXPath();
                String xpathExpression_Item = "/report/modelPath";
                XPathExpression expr3 = xpath3.compile(xpathExpression_Item);
                NodeList modelPathList = (NodeList) expr3.evaluate(xmlDoc, XPathConstants.NODESET);
                String innerText = modelPathList.item(0).getTextContent();
                String sub1 = innerText.substring(innerText.lastIndexOf("/package[@name='") + 16);
                int endIndex = sub1.indexOf("']");
                this.ContainingPackage = sub1.substring(0,endIndex);
            }


Title: Re: How can I get the Report Package Name?
Post by: AussiePete2011 on 12 Oct 2011 02:58:53 PM
Hi there

IBM have a solution already
http://www-01.ibm.com/support/docview.wss?uid=swg24021211

See what you think
Cheers
Peter
Title: Re: How can I get the Report Package Name?
Post by: murali999 on 07 Jun 2012 02:20:40 AM
Hi,

You can get the package name By using

(AuthoredReport)bc[0].getMetaDataModelPackage().getValue();

Title: Re: How can I get the Report Package Name?
Post by: Grim on 07 Jun 2012 09:08:16 AM
Quote from: AussiePete2011 on 12 Oct 2011 02:58:53 PM
Hi there

IBM have a solution already
http://www-01.ibm.com/support/docview.wss?uid=swg24021211

See what you think
Cheers
Peter

Some additional samples:
http://www-304.ibm.com/support/docview.wss?uid=swg21341149

http://www-304.ibm.com/support/docview.wss?uid=swg21374788