Posts Tagged Cognos SDK
An Introduction to the Cognos SDK, Part 4 – Cognos 8 Extended Applications and Conclusion
Posted by Peter Beck in Business Intelligence, Cognos on August 11, 2010
In this final entry in our series on the SDK we’ll touch on Cognos Extended Applications, a set of JSP tags that enable the development of custom “portlets” that can be hosted by a number of “portal” applications, including IBM’s Websphere portal and SAP’s Enterprise Portal (as well as Cognos Connection, of course.)
JSP technology includes the ability to create custom tags that contain back-end code. Just as a set of tags like <a> </a> means something specific to the browser, and <%> </%> are used to demarcate code that will be executed on the server side (but is contained within the JSP page) the user can create tags of their own that will call code when the page is rendered but exists in a java class the user has created.
The Cognos SDK includes several tags libraries that can be used to create JSP pages that can then be registered with a portal. Once again, these libraries enable the user to essentially perform any task that can be performed through the normal interface, but extended or combined as the user wants. Once registered the JSP portlet will be available to users of the existing corporate portal. The details of registering a JSP page with the portal vary with the portal being used.
The Extended Applications approach is ideal for the development of content you want to present within an existing portal, but it is complex, and requires the use of the JSP portion of the J2EE stack.
The C8 SDK is a powerful tool for organizations that want to extend the power of Cognos 8 within the enterprise, and provides a number of tools to do so. The BI Bus API provides a set of classes that can be used to build applications that interact with C8 “from the ground up”. The URL API provides an easy, ‘lightweight” way of calling methods to interact with C8 via a correctly formatted URL, or from JavaScript within a client. Finally, Extended Applications provides a set of custom JSP tags within libraries that can be used to create JSP pages that can then be registered as portlets within an enterprise portal.
An Introduction to the Cognos SDK, Part 3 – The Cognos 8 URL API
Posted by Peter Beck in Business Intelligence, Cognos on July 23, 2010
In the previous entry in this series we took a brief look at the BI Bus API, a collection of classes (either in .NET or Java) or a legacy VB6 .dll that can be used to perform actions against Cognos 8 – tasks as varied as changing attributes of C8 content, running reports, changing security settings, etc. Essentially any task that can be performed through the Cognos 8 interface can be executed through calls to the correct part of the BI Bus API.
Another way of performing tasks is to interact with the Cognos dispatchers through calls to the Cognos gateway – the URL API. You can format an execute a call using a specially formatted URL passed over HTTP/HTTPS. Tasks that can be performed this way include starting Cognos components, and executing tasks such as running a report.
As an example, starting Report Studio can be accomplished by calling the following URL:
http://localhost/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/launch.xts&ui.gateway=http://localhost/cognos8/cgi-bin/cognos.cgi&ui.tool=ReportStudio&ui.action=new
(In this example you would of course need to pass the correct dispactcher/gateway urls, which are not likely to be “localhost” except on a demo machine.)
Including the parameter &ui.object can be used to open a specific report:
http://localhost/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/launch.xts&ui.gateway=http://localhost/cognos8/cgi-bin/cognos.cgi&ui.tool=ReportStudio&ui.object=[PATH]
…Where PATH above is the path to the report. This can be found most easily by examining the properties of the report within Cognos Connection.
Special JavaScript methods can also be embedded in a web page and called to open Cognos 8 content, either in an existing or new window. Use of these methods requires the inclusion of the path to a JavaScript library “cognoslaunch.js” within <script> tags of the header of the page.
<script language=”JavaScript” src=”Cognos8Gateway/cognoslaunch.js”>
</script>
Calls that can be made with a URL can also be called using the JavaScript cognosLaunch method. For example, to open Report Studio, the following call can be made in JavaScript.
cognosLaunch(“ui.gateway”,”gateway”,”ui.tool”,”ReportStudio”)
Using the URL API is useful to embed Cognos studios or content within a browser window or frame in a non-Cognos application. The syntax of the URL API is well documented within the API documentation. As with the BI Bus API the range of actions that can be performed is quite extensive, mirroring what can be called through the regular UI. The URL API can be thought of as a light-weight way to accomplish certain tasks or easily embed content within a web application other than the regular portal. Cognos suggests that for more complex tasks the BI Bus API be used.
An Introduction to the Cognos SDK, Part 2 – The BI Bus API
Posted by Peter Beck in Cognos on July 17, 2010
The following is the latest installment of “Cognos Tips” with Peter Beck:
The portion of the Cognos SDK probably of greatest interest to developers is the BI Bus API. This API (available in VB6, .NET and Java flavours) enables the developer to write code to perform virtually every task that can be performed through the normal UI. This means that the developer can use the API to do everything from automate administrative tasks to embed calls to Cognos 8 functionality in another application.
In .NET there are 2 main dlls that must be referenced by the developers code: cognosdotnetassembly_2_0.dll and cognosdotnet_2_0.dll (there are previous versions, cognosdotnet.dll and cognosdotnetassembly.dll provided as well, but these are meant for use with the 1.1 version of the .NET framework – by now you are probably on version 3 or even 4 of the framework). In Java a number of the JAR files must be referenced (they are in the sdk\lib folder.)
(The single VB6 dll is cdk.dll, although by now you are probably making use of .NET if you are in a Microsoft environment.)
Once these are added to your development environment you will have access to a variety of methods that enable your application to log into and manipulate the Cognos environment. Your application can traverse the Cognos Content Store to retrieve lists of reports (and other objects), get metadata about them, execute reports, delete or move them – virtually any Cognos operation, including operations on Users and Groups.
As an example, we will look at a class that is at the heart of the API – the Cognos “baseClass”, an abstract class that represents an object in the Content Store. This object can be a directory, a report, a report view, and many other object types. Once a reference to the object is obtained, the object can be executed, deleted, changed in some way – whatever the methods or properties available to the specific type of object.
For example, your code could retrieve a reference to all reports with a certain pattern in the name, and then you could delete all these reports, or alternatively move them to a particular folder.
So how do you get a reference to the object? First, you need to log in to the C8 Content Manager Service, for which there is a handy class available:
contentManagerService1 c8serv = new contentManagerService1();
c8serv.Url = c8url;
.
.
.
c8serv.logon(c8xmlEncodedCredentials, null);
First, we create a new contentManagerService1, and provide the URL of the service. We build an XML-encoded string of user credentials (not shown). Finally, we call the logon method of the contentManagerService instance, passing it the credentials and an optional value for an array of paths to user roles.
Now that we’ve logged on, we can query the Content Store. Think of it as querying a database, but in this case you use a Cognos-specific query method called “query” that is a method of the contentManagerService1 created above. This will return an array of baseClass objects that can then be manipulated:
cognosdotnet_2_0.baseClass[] bc;
.
.
.
bc = c8serv.query(sPath, props, sortOptionArray, qOpts );
(We’ve left out a lot of the specifics in this example, but the parameters that are passed to the query method determine what is returned, based on the “path” given (sPath above) and the “properties” that are requested (props above))
Now we have an array of base class objects. The base class is an abstract class that represents a generic type of object in the C8 content store. The “path” above determines specifically what objects the content manager will return – for example, all object in the content store, or only report objects, or all objects in a certain hierarchy, or whatever the developer wants – it is all determined by the “path” supplied to the query. The formatting of this parameter is complex, and it occupies a large section of the SDK documentation.
Once we have an array of base class objects, we can iterate through it, inspecting and/or setting properties, or calling whatever methods are available – moving objects, changing some aspect of them, etc.
These operations aren’t simple, and operations such as executing a report may require interacting with a number of different services (the content manager service is just one available service of several, including the report service, monitor service etc.) The good news is the SDK provides a consistent, highly-typed way of performing these kinds of tasks.
In the next entry in this series we will take a look at some of the URL commands that are available that enable the user to perform tasks on the server simply by passing it the appropriate parameterized URL.
An Introduction to the Cognos SDK
Posted by Peter Beck in Cognos on July 8, 2010
The following is the latest installment of “Cognos Tips” with Peter Beck:
Most Cognos BI developers (i.e. folks who spend their days using the tools provided by Cognos to deliver BI) are aware of the Cognos 8 Software Development Kit. In practice not many make direct use of it, and probably for good reason. First, skills with the Cognos toolset don’t translate directly into software development the skills required to utilize the SDK – skills with Report Studio or Framework Manager are not the same as java or .NET development skills. The SDK is also expensive, and is typically licensed only to large shops that have special needs and can justify the cost. The existing Cognos BI tools are pretty robust, so many shops think that extending them or creating new functionality using the SDK is not worth the effort.
But what is the SDK? Essentially it is a set of APIs that allow the developer to call the Cognos 8 service without having to go through the normal “front end” portal. For some functions these calls can be made through xml-encoded calls to URLs (the “URL API”). For others, a set of Microsoft .dll and Java .jar files are available the enable calls to the “BI Bus API” from either MS .Net languages (C#, VB .NET) or from Java.
(A .dll is also available to enable calls from “old” Visual Basic (i.e. VB 6) but if you are new to the SDK you should probably start with either .NET or Java – the VB 6 .dll will eventually be dropped, and both .NET or Java provide a much better programming “paradigm”.)
What can you do with the SDK? Anything you can do through the portal, with the advantage that you can do it programmatically. Cognos explicitly states in their documentation:
“Virtually everything you can do with the Cognos 8 graphical user interface, you can do using the appropriate API, XML file, or command line utility.”
This tells us that what most users think of as “Cognos 8”, i.e. the experience of using the tools through the web interface, is in fact a “front end” for the API.
(A separate SDK is available for Framework Manager, which is outside the scope of this series)
But by making the experience of the Cognos 8 interface programmable through the SDK, some interesting and useful extensions to Cognos 8 become possible.
For example, within the portal it is possible to select a user from your authentication source, some aspect of the users profile, and apply it to another user. Doing this for many users could be onerous, but automating the process by writing a small utility that selects a source profile and applies it a number of specified destination users could be quite useful in some environments.
You could create a utility to check for some condition in the data warehouse, and enable or disable reports based on that condition (for example, if the data warehouse builds are delayed, you don’t want users running reports that may not be complete).
You could embed Cognos reports within your own application – for example, include a Cognos-based graph within an operational screen in a transactional system.
Some firms, such as Motio, have used the SDK to create powerful custom applications for Cognos 8 users, essentially becoming experts in extending Cognos 8 within the enterprise, and providing additional applications to help Cognos 8 shops manage their environments.
In the next installment we’ll do a brief review of the BI Bus API portion of the SDK.
