AnsweredAssumed Answered

Date format xog problem

Question asked by otahri on May 29, 2013
Latest reply on Jun 3, 2013 by otahri
Hi all,
i'm trying to update and add rows to a matrix in clarity from a csv file using xog
the problem that the csv file input contains dates in this format : 'dd/MM/yyyy" and when i import and send the xog to Clarity, i have an error of date format, (' todate' and 'fromdate' ) because the allowed format is 'yyyy-MM-dd'
how can i proceed to resolve this problem?
bellow my script code:

<gel:script xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:core="jelly:core" xmlns:em="jelly:email"
    xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
    xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
    xmlns:j="jelly:core"
    xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sql="jelly:sql" xmlns:util="jelly:util" xmlns:x="jelly:xml"
    xmlns:xog="http://www.niku.com/xog"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<!-- Utilisateur admin -->




<gel:parameter var="loginClarity" default="admin"/>




<gel:parameter var="passClarity" default="clarity" secure="true"/>



<!-- Serveur Clarity  -->




<gel:parameter var="hostClarity" default="http://clarity1211-oracle112" />

<!--

<core:set value="localhost" var="hostClarity"/>

-->




<!-- ** Connexion au serveur Clarity ** -->



<!--gel:log category="XOG" level="info" message="[-] connecting to ${hostClarity}..."/-->



<gel:out>[-] connecting to ${hostClarity} </gel:out>



<soap:invoke endpoint="${hostClarity}/niku/xog" var="auth">




<soap:message>





<soap-env:Envelope>





<soap-env:Header/>






<soap-env:Body>







<xog:Login>








<xog:Username>${loginClarity}</xog:Username>








<xog:Password>${passClarity}</xog:Password>







</xog:Login>






</soap-env:Body>





</soap-env:Envelope>




</soap:message>



</soap:invoke>



<gel:set asString="true" select="$auth//xog:SessionID/text()" var="sessionID"/>



<core:choose>




<core:when test="${sessionID == null}">





<!--gel:log level="error" message="[-] Identification error. Please check login and pasword."/-->






<gel:out>[-] Identification error. Please check login and password</gel:out>




</core:when>




<core:otherwise>





<!--gel:log category="XOG" level="info" message="Connected to ${hostClarity}"/-->





<gel:out>Connected to ${hostClarity}</gel:out>




</core:otherwise>



</core:choose>








<gel:out>[-] Reading input file...</gel:out>



<file:readFile fileName="rate_matrix.csv" embedded="false" var="input" delimiter=";"/>




<gel:out>Input has ${input.size()} rows.</gel:out>




<file:writeFile fileName="traitement_matrices.csv" delimiter=";" embedded="false">




<core:forEach items="${input.getRows()}" var="row">






<file:line>








<!-- <file:column value="${req.get('id_idee')}"/> -->








<file:column value="${row[0]}"/> <!-- fromDate-->








<file:column value="${row[1]}"/> <!-- toDate-->








<file:column value="${row[2]}"/> <!-- ressource Role-->








<file:column value="${row[3]}"/> <!-- ressource-->








<file:column value="${row[4]}"/> <!-- rate-->








<file:column value="${row[5]}"/>  <!-- standardCost-->








<file:column value="${row[6]}"/> <!-- actualCost-->
















</file:line>








</core:forEach>




</file:writeFile>









<file:readFile fileName="traitement_matrices.csv" embedded="false" var="input" delimiter=";"/>

<core:choose>





<core:when test="${input.size() != 0}">






<gel:out>File ready to import </gel:out>




<!-- Mise à jour des champs spécifiques -->




<core:set value="xog_matrix.xml" var="FichierDest"/>



<gel:parse var="XOG_MATRICES">



<!-- ** Construction du XOG pour la mise à jour des champs spécifique** -->



<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"







 xsi:noNamespaceSchemaLocation="../xsd/nikuxog_matrix.xsd">







  <Header version="12.1.1.1208" action="write" objectType="matrix" externalSource="NIKU">








</Header>






<matrices/>



</NikuDataBus>



</gel:parse>



<file:readFile fileName="traitement_matrices.csv" embedded="false" var="input" delimiter=";"/>




<gel:out>Import file has ${input.size()} rows.</gel:out>




