How can I set the data adapter when running a report via the rest 2 API - jasper-reports

I am using Jasper Server 6.3 Community Edition. I have a set of reports that I want to be able to execute against different databases. I have a data adapter defined for each database. I want to be able to execute any of these reports via the rest 2 API and just tell it to use a different data adapter.
The piece of XML that is pertinent to this setting in the jrxml is:
<property name="net.sf.jasperreports.data.adapter" value="common\test.xml"/>
The ideal situation would be, to be able to pass any value I want to replace common\test.xml
From what I can tell though, there is no built in parameter to set the data adapter, and one cannot use a parameter to set this either. In other words this won't work:
<property name="net.sf.jasperreports.data.adapter" value="$P!{data_adapter_path}"/>
So how can the net.sf.jasperreports.data.adapter value be set dynamically using the rest 2 API?

The easiest solution would be to upgrade to at least JasperReports Server 6.4.0 where you could use a propertyExpression instead of property, like so (I am posting only the relevant fragment):
<propertyExpression name="net.sf.jasperreports.data.adapter"><![CDATA[$P{DataAdapterLocation}]]></propertyExpression>
<parameter name="DataAdapterLocation" class="java.lang.String" evaluationTime="Early">
<defaultValueExpression><![CDATA["default/path/to/DataAdapterFile"]]></defaultValueExpression>
</parameter>
The evaluationTime="Early" on the parameter is essential for this to work.
Another but complex solution, that would not require an upgrade, would involve creating JDBC Data Sources(via interface or REST API) and assigning them to the appropriate Report Unit. This post shows how you could achieve that by using the jrs-rest-java-client .

Related

How to query domain in jaspersoft with Dynamic Parameters

I am new to jaspersoft reporting. I am currently designing and developing reports by considering following requirements.
I want to create template based reports where all dynamic parameters I need to pass in SQL query.
I was going through japsersoft reporting I found that we can create join views and cache data by creating domains. So that it reduces hits at db level.
While creating report I found that I cant execute SQL script on Domain objects.
Please advice whether I am on right track or not.
Basically I want to query on cached data such as domain view instead of hitting DB directly.
Please suggest if any workaround is available for this problem.
Please note, although JasperReports Server manages a cache for Ad Hoc Views and Ad Hoc Reports running on Domains, running a JRXML report (e.g. designed in Jaspersoft Studio) on a Domain does not guarantee hitting that cache.
You also have the option of using a layer that provides caching between JasperReports Server and your database. For example, support has been recently added for TIBCO Data Virtualization (not a free product) in v.7, see https://www.jaspersoft.com/introducing-jaspersoft-7.
In any case, Domains are not relational databases and therefore do not support straight SQL.
You can use the "Domain query language" though, which offers a subset of the features of SQL. The easiest way to write a query is using Jaspersoft Studio and selecting "domain" in the Language dropdown (top-left corner of the Dataset and Query Dialog, indicated by the red arrow in the screenshot below from Studio 6.4.0):
For example the design above (which uses the Supermart Domain, provided with the sample data) will generate this query and the required "dynamic" parameter as you requested – in this case a Collection as the filter is 'Is One Of' which can take multiple values:
<query>
<queryFields>
<queryField id="sales_fact_ALL.sales__product.sales__product__product_name"/>
<queryField id="sales_fact_ALL.sales_fact_ALL__store_sales_2013"/>
</queryFields>
<queryFilterString>sales_fact_ALL.sales__store.sales__store__region.sales__store__region__sales_country in sales__store__region__sales_country_0</queryFilterString>
</query>
See here for another example of a query (current version of docs based on 7.1.0 release), in this case for use with the REST API: https://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v710/queryexecutor-service
The queryFilterString tag follows the DomEL syntax as documented here (also for 7.1.0): https://community.jaspersoft.com/documentation/tibco-jasperreports-server-user-guide/v71/domel-syntax

Get all the reports which have used a specific resource id of a domain topic in jasper

I have created a topic using a Domain in my JasperReport Server. Now I need to get all the reports which have used that Domain or Topic by using REST API.
I have tried this REST call:
https://<host>/jasperserver-pro/rest_v2/resource/organizations/test/organizations/data/Reports?j_username=jasperadmin&j_password=jAspErAdmIn
It gives 200 OK. But no data, it only gives the login page source.
<title>TIBCO Jaspersoft: Login</title>
Can anyone tell me how how to get this from REST call?
First, your call to the API seems errorneous.
According to the docs the call to the repository service looks like this:
http://<host>:<port>/jasperserver[-pro]/rest_v2/resources?<parameters>
In your case this would be:
http://<host>/jasperserver-pro/rest_v2/resources?<parameters>
Sencond, since your call is different, you won't get any result. It is possible to search for a specific string:
http://<host>/jasperserver-pro/rest_v2/resources?q=Domain_Name
and / or a type:
http://<host>/jasperserver-pro/rest_v2/resources?q=Domain_Name&type=dataType
As far as I understand it, it is not possible to search which report use which resources, though.

Databean to fetch CATENTDESCOVR

