Mashup Service
Cognos Mashup Service(CMS), IBM Cognos Yazılım Geliştirme Kit'inin parçası olarak gelen yeni bir web servistir. Bu dökümantasyon, CMS tanıtımını ve REST ve SOAP interface'leri arasındaki farkları açıklamak üzere yazılmıştır. Bu dökümantasyon ile örnek kodlardan CMS ile neler yapabiliceğimizden bazılarını göreceğiz ve Cognos Mashup Servis yüklenmesi ile gelen bazı örnek kodlar üzerinde durulacaktır. Bu dökümantasyondan en iyi şekilde faydalanmak için, temel seviyede IBM Cognos BI , programlama dillerini anlama ve Web Teknolojileri bilgisi gerekir.CMS ile Neler Yapılabilir
IBM Cognos Mashup Servis, Cognos Raporları diğer uygulamalara entegre etmek için size bir yol sunar. Bu entegreyi gerçekleştirmek için aşağıdaki iki interface de kullanabilir.- Representational State Transfer (REST): Bu interface temel HTTP istekleri için kullanılır.
- Simple Object Access Protocol (SOAP): Bu interface, CMS API'sine erişmek için programlı olarak kullanılabilir.
Aşağıdaki örnek, tamamlanmış bir CMS entegresini gösterir. Şekil 1.1 de, IBM Cognos Report Studio'dan örnek bir raporun bir kısmı gösterilmiş. Rapor, hayali bir şirketin satış gelir verilerini içerir. Veri, her bir şirket ofisinin konumuna göre bölünmüş. Şekil 1.2 ise Raporun, Google Earth map ile entegre edildiğindeki sonuçları gösteriyor. Her bir ofisin satış rakamları, ofisin konumuna göre harita üzerinde yerleştirilmiş. Bu, CMS REST interface ile birlikte Google Maps API kullanılarak gerçekleştirilmiştir.
HTML formatında örnek bir IBM Cognos rapor sonuçları
IBM Cognos Mashup Servis kullanılarak Google Earth üzerine yerleştirilmiş IBM Cognos rapor sonuçları
CMS Kullanımı
Bu bölümdeki örnekler, Cognos raporunda farklı component'leri çıkarmak için REST ve SOAP interface'lerinin nasıl kullanılacağı örneklendirilecekREST Interface
REST istekleri için url üretimi:
http://webservername:portnumber/cognos8/cgi-bin/cognos.cgi/rds/resource
\_type/source\_type/source\_id?option1=val1\&option2=val2...
REST API'nin ana yapı elemanları aşağıda gösterilmiştir.
REST API Örnek 1
İlk REST API örneği, List ve Chart'ı bir arada içeren mevcut bir raporda tüm chart'ları nasıl alınacağını gösterir. Örnek, Rapordan Tüm chart'ları Layout Data XML (LDX) formatında gönderir\\Örnek için url oluşturulduğunda aşağıdaki parametreler kullanılır.
- Resource type:reportData
- Source type: report
- Resource_id:report store id; Örnek olarak, iE0CDFEF149F8408F96F1C27DCFFA6BCB
- Options: fmt=layoutDataXML, xpath=//chart
Url aşağıdaki gibi görünür
http://localhost/c841/cgi-bin/cognos.cgi/rds/reportData/report/\\
iE0CDFEF149F8408F96F1C27DCFFA6BCB?fmt=layoutDataXML\&xpath=//chart
REST isteğinden dönen LDX,caption=REST isteğinden dönen LDX
<filterResultSet xmlns="http://www.ibm.com/xmlns/prod/cognos/
layoutData/200904">
<filterResult>
<filterType>XPATH</filterType>
<filterValue>//chart</filterValue>
<reportElement>
<chart>
<palette>
<paletteItem>
<pattern>
<type>ePatternSolid</type>
<fgColor>
<red>51</red>
<green>51</green>
.
.
.
</reportElement>
</filterResult>
</filterResultSet>
\end{lstlisting}
REST API Örnek 2:
Bu örnek, ilk örnekteki gibi aynı rapordan veriye erişir. HTML bölümü olarak rapordan tek bir chart döndürürÖrnek için url oluşturulduğunda aşağıdaki parametreler kullanılır.
- Resource type:reportData
- Source type: report
- Resource_id: report store id; Örnek olarak, iE0CDFEF149F8408F96F1C27DCFFA6BCB
- Options:fmt=HTMLFragment, selection=Chart1
Url aşağıdaki gibi görünür
http://localhost/c841/cgi-bin/cognos.cgi/rds/reportData/report/\\
iE0CDFEF149F8408F96F1C27DCFFA6BCB?fmt=HTMLFragment\&selection=Chart1
IBM Cognos Mashup Servis'den Üretilen Chart
REST API Örnek 3
Bu örnek, her bir sayfa üzerine döndürülen verinin maksimum 3 satırını html formatında nasıl çalıştırıldığını gösterir.Örnek için url oluşturulduğunda aşağıdaki parametreler kullanılır.
- Resource type:reportData
- Source type: report
- Resource_id: report store id; Örnek olarak, i6243D3E1A36A4E0FAF9D90652C171FC2
- Options: fmt=HTML, selection=List1, rowLimit=3
Url aşağıdaki gibi görünür
http://localhost/c841/cgi-bin/cognos.cgi/rds/reportData/report/
i6243D3E1A36A4E0FAF9D90652C171FC2?fmt=HTML&selection=List1&rowLimit=3
IBM Cognos Mashup Servis'i kullanılarak HTML formatında sınırlı çıkışlar elde etmek
SOAP Interface
Şekil 1.6 SOAP API Interface'in bir kaç generic methodunu gösterir.SOAP Methotları}
SOAP API Örnek 1:
Bu örnek, liste ve grafik içeren bir rapordan, tüm rapor elementlerine erişim sağlayan bir listenin nasıl çıkarılacağını gösterir.Örnek Java Kodu
ReportDataServicePortProxy proxy=new ReportDataServicePortProxy();
//The endpoint will be the gateway URL for your server
proxy.setEndpoint(url);
ReportDataServicePort mashupService=
proxy.getReportDataServicePort();
GetReportDataRequest request = new GetReportDataRequest();
//This sets the cm searchPath as the source of the report, you
//could alternatively use the storeId
request.setSourceID("/content/folder[@name='Samples']
/package[@name='GO Data Warehouse (analysis)']/folder[@name=
'Query Studio
Report Samples']/query[@name='Returns by Product Type']");
//This identifies that the sourceID refers to a CM search path
request.setSourceType(SourceTypeEnum.searchPath);
//This creates an object id filter to only return the
List1 element, OBJECT_ID is the type of filter that
//filters based on element id.
Filter[] filters = {new Filter("List1",
FilterTypeEnum.OBJECT_ID, null)};
request.setFilters(filters);
GetOutputResponse response = mashupService.getReportData(request);
GetOutputRequest outputRequest = new GetOutputRequest();
/*
* This loop is necessary when running asynchronously
*/
while(response.getSession().getStatus()
== SessionTypeStatus.working)
{
outputRequest.setSession(response.getSession());
response = mashupService.getOutput(outputRequest);
}
/*
* This block of code goes through the list
contents and outputs them to the console
*/
ListFrame list1 = response.getOutput().getLDXOutput()
.getFilterResultSet().getFilterResult()[0]
.getReportElement()[0].getLst();
Row[] rows = list1.getGroup().getRow();
System.out.println();
System.out.print("Product type");
int spaceOfCell=25-("Product type".length());
for (int n=0;n<spaceOfCell;n++)
{ System.out.print(" ");}
System.out.print("Base product");
spaceOfCell=35-("Base product".length());
for (int n=0;n<spaceOfCell;n++)
{ System.out.print(" ");}
System.out.print("Lost revenue");
spaceOfCell=20-("Lost revenue".length());
for (int n=0;n<spaceOfCell;n++)
{ System.out.print(" ");}
System.out.println();
System.out.println();
for(int i = 0; i < rows.length; i++)
{
Cell[] cells = rows[i].getCell();
System.out.print(cells[0].getItem(0).getTxt().
getFmtVal());
spaceOfCell=25-(cells[0].getItem(0).getTxt().
getFmtVal().length());
for(int j=0;j<spaceOfCell;j++)
{ System.out.print(" ");}
System.out.print(cells[1].getItem(0).
getTxt().
getFmtVal());
spaceOfCell=35-cells[1].getItem(0).getTxt().
getFmtVal().length();
for(int j=0;j<spaceOfCell;j++)
{ System.out.print(" ");}
System.out.print(cells[5].
getItem(0).getTxt().
getFmtVal());
spaceOfCell=20-cells[5].getItem(0).getTxt().
getFmtVal().length();
for(int j=0;j<spaceOfCell;j++)
{ System.out.print(" ");}
System.out.println();
}
Aşağıdaki şekil, yukardaki örnek koddan üretilen çıkışların nasıl olacağını gösterir.
0 yorum:
Yorum Gönder