<gel:out>[-] Updating rate matrix</gel:out>





<core:forEach items="${input.getRows()}" var="row">






<gel:parse var="XOG_MATRIX">







<matrix defaultCurrencyCode="EUR" name="MATRIX_TEST" type="Cost/Rate">








<columns>









<column name="resourceRole"/>









<column name="resource"/>








</columns>








<matrixRows>









<matrixRow actualCost="${row[6]}" currencyCode="EUR"










fromDate="${row[0]}" rate="${row[4]}" resource="${row[3]}"










resourceRole="${row[2]}" standardCost="${row[5]}" toDate="${row[1]}"/>








</matrixRows>







</matrix>














</gel:parse>






<!-- Ajout de l'idée à la liste des idées à mettre à jour -->






<gel:set insert="true" select="$XOG_MATRICES/NikuDataBus/matrices" value="${XOG_MATRIX}"/>





</core:forEach>





<gel:serialize fileName="${FichierDest}" var="${XOG_MATRICES}"/>





<!--core:set value="xog_PRB.xml" var="FichierDest"/-->











<!--gel:serialize fileName="${FichierDest}" var="${XOG_MATRICES}"/-->



<!-- Envoie du XOG pour ecriture -->



<core:catch var="exception">



<soap:invoke endpoint="${hostClarity}/niku/xog" var="output">




<soap:message>





<soap-env:Envelope>






<soap-env:Header>







<xog:Auth>








<xog:SessionID>${sessionID}</xog:SessionID>







</xog:Auth>






</soap-env:Header>






<soap-env:Body>







<gel:include select="$XOG_MATRICES"/>






</soap-env:Body>





</soap-env:Envelope>




</soap:message>



</soap:invoke>








<core:set value="0" var="exception"/>


</core:catch>





<core:choose>




<core:when test="${exception != 0}">




<gel:out>[-] Error while sending XOG</gel:out>




<gel:out>${exception}</gel:out>




<!--gel:log level="error" message="[-] Error while sending XOG"/-->




<!--gel:log category="SOAP" level="info" message="${exception}"/-->



</core:when>



<core:otherwise>





<gel:set asString="true" select="$output//XOGOutput/ErrorInformation/Exception/text()"
var="DocErrTxt1"/>





<gel:set asString="true" select="$output//XOGOutput/Records/Record/ErrorInformation/Exception/text()" var="DocErrTxt2"/>





<core:choose>






<core:when test="${DocErrTxt1 != null || DocErrTxt2 != null}">








<!--gel:log category="SOAP" level="error" 








message="Erreur lors de la création à partir du modèle !!"/-->








<gel:out>[-] Error while updating Rate matrix rows</gel:out>








<gel:set asString="true" select="$output//XOGOutput/Records/Record/ErrorInformation/Description/text()" var="DescErr"/>








<!--gel:log category="XOG" level="info" 








message="${DescErr}"/-->








<gel:out>${DescErr}</gel:out>








<!--gel:log category="XOG" level="info" 








message="${DocErrTxt2}"/-->








<gel:out>${DocErrTxt2}</gel:out>








<gel:set asString="true" select="$XOG_MATRICES" var="xogIn"/>








<!--gel:log category="XOG" level="info" 








message="${xogIn}"/-->








<gel:out>${xogIn}</gel:out>







</core:when>






<core:otherwise>







<!--gel:log category="SOAP" level="info" 







message="Copie réussie !!"/-->







<gel:out>rate matrix rows has been updated !!</gel:out>






</core:otherwise>





</core:choose>



</core:otherwise>


</core:choose>

</core:when>

<core:otherwise>


<gel:out>no matrix ewists in dans Clarity</gel:out>


<gel:out>can not load</gel:out>

</core:otherwise>
</core:choose>



<!--Déconnexion et libération de la session -->





<soap:invoke endpoint="${hostClarity}/niku/xog" var="result">


<soap:message>



<soap-env:Envelope>




<soap-env:Header>





<xog:Auth>






<xog:SessionID>${sessionID}</xog:SessionID>





</xog:Auth>




</soap-env:Header>




<soap-env:Body>





<xog:Logout/>




</soap-env:Body>



</soap-env:Envelope>


</soap:message>


</soap:invoke>
</gel:script>
thank you for your help

Outcomes