I need to fetch data of CATENTDESCOVR using Databean.
Is there any databean provided by IBM to get the data?
I am using IBM WebSphere Commerce V7.0 Feature Pack 8
this is good question and here below is the explanation how CATENTDESCOVR works , this answer is based on WCS 7.0 , FEP 7 . but I believe fep 8 have same api , i don't think IBM enhanced this in fep8!
the information of CATENTDESCOVR are indexed and stored in solr, BUT the reason for indexing is just for searching and spellcheck, you can see how we are copying these info to defultSearch and spellCheck to make these values searchable and to be part of spellcheck (end of schema.xml).
if you look at how these data are indexed and stored in solr in schema.xml you will find following line
<!--
Catentry's description override: map to table CATENTDESCOVR
-->
<field name="nameOverride" type="wc_text" indexed="true" stored="true" multiValued="true"/>
<field name="shortDescriptionOverride" type="wc_text" indexed="true" stored="true" multiValued="true"/>
<field name="keywordOverride" type="wc_text" indexed="true" stored="true" multiValued="true"/>
please note here the multiValued="true" , this means that if you have multible stores belongs to same Esite , the solr index the nameOvr , descOvr as multivalued for that catentryId , but solr have no idea which overridden name belongs to which store , that bean said , IBM solr index the master catalog data not store specific data .
this brings the question how the overridden name is shown per store in store front?
the answer is by utilizing WC-Search post-processor:
com.ibm.commerce.foundation.server.services.rest.search.postprocessor.solr.SolrRESTSearchCatalogEntryViewDescriptionQueryPostprocessor
if you look at the implementation of this postprocessor you will find the following high level steps :
1- get the catOvrGrpId by:
catOvrGrpId = CatalogOverrideHelper.getOverrideGroupIdForStore(this.iStoreId)
2- get the required overridden data by calling the DSL service:
JDBCQueryService service = new JDBCQueryService("com.ibm.commerce.catalog");
queryParameters.put("language", langIds);
queryParameters.put("UniqueID", catEntryUniqueIDs);
queryParameters.put("catOverrideGroupID", groupIds);
service.executeQuery("IBM_Get_CatentryDescOverride_By_LangId_And_CatentryId_And_GroupId",
queryParameters);
3- convert the array list returned to JSON compatible result:
populateOverrideCatalogEntries((List)listOfPhysicalObjects, catalogEntryViews);
you can reused the codes above and try to de-compile SolrRESTSearchCatalogEntryViewDescriptionQueryPostprocessor to understand how you can read these information from database.
the query for IBM_Get_CatentryDescOverride_By_LangId_And_CatentryId_And_GroupId is exist under Search/xml/config/com.ibm.commerce.catalog/wc-query-utilities.tpl
Hope this will be informative for you.
Thanks
Abed
The short answer is that there isn't a DataBean for accessing this data.
The [beginning of the] long answer is that you need to use the BOD+DSL layers in order to access such data.
Either through JSP using the getData tag (Aurora uses this tag extensively) or using Java code (sometimes using XPath expressions...).
You can also trace the query: see here.
However, to my understanding, the idea of overrides is that they are transparent to the front-end. I.e. the description overrides are replacing the main descriptions when they are set-up. see here
Not sure what you're trying to do with accessing this data directly. Override WCS logic?
The CATENTDESCOVR will already have been indexed in your solr core.
Look in solr\home\MC_10001\en_US\CatalogEntry\conf, for in the wc-data-config.xml, and you can see it being mapped into the core.
When you request data from solr, one of the Post processing filters defined in the wc-search.xml of the Search EAR project will fill in the override value as the "name" or "shortdesc" of the returned values.
So, you really only need to call the rest service as normal to get this value. Provided ofcourse you are wanting it from the frontend.
If you need it backend, you can use the CatalogEntryFacadeClient to perform the solr query.

Workarounds for adding new fields to existing output data type in SOAP

According to this article about backwards compatibility in SOAP by IBM they state that new fields can not be added to output types without breaking the contract. The relevant snip from the page is from the section titled New, optional fields in an existing data type...
You can add an element to an existing complexType as long as you make it optional (using the minOccurs="0" attribute). But be careful. Adding an optional element is a minor change only if its enclosing complexType is received as input to the new service. The new service cannot return a complexType with new fields. If an old client were to receive the new field, the client deserialization would fail because the client would not know about the new field.
This was written in 2004 for the WSDL 1.1 spec. Is this still true under current under the WSDL 1.2 spec? Is there no way to define a default behavior of "ignore" for new unknown fields? This statement also seems implementation specific or is that per the spec?
I am trying to contend with the issue of evolving a SOAP service that returns complex business objects. New fields will be added as consumers find use cases for them. I would like to avoid having keep N versions of the service around for simply adding new fields.
From my personal experience this is still the case. I think your main concern is the versioning methodology. You can look at: http://www.ibm.com/developerworks/webservices/library/ws-version/, or more close to home Web Services API Versioning.

Set the reference from a report to its Data Source using SOAP?

I am writing a script for RS.EXE tool to deploy reports onto a server running Microsoft SQL Reporting Services 2008 R2. Using the Mgmt2010 SOAP endpoint, I am able to upload the reports (rdl files) just fine, but they need a bit of additional help in order to be able to find the shared Data Sources that are on the server.
How can I use the SOAP service to properly configure the data source references associated with a report after I have uploaded it?
Thanks in advance...
Create a DataSourceReference object and set its Reference property to the path to the shared data source.
Create a DataSource object. Set the Name property to the name of the shared dataset as known by the report. This might be different than the file name of the shared data source. Set the Item property to the DataSourceReference object created above.
Finally, call SetItemDataSources with the path to the report and the DataSource object.