Author Topic: Tip: Retrieving a list of reports with their packages  (Read 6985 times)

Offline dew

  • Full Member
  • ***
  • Join Date: Sep 2009
  • Posts: 8
  • Forum Citizenship: +0/-0
Tip: Retrieving a list of reports with their packages
« on: 31 Jan 2011 07:57:10 am »

Hi there. 
If you want to get a list of report or report views, with the package they are based on, here is a how-to to get you started.

First query the content store for your target reports you with these PropEnum properties
 - PropEnum.defaultName,
 - PropEnum.searchPath,
 - PropEnum.metadataModelPackage

For each report returned , you want to create another query to get that specific report's package.
Use the getMetadataModelPackage() on each baseclass result
   
   AuthoredReport theReport = (AuthoredReport)results;            
   BaseClassArrayProp ob = theReport.getMetadataModelPackage();                  
   BaseClass[] bc = ob.getValue();               
   GuidProp gp = bc[0].getStoreID();
   Guid guid = gp.getValue();
   String strStoreID = guid.getValue();
   String strQuery = "storeID('" +strStoreID  +"')"

Now you can use strQuery in a new query to get the Package details.
 
   .query(new SearchPathMultipleObject(strQuery)

The StoreID uniquely identifies a content store object since cognos 8.3, so can use that directly as a query.
If you need to do this for a specific Report View, then you first need to get the authored-report of that report view, in other words, the actual report that the report view is based on.
Note that it may take a while to query the content store of you have thousands of reports ;)

Hope this helps,
Dew

Offline Aljasmi

  • Associate
  • **
  • Join Date: Feb 2011
  • Posts: 2
  • Forum Citizenship: +0/-0
Re: Tip: Retrieving a list of reports with their packages
« Reply #1 on: 23 Feb 2011 03:50:36 am »
Thank you for your kind effort

I’m trying to follow your example but  an error keep appearing to me

 the code doesn't work right so I attached it here

can you please explain to me what I did wrong.

Thanks in advance 8)

Code: [Select]

String path = request.getParameter( "path" );
if ( path == null ) {
path = "/content/folder[@name='Reports']";
}

 PropEnum propm[] = new PropEnum[]{PropEnum.defaultName,PropEnum.searchPath,PropEnum.metadataModelPackage};

BaseClass bc_obj[] = cognos.query(new SearchPathMultipleObject(path),propm,new Sort[] {},new QueryOptions());
        AuthoredReport oReport = (AuthoredReport)bc_obj[0];
        BaseClassArrayProp ob = oReport.getMetadataModelPackage();
        BaseClass[] bc_object = ob.getValue();
        GuidProp gp = bc_object[0].getStoreID();
        Guid guid = gp.getValue();
        String strStoreID = guid.getValue();
        String strQuery = "storeID('" +strStoreID  +"')";

« Last Edit: 23 Feb 2011 09:31:26 pm by Aljasmi »

Offline dew

  • Full Member
  • ***
  • Join Date: Sep 2009
  • Posts: 8
  • Forum Citizenship: +0/-0
Re: Tip: Retrieving a list of reports with their packages
« Reply #2 on: 03 Mar 2011 02:51:00 am »
Hello Aljasmi.

I think it's your SearchPath that might cause the error.  The code I provided will only work on AuthoredReport objects, and your Path will include other objects as well.

Try using:
path = "/content/folder[@name='Reports']//report"
This will select all AuthoredReport objects.
Hope it works 8)

 


       
Twittear