I want to retreive ReferenceNumber value present in
I have used the following query and I am getting empty result
SELECT EXTRACTVALUE('<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DCRequest xmlns="http://hello.com/dc/extsvc"> <Authentication type="Ond"> <UserId>hello</UserId> <Password>345545</Password> </Authentication> <RequestInfo> <SolutionSetId>1617</SolutionSetId> <SolutionSetVersion>85</SolutionSetVersion> <ExecutionMode>NewWithContext</ExecutionMode> <EnvironmentId>1</EnvironmentId> </RequestInfo> <Fields> <Field key="ApplicationData"> <![CDATA[<ApplicationData> <SkipFlag>false</SkipFlag> <Purpose>05</Purpose> <ReferenceNumber>1741759</ReferenceNumber> <SkipDSTuNtcFlag>false</SkipDSTuNtcFlag> <SkipDSTuIDVisionFlag>true</SkipDSTuIDVisionFlag> </ApplicationData>]]]]>> </Field> <Field key="Applicants"> <![CDATA[<Applicants> <Applicant> <ApplicantType>Main</ApplicantType> <ApplicantFirstName>rishi</ApplicantFirstName> <DateOfBirth>16061988</DateOfBirth> <Gender>2</Gender> <Emails> <Email> <EmailId>rishi543ta88#gmail.com</EmailId> <EmailIdType>02</EmailIdType> </Email> </Emails> <Telephones> <Telephone> <TelephoneNumber>76434475257</TelephoneNumber> <TelephoneType>01</TelephoneType> </Telephone> </Telephones> <Identifiers> <Identifier> <IdNumber>AMRPG4334N</IdNumber> <IdType>01</IdType> </Identifier> </Identifiers> <Addresses> <Address> <AddressLine1>43434345 road</AddressLine1> <City>Mumbai West</City> <PinCode>4005080</PinCode> <AddressType>052</AddressType> <ResidenceType>502</ResidenceType> <StateCode>257</StateCode> </Address> </Addresses> </Applicant> </Applicants>]]]]>> </Field> </Fields> </DCRequest>','/Fields/Field/ReferenceNumber')
First get all child of <Field key="ApplicationData">, then search for ReferenceNumber.
So you Need this:
SELECT EXTRACTVALUE(t, '//ReferenceNumber') AS ReferenceNumber FROM (
SELECT EXTRACTVALUE(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DCRequest xmlns="http://hello.com/dc/extsvc"> <Authentication type="Ond"> <UserId>hello</UserId> <Password>345545</Password> </Authentication> <RequestInfo> <SolutionSetId>1617</SolutionSetId> <SolutionSetVersion>85</SolutionSetVersion> <ExecutionMode>NewWithContext</ExecutionMode> <EnvironmentId>1</EnvironmentId> </RequestInfo> <Fields> <Field key="ApplicationData"> <![CDATA[<ApplicationData> <SkipFlag>false</SkipFlag> <Purpose>05</Purpose> <ReferenceNumber>1741759</ReferenceNumber> <SkipDSTuNtcFlag>false</SkipDSTuNtcFlag> <SkipDSTuIDVisionFlag>true</SkipDSTuIDVisionFlag> </ApplicationData>]]]]>> </Field> <Field key="Applicants"> <![CDATA[<Applicants> <Applicant> <ApplicantType>Main</ApplicantType> <ApplicantFirstName>rishi</ApplicantFirstName> <DateOfBirth>16061988</DateOfBirth> <Gender>2</Gender> <Emails> <Email> <EmailId>rishi543ta88#gmail.com</EmailId> <EmailIdType>02</EmailIdType> </Email> </Emails> <Telephones> <Telephone> <TelephoneNumber>76434475257</TelephoneNumber> <TelephoneType>01</TelephoneType> </Telephone> </Telephones> <Identifiers> <Identifier> <IdNumber>AMRPG4334N</IdNumber> <IdType>01</IdType> </Identifier> </Identifiers> <Addresses> <Address> <AddressLine1>43434345 road</AddressLine1> <City>Mumbai West</City> <PinCode>4005080</PinCode> <AddressType>052</AddressType> <ResidenceType>502</ResidenceType> <StateCode>257</StateCode> </Address> </Addresses> </Applicant> </Applicants>]]]]>> </Field> </Fields> </DCRequest>',
'DCRequest/Fields/Field[1]'
) AS t
) AS t1
Related
When you define a field in odoo, by default, it displays the string for that value and next to it, the value.
If you don't put the field between group tags, the string value, doesn't appear.
The problem is that I am defining a tree view which doesn't contain group tags:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string= 'Nombre' name="fertilizer"/>
<field string='N' name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field string='P' name="fosforo" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='K' name="potasio" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>
</record>
By using widget percentpie, I can display this:
I want to hide the letter N next to the graph but not the column and I can't find any property of the widget to do that. The only way I could trick this is by giving the color white to the text so it disappears with the background, but the column cant be centered.
I have tried with the option show_string I found on GitHub but it doesn't work.
Any help would be awesome...
Thank you!
Odoo defines a condition in the PercentPie template to show the string attribute vaue:
<span t-if="widget.string"><t t-esc="widget.string"/></span>
You can alter the template and define a new condition base on a value (show_string ) passed through the options attribute:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="FieldPercentPie">
<t t-jquery="span" t-operation="attributes">
<attribute name="t-if">widget.string and (widget.attrs.options.show_string === undefined or widget.attrs.options.show_string)</attribute>
</t>
</t>
</templates>
Create a new XML file with the above content and add it under the qweb section of the manifest file.
Example:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string='Nombre' name="fertilizer"/>
<field name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field name="fosforo" options='{"show_string": False}' widget="percentpie"/>
<field name="potasio" options='{"show_string": False}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>
How Can I extract the characteristics values for the following XML code using XPATH?
Example: Extract displayName, firsName, lastName, etc.
This is my XML data:
<directory>
<fieldset>
<field id="displayName">Display name</field>
<field id="firstName">First name</field>
<field id="lastName">Last name</field>
<field id="preferredName">Preferred name</field>
<field id="jobTitle">Job title</field>
<field id="workPhone">Work Phone</field>
<field id="canUploadPhoto">Can Upload Photo</field>
</fieldset>
<employees>
<employee id="229">
<field id="displayName">Susan</field>
<field id="firstName">TestName</field>
<field id="canUploadPhoto">no</field>
</employee>
</employees>
</directory>
You can get actual values along the following XPath expression:
/directory/employees/employee/field[#id="displayName"]/text()
I am trying to import data from files like CSV, XML and Json to solr core, I am new to solr so this might be a straightforward to some but for me I have tried many online suggestions but not getting the desired result.
So I have a json file and I have enabled dataimport by adding the following requestHandler to solrconfig.xml:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">solr-data-config.xml</str>
</lst>
</requestHandler>
And in the solr-data-config.xml:
<dataConfig>
<dataSource name="dfs" type="FileDataSource"/>
<document>
<entity name="sourcefile" processor="FileListEntityProcessor" fileName=".*" rootEntity="false" baseDir="${solr.install.dir}/example/exampledocs">
<entity name="entryline" processor="LineEntityProcessor" url="${sourcefile.fileAbsolutePath}" rootEntity="true" dataSource="fds" separator=","/>
</entity>
</document>
The updated version:
<dataConfig>
<script><![CDATA[
function CategoryPieces(row) {
var pieces = row.get('manu_id_s').split('/');
var arr = new Array();
for (var i=0; i < pieces.length; i++) {
row.put('manu_id_s' + i, pieces[i].trim());
arr[i] = pieces[i].trim();
}
row.put('manu_id_s', (pieces.length - 1).toFixed());
row.put('manu_id_s', arr.join('/'));
row.put('manu_id_s', arr.join('/'));
return row;
}
]]></script>
<dataSource type="FileDataSource" />
<document>
<entity
name="document"
processor="FileListEntityProcessor"
baseDir="${solr.install.dir}/example/exampledocs/khaled"
fileName=".*.xml$"
recursive="false"
rootEntity="false"
dataSource="null">
<entity
name="test"
processor="XPathEntityProcessor"
transformer="script:CategoryPieces"
url="${document.fileAbsolutePath}"
useSolrAddSchema="true"
stream="true">
</entity>
</entity>
</document>
</dataConfig>
And I have added a json, csv and xml files to the path, in the ui of solr when I use the dataimport it says that e.g. Requests: 0 , Fetched: 26 , Skipped: 0 , Processed: 0 and nothing in the logs, can someone advice how to add the data in the file to solr?
Here is my sample data in the xml file:
<add>
<doc>
<field name="id">USD</field>
<field name="name">One Dollar</field>
<field name="manu">Bank of America</field>
<field name="manu_id_s">boa</field>
<field name="cat">currency</field>
<field name="features">Coins and notes</field>
<field name="price_c">1,USD</field>
<field name="inStock">true</field>
</doc>
<doc>
<field name="id">EUR</field>
<field name="name">One Euro</field>
<field name="manu">European Union</field>
<field name="manu_id_s">eu</field>
<field name="cat">currency</field>
<field name="features">Coins and notes</field>
<field name="price_c">1,EUR</field>
<field name="inStock">true</field>
</doc>
<doc>
<field name="id">GBP</field>
<field name="name">One British Pound</field>
<field name="manu">U.K.</field>
<field name="manu_id_s">uk</field>
<field name="cat">currency</field>
<field name="features">Coins and notes</field>
<field name="price_c">1,GBP</field>
<field name="inStock">true</field>
</doc>
<doc>
<field name="id">NOK</field>
<field name="name">One Krone</field>
<field name="manu">Bank of Norway</field>
<field name="manu_id_s">nor</field>
<field name="cat">currency</field>
<field name="features">Coins and notes</field>
<field name="price_c">1,NOK</field>
<field name="inStock">true</field>
</doc>
</add>
Now the data returned from the query looks like:
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"_":"1547556805546"}},
"response":{"numFound":4,"start":0,"docs":[
{
"manu_id_s":"boa",
"id":"USD",
"_version_":1622731088078045184},
{
"manu_id_s":"eu",
"id":"EUR",
"_version_":1622731088081190912},
{
"manu_id_s":"uk",
"id":"GBP",
"_version_":1622731088081190913},
{
"manu_id_s":"nor",
"id":"NOK",
"_version_":1622731088082239488}]
}}
I am using Mule 3.6.1 and have a flow that reads a CSV file and then splits the file and passes in each record to the datamapper. I can see that the record is present prior to data mapper but once the message leaves the datamapper, the payload is empty.
How can I fix this? Please note that the Choice will have 3 possible datamappers to select in the completed flow.
The flow is:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd">
<context:property-placeholder location="mule-app.properties" />
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="org.mule.util.StringUtils" />
<import class="org.mule.util.ArrayUtils" />
</expression-language>
</configuration>
<data-mapper:config name="test_mapper" transformationGraphPath="csv_to_json_1.grf" doc:name="test_mapper"/>
<flow name="read-file" >
<file:inbound-endpoint path="${file.unprocessed.location}" moveToPattern="#[message.inboundProperties['originalFilename']]" moveToDirectory="${file.processed.location}" responseTimeout="10000" doc:name="Files" mimeType="text/csv" >
<file:filename-regex-filter pattern="test.csv" caseSensitive="true"/>
</file:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<splitter expression="#[rows=StringUtils.split(message.payload,'\n\r'); ArrayUtils.subarray(rows,1,rows.size())]" doc:name="Splitter"/>
<set-property propertyName="testFilename" value="#[flowVars.originalFilename]" doc:name="Set Filename"/>
<choice doc:name="Choice">
<when expression="#[message.outboundProperties.'testFilename'=='test.csv']">
<data-mapper:transform config-ref="CSV_To_JSON" doc:name="CSV To JSON"/>
</when>
<otherwise>
<logger level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
<object-to-string-transformer doc:name="Object to String"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
and CSV input file:
DeptID,Dept,Staff
5LL/A,Human Resources,4.00
and GRF file showing data mappings:
<?xml version="1.0" encoding="UTF-8"?><Graph __version="3.5.0" author="" created="Wed May 25 14:20:34 BST 2016" description="CSV To JSON" guiVersion="3.4.4.P" id="1464184235950" licenseCode="Unlicensed" licenseType="Unknown" modified="Wed May 25 14:20:34 BST 2016" modifiedBy="" name="CSV_To_JSON" preview-file="C:/test.csv" revision="1.0" showComponentDetails="false">
<Global>
<Metadata __referenceCounter="1" _dataStructure="SINGLE_DIMENSIONAL_COLLECTION" _type="Input" id="f79c6373-b266-4a78-91c9-3a731304eef1">
<Record fieldDelimiter="," name="test" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field containerType="SINGLE" label="DeptID" name="DeptID" size="10" type="string"/>
<Field containerType="SINGLE" label="Dept" name="Dept" size="10" type="string"/>
<Field containerType="SINGLE" eofAsDelimiter="true" label="Staff" name="Staff" size="10" type="string"/>
<Field __artificialType="_id" auto_filling="global_row_count" name="__id" type="long"/>
</Record>
</Metadata>
<Metadata __index="0" __referenceCounter="1" __sourcePath="{}/test" _dataStructure="SINGLE_DIMENSIONAL_COLLECTION" _id="__id" _type="Output" id="4b092da3-e786-4f90-8e22-d9d5e8d7a7b1">
<Record fieldDelimiter="," name="test" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field __artificialType="_id" __systemManaged="true" name="__id" type="string"/>
<Field __index="1" __sourcePath="{}/test/Dept" containerType="SINGLE" label="Dept" name="Dept" type="string"/>
<Field __index="0" __sourcePath="{}/test/DeptID" containerType="SINGLE" label="DeptID" name="DeptID" type="string"/>
<Field __index="2" __sourcePath="{}/test/Staff" containerType="SINGLE" label="Staff" name="Staff" type="string"/>
</Record>
</Metadata>
<Dictionary>
<Entry id="DictionaryEntry0" input="true" name="inputPayload" output="false" type="object"/>
<Entry id="DictionaryEntry1" input="false" name="outputPayload" output="true" type="object"/>
</Dictionary>
</Global>
<Phase number="0">
<Node charset="UTF-8" enabled="enabled" fileURL="dict:inputPayload" guiName="CSV READER" guiX="20" guiY="20" id="DATA_READER0" quoteCharacter="both" quotedStrings="true" skipRows="1" trim="true" type="DATA_READER">
<attr name="_data_format"><![CDATA[CSV]]></attr>
<attr name="__dataSourceDefinition"><![CDATA[C:/test.csv]]></attr>
</Node>
<Node enabled="enabled" guiName="Foreach 'test' -> 'test'" guiX="460" guiY="20" id="FOREACH_TEST_TEST" transformClass="com.mulesoft.datamapper.transform.MelRecordTransform" type="REFORMAT">
<attr name="melScript"><![CDATA[//MEL
//START -> DO NOT REMOVE
output.__id = num2str(input.__id);
//END -> DO NOT REMOVE
output.DeptID = input.DeptID;
output.Dept = input.Dept;
output.Staff = input.Staff;
]]></attr>
</Node>
<Node cacheInMemory="true" charset="UTF-8" enabled="enabled" fileURL="dict:outputPayload" guiName="JSON WRITER" guiX="900" guiY="20" id="JSON_WRITER0" type="JSON_WRITER">
<attr name="mapping"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<clover:collection clover:name="test" xmlns:clover="http://www.cloveretl.com/ns/xmlmapping">
<item clover:inPort="0">
<DeptID>$0.DeptID</DeptID>
<Dept>$0.Dept</Dept>
<Staff>$0.Staff</Staff>
</item>
</clover:collection>]]></attr>
<attr name="_data_format"><![CDATA[JSON]]></attr>
</Node>
<Edge debugMode="true" fromNode="DATA_READER0:0" guiBendpoints="" id="Edge0" inPort="Port 0 (in)" metadata="f79c6373-b266-4a78-91c9-3a731304eef1" outPort="Port 0 (output)" toNode="FOREACH_TEST_TEST:0"/>
<Edge debugMode="true" fromNode="FOREACH_TEST_TEST:0" guiBendpoints="" id="Edge1" inPort="Port 0 (in)" metadata="4b092da3-e786-4f90-8e22-d9d5e8d7a7b1" outPort="Port 0 (out)" toNode="JSON_WRITER0:0"/>
</Phase>
</Graph>
In the splitter your are already stripping of the header.
In DataMapper you have the option 'Rows to Ignore' set to "1".
Set that to "0", or change the expression in your splitter.
Because now you tell DataMapper to ignore your one and only row!
You are ignoring the row coming into the datamapper and hence there is no mapping being done remove "rows to ignore".Then the mapper will work on the row coming inside
I am trying to use solr for indexing data from my data base.
After I index data, when I query *.*
I get just the id field in result. not all the fields which I had in my query.
My data-config.xml
<document name="content">
<entity name="documen" query="SELECT indexId ,brand_id, category_id, product_name from Production">
<field column="indexId" name="id" />
<field column="category_id" name="categoryid" />
<field column="brand_id" name="brandid" />
<field column="product_name" name="id" />
</entity>
</document>
My schema.xml looks like this :
<field name="id" type="int" indexed="true" stored="true" required="true"/>
<field name="categoryid" type="int" indexed="true" stored="true"/>
<field name="brandid" type="int" indexed="true" stored="true" />
<field name="productname" type="string" indexed="true" stored="true"/>
When I query using *.* I get
<doc>
<str name="id">1</str>
<long name="_version_">1426653005792411648</long></doc>
<doc>
<str name="id">2</str>
<long name="_version_">1426653005793460224</long></doc>
<doc>
I get only "id" field as result.
Actually, whatever field is in "uniquekey" tag is returned as query result