I have problem with I think format when I get temperature value. When I call for this parameter I always got it with "d0" f.e. "-0,39d0". How can I fix it? My code:
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set name="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
<filter type="jsonpath">$.main.temp</filter>
</callapi>
</set>
</think>
<get name="weather_t"/>.
</template>
</category>
If I use jsonpath instead filter the result is the same.
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set var="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
</callapi>
</set>
</think>
<jsonpath><path>$.main.temp</path><get var="weather_t"/></jsonpath>
</template>
</category>
bot answer example
This is how the openweathermap API presents the results. The easiest way to get rid of the d0 part is to denormalize the output.
Add this to your denormal substitution file:
["0d0", "0"],
["1d0", "1"],
["2d0", "2"],
["3d0", "3"],
["4d0", "4"],
["5d0", "5"],
["6d0", "6"],
["7d0", "7"],
["8d0", "8"],
["9d0", "9"],
In your first category, replace:
<get name="weather_t"/>
with
<denormalize><get name="weather_t"/></denormalize>
It should now work
Related
How to pass multiple parameters into WSO2 MI dataService, nested queries
I search far and wide,
Here how its done:
</query>
<query id="getCampaigns" useConfig="MySQLConnection">
<sql>SELECT NULL</sql>
<param name="param1" sqlType="STRING" />
<param name="param2" sqlType="QUERY_STRING" />
<param name="param3" sqlType="QUERY_STRING" />
<result outputType="json">{
"Campaigns": {
"CampaignsByBanks": {
"SearchedCampaigns": {
"#getCampaignBbank": "$param1->param1, $param2->param2, $param3->param3",
"#getCampaignAbank": "$param1->param1, $param2->param2, $param3->param3"
},
"OtherCampaigns": {
"#getOtherCampaignBbank": "$param1->param1, $param2->param2, $param3->param3",
"#getOtherCampaignAbank": "$param1->param1, $param2->param2, $param3->param3"
}
}
}
}
</result>
</query>
how to pass single parameter into WSO2 MI dataService, nested query
https://docs.wso2.com/display/EI630/Defining+Nested+Queries
I'm using WSO2 Enterprise Integrator 6.5.0 's DataService,
I want to input nested parameters,
i did not find any tutorials about that,
it is my input :
{
"getBankCodes": {
"SOURCE" : "12",
"FUNCTION": "james",
"REQUESTER" : "bond",
"SECURITYCODE" : "bond#gmail.com"
}
}
Desired input is :
{
"source" : "123",
"userId" : "test",
"Request": {
"SOURCE" : "12",
"FUNCTION": "james",
"REQUESTER" : "bond",
"SECURITYCODE" : "bond#gmail.com"
}
}
Source code :
<query id="getBankCodes" useConfig="Datasource">
<sql>Select BankCode, BankName From XAC_BANKCODES Where Substr(BankCode, Length(BankCode) - 3) = '0000'</sql>
<result outputType="json">
{ "Response":
{"Banks":[
{
"Details": {
"BankCode":"$BankCode",
"BankName":"$BankName"
}
}
]
}
}</result>
<param name="SOURCE" ordinal="1" sqlType="STRING"/>
<param name="FUNCTION" ordinal="1" sqlType="STRING"/>
<param name="REQUESTER" ordinal="1" sqlType="STRING"/>
<param name="SECURITYCODE" ordinal="1" sqlType="STRING"/>
</query>
<operation name="getBankCode">
<call-query href="getBankCodes">
<with-param name="SOURCE" query-param="SOURCE"/>
<with-param name="FUNCTION" query-param="FUNCTION"/>
<with-param name="REQUESTER" query-param="REQUESTER"/>
<with-param name="SECURITYCODE" query-param="SECURITYCODE"/>
</call-query>
</operation>
<resource method="POST" path="/getBankCodes">
<call-query href="getBankCodes">
<with-param name="SOURCE" query-param="SOURCE"/>
<with-param name="FUNCTION" query-param="FUNCTION"/>
<with-param name="REQUESTER" query-param="REQUESTER"/>
<with-param name="SECURITYCODE" query-param="SECURITYCODE"/>
</call-query>
</resource>
Please refer below questions
How to send grouped complex nested input parameters
How to get input parameters as response(return What i sent as input) on this situation.
Regards,
Thanks
How to send grouped complex nested input parameters
Extracting the corresponding parameter is a mediation logic. Therefore, you have to write a proxy service/API in EI to extract inner param set from the request and call the dataservice.
How to get input parameters as response(return What i sent as input) on this situation.
You can do the same when you are writing a mediation logic.
I want to set some variables to default values, so if the user never supplies, say, their username, my responses won't have odd empty spaces in them.
Sample of what I tried but didn't work:
<set name="name">user</set>
<category>
<pattern>HELLO</pattern>
<template>
Hello, <get name="name"/>.
</template>
</category>
The description of <get /> leads to the .pdefaults file.
Instead of
<set name="name">user</set>
in the UDC, the following single line in .pdefaults gets the result you want
[["name", "user"]]
I am writing the below AIML code.
<aiml>
<category>
<pattern>test</pattern>
<template>This is a test to try the third possible input. Yes / No ? </br>
</template>
</category>
<category>
<pattern>Yes</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>No</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>This is a test to try the third possible *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
I would like to see "Bingo!!!" as a response when a user enters anything apart from Yes or No.
<pattern>*</pattern>
works fine when I use it separately, but not here. Where am I doing the mistake?
Some AIML libraries require the pattern value to be uppercase (this is good practice even for implementations which not force it). So for me the following code works as expected (tested under PyAIML):
<aiml>
<category>
<pattern>TEST</pattern>
<template>This is a test to try the third possible input. Yes / No ? <br /></template>
</category>
<category>
<pattern>YES</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
Output:
> test
This is a test to try the third possible input. Yes / No ?
> yes
Hey!. You have typed YES!
> test
This is a test to try the third possible input. Yes / No ?
> no
Hey!. You have typed No!
> test
This is a test to try the third possible input. Yes / No ?
> Foo
BINGO!!!!
>
Instead of <that> tags you can also try to use <topic>, e.g.:
<aiml>
<category>
<pattern>TEST</pattern>
<template>
This is a test to try the third possible input. Yes / No ? <br />
<think><set name="topic">THREE OPTIONS</set></think>
</template>
</category>
<topic name="THREE OPTIONS">
<category>
<pattern>YES</pattern>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<template>BINGO!!!!</template>
</category>
</topic>
</aiml>
I just want to know, is there any way to iterate a List and print it's content one by one (incremental) in each groupFooter?
I create a group in my report, and in each groupFooter section, I want to display content from a java.util.List I sent from Java class via parameter.
Currently I just using jr:list and jr:listContents in my groupFooter, and the result is all contents from the list is printed in every groupFooter. I got an headache to solve this, so any help will relief me.
I don't think you should try to iterate the List to get content in a certain number of groupFooter, instead I would get content directly List based on index.
What we need is simple a pointer (position in list), in your case this number seems to be an incremented number every time we have a new group.
A variabile counting as group change is:
<variable name="countMyGroup" class="java.lang.Integer" incrementType="Group" incrementGroup="Group1" calculation="Count">
<variableExpression><![CDATA[""]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
With this simple variabile we will now have the current number of group that is displayed and we can add a textField with the value from or List using this number. see java.util.List.get(int index)
<parameter name="listOfStuff" class="java.util.List" isForPrompting="false"/>
.....
<textField>
<reportElement x="120" y="0" width="267" height="17" uuid="b45699d3-5d34-4d88-b7bc-2666cf787ace">
<printWhenExpression><![CDATA[$P{listOfStuff}.size()>=$V{countMyGroup}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA[$P{listOfStuff}.get($V{countMyGroup}-1)]]></textFieldExpression>
</textField>
Note: the printWhenExpression will avoid IndexOutOfBoundsException, hence that the group number is higher then the size of our List
Full jrxml example, it use a dummy group changing on each record, to try it use a JREmptyDatasource with a couple of records.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ListOnEachPage" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="33394f25-66fc-431b-ac82-88660e9115e5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Empty 4 records"/>
<parameter name="listOfStuff" class="java.util.List" isForPrompting="false">
<defaultValueExpression><![CDATA[Arrays.asList(new String[]{"group 1","group 2","group 3"})]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<variable name="countMyGroup" class="java.lang.Integer" incrementType="Group" incrementGroup="Group1" calculation="Count">
<variableExpression><![CDATA[""]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<group name="Group1">
<groupExpression><![CDATA[$V{REPORT_COUNT}]]></groupExpression>
<groupFooter>
<band height="34">
<textField>
<reportElement x="120" y="0" width="267" height="17" uuid="b45699d3-5d34-4d88-b7bc-2666cf787ace">
<printWhenExpression><![CDATA[$P{listOfStuff}.size()>=$V{countMyGroup}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA[$P{listOfStuff}.get($V{countMyGroup}-1)]]></textFieldExpression>
</textField>
<textField>
<reportElement x="445" y="0" width="100" height="17" uuid="e5c46332-b137-4c55-99e4-265c87b8f97d"/>
<textFieldExpression><![CDATA[$V{countMyGroup}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<detail>
<band height="63" splitType="Stretch">
<staticText>
<reportElement x="140" y="20" width="264" height="30" uuid="1ec9f950-dd2d-4c18-a81a-b0da937eb1b5"/>
<textElement>
<font size="14"/>
</textElement>
<text><![CDATA[Just some text to simulate detail band]]></text>
</staticText>
</band>
</detail>
</jasperReport>
Output, see how values from list are extracted as long as we are within size of List
You need to make a variable which increment at your group level.
Step 2 its to use that variable in a simple textfield or what component you want (not a collection component) and put his expression like this : list.indexOf(countVariable)