AnsweredAssumed Answered

Trying to create ootb issue instance in a clarity project via gel process

Question asked by shalinee on Apr 6, 2016
Latest reply on Apr 6, 2016 by shalinee

Hi All,

We are facing issues while we are trying to create a issue instance within clarity project via custom gel script. Below is the gel code. It creates the issue in first time and next time it is keep overriding the same issue rather than creating a new instance of it. Issue is OOTB object in system and auto numbering is enabled for it.

 

<gel:script xmlns:core="jelly:core"

    xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

    xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"

    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

    xmlns:sql="jelly:sql" 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:parse file="../config/properties.xml" var="properties"/>

    <gel:set asString="true"

        select="$properties/properties/webServer/@schedulerUrl" var="XOGURL"/>

    <gel:parameter default="******" var="XOGUsername"/>

    <gel:parameter default="xxxxxxx" secure="true" var="XOGPassword"/>

    <gel:parameter default="../logs/IssueInfile.xml" var="Infile"/>

    <gel:parameter default="../logs/IssueLogfile.xml" var="Outfile"/>

    <gel:formatDate format="yyyyMMdd" stringVar="today"/>

    <core:set var="eventId">${gel_objectInstanceId}</core:set>

    <!-- Get a DB Connection to Clarity -->

    <gel:setDataSource dbId="Niku" var="clarityDS"/>

    <gel:log level="INFO" trim="false">[sync] Logging into Clarity XOG at ${XOGURL}.</gel:log>

    <core:catch var="exception">

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

            <soap:message>

                <soapenv:Envelope

                    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">

                    <soapenv:Header/>

                    <soapenv:Body>

                        <xog:Login>

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

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

                        </xog:Login>

                    </soapenv:Body>

                </soapenv:Envelope>

            </soap:message>

        </soap:invoke>

        <!-- Checking whether a sessionID is returned.  If not, it means that Login was not successful. -->

        <gel:set asString="true"

            select="$auth/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>

        <gel:log level="INFO">Session ID is: ${sessionID}</gel:log>

        <core:choose>

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

                <gel:log level="ERROR">Cannot login to Clarity XOG. Check username and password.</gel:log>

                <gel:out trim="false">   [sync] Cannot login to Clarity XOG at ${XOGURL}. Check username and password.</gel:out>

            </core:when>

            <core:otherwise>

                <gel:log level="INFO"> The Event ID ${eventId}</gel:log>

                <sql:query dataSource="${clarityDS}" escapeText="false" var="nxtNum"><![CDATA[

                SELECT NEXT_VALUE FROM CMN_AUTONUM_SCHEMES

                WHERE OBJECT_CODE = 'issue'

                AND ATTRIBUTE_CODE = 'rim_risk_issue_code'

                AND PARTITION_CODE = 'NIKU.ROOT'

            ]]></sql:query>

                <core:forEach items="${nxtNum.rows}" var="row2">

                    <core:set value="${row2.NEXT_VALUE}" var="next_code"/>

                </core:forEach>

                <!-- CREATE XOG HEADER -->

                <gel:parse var="issueXML">

                    <NikuDataBus

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_issue.xsd">

                        <Header action="write" externalSource="NIKU"

                            objectType="issue" version="12.1.3.1361"/>

                        <issues/>

                    </NikuDataBus>

                </gel:parse>

                <gel:log level="INFO" trim="false">[sync] Querying Project Evaluation Conditions Data.</gel:log>

                <sql:query dataSource="${clarityDS}" escapeText="false" var="result"><![CDATA[

                            SELECT inv.code projectCode

                                , left(ef.hna_conditions, 250) desc_name

                                                                         , left(ef.hna_conditions, 80) abbr_desc_name

                                , r.user_name ownerCode

                                , 'LOW' priorityCode

                                , 'OPEN' statusCode

                            FROM odf_ca_nae_efloweval ef

                             JOIN inv_investments inv ON inv.id = ef.odf_parent_id

                             JOIN cmn_sec_users r on ef.created_by = r.id

                            WHERE odf_object_code = 'project'

                                and ef.id= ${eventId}

                    ]]></sql:query>

                <gel:log level="INFO" trim="false">[sync] Create the XOG Issue file.</gel:log>

                <!-- CREATE XOG FILE -->

                <core:forEach items="${result.rows}" var="row">

                    <gel:parse var="xogIssue">

                        <issue code="${next_code}"

                            description="${row.desc_name}"

                            name="${row.abbr_desc_name}"

                            ownerCode="${row.ownerCode}"

                            priorityCode="${row.priorityCode}"

                            projectCode="${row.projectCode}" statusCode="${row.statusCode}">

                            <notes/>

                            <associatedTasks/>

                            <CustomInformation/>

                        </issue>

                    </gel:parse>

                    <gel:set insert="true"

                        select="$issueXML/NikuDataBus/issues" value="${xogIssue}"/>

                </core:forEach>

                <gel:serialize fileName="${Infile}" var="${issueXML}"/>

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

                    <soap:message>

                        <soapenv:Envelope

                            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">

                            <soapenv:Header>

                                <xog:Auth>

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

                                </xog:Auth>

                            </soapenv:Header>

                            <soapenv:Body>

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

                            </soapenv:Body>

                        </soapenv:Envelope>

                    </soap:message>

                </soap:invoke>

                <gel:out>

                    <gel:expr select="$result"/>

                </gel:out>

                <gel:serialize fileName="${Outfile}" var="${result}"/>

                <!-- Logout XOG-->

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

                    <soap:message>

                        <soapenv:Envelope

                            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">

                            <soapenv:Header>

                                <xog:Auth>

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

                                </xog:Auth>

                            </soapenv:Header>

                            <soapenv:Body>

                                <xog:Logout/>

                            </soapenv:Body>

                        </soapenv:Envelope>

                    </soap:message>

                </soap:invoke>

                <gel:log level="INFO" trim="false">[sync] XOG logged out.</gel:log>

            </core:otherwise>

        </core:choose>

    </core:catch>

</gel:script>

 

 

Any suggestion !

thanks in advance.

Attachments

Outcomes