Domains accepting Custom Datasource as Bean

The following description is related to Bean data source. In general domains don’t accept bean as data source. To enable a custom data source for usage in a domain you can effect the following changes to the applicationContext-semanticLayer.xml.

Add below bean data source entry in metaDataFactoryFactory configuration code. metaDataFactoryFactory holds the list of data sources.

Code:

 <entry key="com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.BeanReportDataSource" value-ref="jdbcMetaDataFactory"/> 

After Editing it Looks like:

 <bean name="metaDataFactoryFactory" 
      class="com.jaspersoft.commons.semantic.metaapi.impl.MetaDataFactoryFactoryImpl">
    <property name="implementationObjectFactory" ref="mappingResourceFactory"/>
    <property name="dataSourceTypeMapping">
        <map>
            <entry key="com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JdbcReportDataSource"
                   value-ref="jdbcMetaDataFactory"/>
            <entry key="com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JndiJdbcReportDataSource"
                   value-ref="jndiJdbcMetaDataFactory"/>
            <entry key="com.jaspersoft.commons.semantic.datasource.SemanticLayerDataSource"
                   value-ref="domainMetaDataFactory"/>
            <entry key="com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.BeanReportDataSource"
                   value-ref="jdbcMetaDataFactory"/>
       </map>
    </property>

Within same file you will also need to add below class under dataSourceTreeDataProvider with in the same file.

Code:

 <value> com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.BeanReportDataSource 

After Editing it looks like:

 <bean name="dataSourceTreeDataProvider" 
      class="com.jaspersoft.commons.semantic.tree.DataSourceTreeDataProvider" 
      scope="prototype">
    <constructor-arg ref="repositoryService" />
    <constructor-arg>
        <list>
         <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JdbcReportDataSource</value>
           <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JndiJdbcReportDataSource</value>
           <value>com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.BeanReportDataSource</value>
        </list>
    </constructor-arg>

Leave a Reply