Notes
Notes - notes.io |
xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:nikuq="http://www.niku.com/xog/Query" xmlns:jelly="jelly:core" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="jelly:sql" xmlns:util="jelly:util"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<gel:setDataSource dbId="Niku" var="clarityDS" />
<sql:query var="results" dataSource="${clarityDS}">
SELECT i.code, i.name, zjp.code z_jira_kanban_id, usr.user_name, i.description, zjp.name jira_name, zjp.z_project_key
FROM odf_ca_idea oci
LEFT JOIN inv_investments i ON i.id = oci.id
LEFT JOIN cmn_sec_users usr ON usr.id = i.created_by
LEFT JOIN odf_ca_z_jira_project zjp ON ZJP.Z_PROJECT_KEY = oci.z_attachjira
WHERE oci.id = ${gel_objectInstanceId}
</sql:query>
<gel:out>[XOG] Sonuclar</gel:out>
<gel:out>[XOG] Code:${results.rows[0].code}</gel:out>
<gel:out>[XOG] Name:${results.rows[0].name}</gel:out>
<gel:out>[XOG] Jira Project Name:${results.rows[0].jira_name}</gel:out>
<gel:out>[XOG] Jira Kanban Id:${results.rows[0].z_jira_kanban_id}</gel:out>
<gel:out>[XOG] Jira Project Key:${results.rows[0].z_project_key}</gel:out>
<gel:out>Start this Script</gel:out>
<core:invokeStatic var="base64" className="com.niku.union.utility.Base64" method="encode">
<core:arg type="java.lang.String" value="jiracaadmin:jiracaadmin2017" />
</core:invokeStatic>
<core:set var="basicAuth" value="Basic ${base64}" />
<gel:out>basicAuth = ${basicAuth}</gel:out>
<!-- Set the endpoint to WebService and set our Authorization for Basic -->
<core:set var="soapEndPoint" value="http://jira.thy.com/rest/api/2/issue" />
<!-- Open a connection to WebService and set our request headers -->
<core:new var="RestEndPoint" className="java.net.URL">
<core:arg type="java.lang.String" value="${soapEndPoint}" />
</core:new>
<gel:out>1</gel:out>
<core:invoke var="connection" on="${RestEndPoint}" method="openConnection"/>
<core:expr value="${connection.setDoOutput(true)}" />
<core:expr value='${connection.setRequestMethod("POST", soapEndPoint)}'/>
<core:expr value='${connection.setRequestProperty("Content-type", "application/json")}'/>
<core:expr value='${connection.setRequestProperty("Accept", "application/json")}'/>
<core:expr value='${connection.setRequestProperty("Authorization",basicAuth)}'/>
<core:set var="RestBody">
{
"fields": {
"project":
{
"id": "${results.rows[0].z_jira_kanban_id}"
},
"summary": "${results.rows[0].code} - ${results.rows[0].name}",
"description": "${results.rows[0].description}",
"issuetype": {
"name": "Task"
},
"customfield_13901": "${results.rows[0].code}",
"customfield_13208": "${results.rows[0].name}"
}
}
</core:set>
<gel:out>${RestBody}</gel:out>
<!-- Write out our getRecords request to WebService -->
<core:invoke var="outputStream" on="${connection}" method="getOutputStream" />
<core:new var="outputStreamWriter" className="java.io.OutputStreamWriter">
<core:arg type="java.io.OutputStream" value="${outputStream}" />
</core:new>
<gel:out>3</gel:out>
<core:expr value="${outputStreamWriter.write(RestBody)}" />
<gel:out>4</gel:out>
<core:expr value="${outputStreamWriter.flush()}" />
<gel:out>5</gel:out>
<core:expr value="${outputStreamWriter.close()}" />
<gel:out>6</gel:out>
<!-- Read in the response from WebService into a string -->
<core:invoke var="responseCode" on="${connection}" method="getResponseCode" />
<gel:out>Response Code: ${responseCode}</gel:out>
<core:if test = "${responseCode == 200 || responseCode == 201 || responseCode == 202 }">
<core:invoke var="inputStream" on="${connection}" method="getInputStream" />
</core:if>
<core:if test="${ responseCode != 200 && responseCode != 201 && responseCode != 202}">
<core:invoke var="inputStream" on="${connection}" method="getErrorStream" />
</core:if>
<gel:out>7</gel:out>
<core:new var="inputStreamReader" className="java.io.InputStreamReader">
<core:arg type="java.io.InputStream" value="${inputStream}" />
</core:new>
<gel:out>8</gel:out>
<core:new var="stringBuilder" className="java.lang.StringBuilder" />
<core:set var="data" value="${inputStreamReader.read()}" />
<gel:out>9</gel:out>
<core:while test="${data != -1}">
<core:invokeStatic var="char" className="java.lang.Character" method="toChars" >
<core:arg type="int" value="${data}" />
</core:invokeStatic>
<core:invokeStatic var="charString" className="java.lang.String" method="valueOf" >
<core:arg value="${char}" />
</core:invokeStatic>
<core:set var="char" value="${java.lang.String.valueOf(java.lang.Character.toChars(data))}"/>
<core:invoke method="append" on="${stringBuilder}">
<core:arg value="${charString}" />
</core:invoke>
<core:set var="data" value="${inputStreamReader.read()}" />
</core:while>
<gel:out>10</gel:out>
<!-- Here is a string of the xml reponse payload -->
<gel:out>${stringBuilder.toString()}</gel:out>
<core:set var="jsonstr">${stringBuilder.toString()}</core:set>
<core:if test="${ responseCode > 300}">
<gel:log level="ERROR" category="XOG">${stringBuilder.toString()}</gel:log>
</core:if>
<core:if test="${ responseCode < 300}">
<sql:query dataSource="${clarityDS}" var="jiraresult">
select SUBSTR('${jsonstr}',
INSTR('${jsonstr}', '"key":')+7,
INSTR('${jsonstr}', ',"self"') - INSTR('${jsonstr}', '"key":') -8
) outp from dual
</sql:query>
<gel:out>Issue Key: ${jiraresult.rows[0].outp}</gel:out>
<sql:update var="results" dataSource="${clarityDS}">
UPDATE odf_ca_idea oci
SET z_refprjid = '${results.rows[0].jira_name}',
z_ref_prj_link = 'https://jira.thy.com/projects/${results.rows[0].z_project_key}/issues/${jiraresult.rows[0].outp}?filter=allopenissues',
z_refprjstatus = '-',
z_kanban = 1
WHERE oci.id = ${gel_objectInstanceId}
</sql:update>
</core:if>
</gel:script>
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team