Writing the SQLMap File and Instruction Class
Adding the SQL Map
Assuming the file name is CurrewiseTransactionSqlMap.xml
<?xml version="1.0" encoding="UTF-8" ?> <sqlMap> <resultMap id="CURRENCYWISE_TXN_RESULT_MAP" class="java.util.HashMap"> <result property="TRANS_COUNT" nullValue="" column="TRANS_COUNT" javaType="java.lang.String" jdbcType="NUMBER"/> <result property="OD_TXN_CY" nullValue="" column="OD_TXN_CY" javaType="java.lang.String" jdbcType="VARCHAR"/> </resultMap> <select id="VIEW_MGR_FRMWK_MNT_SELECT_GET_CURRENCYWISE_TXN" parameterClass="java.util.HashMap" resultMap="CURRENCYWISE_TXN_RESULT_MAP"> SELECT COUNT(OD_REF_NO) AS TRANS_COUNT,OD_TXN_CY FROM OD_TXN_MASTER WHERE OD_GCIF=#INPUT_GCIF# AND OD_TXN_CY IS NOT NULL AND OD_FUNCTION_ID NOT IN ('CRSTAM','BULKUP','CRUTIL','RECUR','CNCLSI') AND OD_SUBPROD_CODE NOT IN ('BKSRNT','BKSIBT','BKSIFT','TELTRF') AND OD_HOST_STATUS='AH' GROUP BY OD_TXN_CY </select> <sqlMap>
Make an entry for the SQL Map file in the implementation database configuration file of your application. The implementation database configuration file for your application will be specified in the databaseconfig.properties file, refer Configuration Descriptor: Database for more information. For example, the Modelhouse application uses CTIMPLDatabaseConfig.xml as the implementation database configuration file. If your application is using external database other than implementation database, refer Fetching Data from a Schema Different from Implementation Schema. Sample implementation database configuration is as follows:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="databaseconfig.properties" /> <transactionManager type="EXTERNAL"> <property name="SetAutoCommitAllowed" value="false"/> <dataSource type="JNDI"> <property name="DataSource" value="${DATASOURCE_NAME}"/> </dataSource> </transactionManager> <sqlMap resource="com/intellectdesign/canvas/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/viewdefn/Default_Function_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/canvas/database/ibatis/common/maps/viewdefn/Default_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/grid/myWidgetView_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/calendar/myCalendarView_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/chart/myChartView_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/asw/Activity_Summary_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/appstore/Appstore_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/txn/PaymentTxn_SqlMap.xml" /> <!-- SQL Map file for the sample chart app. --> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/txn/CurrewiseTransactionSqlMap.xml" /> </sqlMapConfig>
Adding the Instruction Class
Assuming the file name is CurrencywiseTxnBarChartInstruction.java
package com.intellectdesign.payments.instruction; import java.util.HashMap; import java.util.List; import com.intellectdesign.canvas.entitlement.DataEntitlements; import com.intellectdesign.canvas.viewdefinition.ViewDefinition; import com.intellectdesign.canvas.viewdefinition.ViewDefinitionException; import com.intellectdesign.canvas.viewdefinition.instruction.GraphViewInstruction; public class CurrencywiseTxnBarChartInstruction extends GraphViewInstruction { /** * Return the unique sort field name for this view * * */ @Override protected String getUniqueSortFieldName() { return "OD_TXN_CY"; } /** * This method gets the sort order for the unique sort field * */ @Override protected String getUniqueSortFieldOrder() { return "ASC"; } @Override protected HashMap<String, String> getSortColumnMap() { logger.log(ENTRYLevel.ENTRY, "Inside Hashmap"); HashMap<String, String> SingSeriesBarChartColMap = new HashMap<String, String>(); listViewColumnMap.put("OD_TXN_CY", "OD_TXN_CY"); listViewColumnMap.put("TRANS_COUNT", "TRANS_COUNT"); return SingSeriesBarChartColMap; } /** * This method forms the view specific filters from the input params * */ public HashMap getViewSpecificFilters(HashMap hmInputParams, DataEntitlements dataEntitlements) throws ViewDefinitionException { HashMap mapViewSpecificFilter = null; return mapViewSpecificFilter; } @Override protected HashMap processResponse(List listViewData, ViewDefinition viewDefinition, HashMap mapInputParams) throws ViewDefinitionException { return super.processResponse(listViewData, viewDefinition, mapInputParams); } }