Hi Greiff
I am getting an error message "Can't convert Opened to class java.lang.String at org.apache.commons.jelly.tags.core.ArgTag.conver." after implemented the below logic.
<core:new var="ExcelDateNumeric" className="java.lang.Integer">
<core:arg type="java.lang.String" value="${creation_dt}" />
</core:new>
Can you please advice how can I fix the problem in the code?
Excel:
Number | State | Opened |
INC_0190526 | Resolved | 21/09/2018 04:02:43 |
INC_0190531 | Resolved | 21/09/2018 05:54:14 |
INC_0190535 | Resolved | 21/09/2018 07:31:13 |
INC_0190540 | Closed | 21/09/2018 07:57:37 |
Code:
<gel:script
xmlns:core="jelly:core"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="jelly:sql"
xmlns:util="jelly:util"
xmlns:xog="http://www.niku.com/xog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<gel:setDataSource dbId="niku"/>
<gel:parameter default="C:\Temp" var="P_INCIDENT_TEMP_PATH"/>
<core:set value = "${P_INCIDENT_TEMP_PATH}\test.xls" var = "SourceFile"/>
<!--Input File Start-->
<core:catch var = "fileExp">
<core:new className = "java.io.File" var = "varFileInstance">
<core:arg type = "java.lang.String" value = "${SourceFile}"/>
</core:new>
</core:catch>
<core:if test = "${fileExp!=null}">
<gel:log>Encountered File exception: ${fileExp}</gel:log>
</core:if>
<!--Read Inputstream of the File-->
<core:catch var = "FISExp">
<core:new className = "java.io.FileInputStream" var = "varFileisInstance">
<core:arg type = "java.io.File" value = "${varFileInstance}"/>
</core:new>
</core:catch>
<core:if test = "${FISExp!=null}">
<gel:log>Encountered exception in Inputstream: ${FISExp}</gel:log>
</core:if>
<!--Representation of a Input Spreadsheet workbook -->
<core:catch var = "xssfexp">
<core:new className = "org.apache.poi.hssf.usermodel.HSSFWorkbook" var = "varxssfwb">
<core:arg type = "java.io.FileInputStream" value = "${varFileisInstance}"/>
</core:new>
</core:catch>
<core:if test = "${xssfexp!=null}">
<gel:log>Encountered exception in workbook: ${xssfexp}</gel:log>
</core:if>
<!--Input file read end-->
<!--Output File Start-->
<!--To get First row in Input file-->
<core:invoke method = "getSheetAt" on = "${varxssfwb}" var = "varSheet">
<core:arg type = "java.lang.Integer" value = "0"/>
</core:invoke>
<core:set value = "${varSheet.getPhysicalNumberOfRows()}" var = "rowCount"/>
<gel:log>Number of Rows in Sheet: ${rowCount}</gel:log>
<file:writeFile embedded="false" fileName="${P_INCIDENT_TEMP_PATH}/load_incidents_insert.csv" delimiter="|">
<file:line>
<file:column value="incident_no"/>
<file:column value="status"/>
<file:column value="creation_dt"/>
</file:line>
<!-- FILE DATA LOOP Start -->
<core:while test = "${j < rowCount}">
<!--Read 'j'th row in the input file-->
<core:invoke method = "getRow" on = "${varSheet}" var = "cur_row">
<core:arg type = "java.lang.Integer" value = "${j}"/>
</core:invoke>
<core:if test = "${cur_row!=null}">
<!--Read 1st Cell-->
<core:invoke method = "getCell" on = "${cur_row}" var = "incident_no">
<core:arg type = "java.lang.Integer" value = "${0}"/>
</core:invoke>
<!--Read 2nd Cell-->
<core:invoke method = "getCell" on = "${cur_row}" var = "status">
<core:arg type = "java.lang.Integer" value = "${1}"/>
</core:invoke>
<!--Read 3rd Cell-->
<core:invoke method = "getCell" on = "${cur_row}" var = "creation_dt">
<core:arg type = "java.lang.Integer" value = "${2}"/>
</core:invoke>
<core:set value="${incident_no.toString().trim().replaceAll('\n', ' ').replaceAll('\r', ' ').replaceAll('\x27', '').replaceAll(',', ' ')}" var="incident_no"/>
<core:set value="${status.toString().trim().replaceAll('\n', ' ').replaceAll('\r', ' ').replaceAll('\x27', '').replaceAll(',', ' ')}" var="status"/>
<!--
<core:set value="${creation_dt.toString().trim().replaceAll('\n', ' ').replaceAll('\r', ' ').replaceAll('\x27', '').replaceAll(',', ' ')}" var="creation_dt"/>
-->
<core:new var="ExcelDateNumeric" className="java.lang.Integer"> <!-- Excel int for 30-Aug-2018 -->
<core:arg type="java.lang.String" value="${creation_dt}" />
</core:new>
<gel:log>Creation Date: ${creation_dt}</gel:log>
<core:if test = "${j != 0}">
<gel:log>Row_NUM: ${j}, Incident: ${incident_no}, Creation Date: ${creation_dt}</gel:log>
<file:line>
<core:choose>
<core:when test="${incident_no == null}">
<file:column value=""/>
</core:when>
<core:otherwise>
<file:column value="${incident_no}"/>
</core:otherwise>
</core:choose>
<core:choose>
<core:when test="${status == null}">
<file:column value=""/>
</core:when>
<core:otherwise>
<file:column value="${status}"/>
</core:otherwise>
</core:choose>
<core:choose>
<core:when test="${creation_dt == null}">
<file:column value=""/>
</core:when>
<core:otherwise>
<file:column value="${creation_dt}"/>
</core:otherwise>
</core:choose>
</file:line>
</core:if>
</core:if>
<core:set value="${j+1}" var="j"/>
</core:while>
<!-- FILE DATA LOOP END -->
</file:writeFile>
</gel:script>
Thanks
Senthil