Why does j8583 Configparser fails with no default value to template fields? - java

I am using j8583 to build and parse ISO messages.
I have my template and parse config.xml in place, but when there are no default values specified to template fields it fails with NullPointerException.
Below is the template which fails with NullPointerException.
Field 3 doesn't have any default value.
<template type="0200">
<field num="3" type="NUMERIC" length="6"></field>
<field num="32" type="LLVAR">456</field>
<field num="35" type="LLVAR">4591700012340000=</field>
<field num="43" type="ALPHA" length="40">SOLABTEST TEST-3 DF MX</field>
<field num="49" type="ALPHA" length="3">484</field>
<field num="60" type="LLLVAR">B456PRO1+000</field>
<field num="61" type="LLLVAR"> 1234P</field>
<field num="100" type="LLVAR">999</field>
<field num="102" type="LLVAR">ABCD</field>

Well you're specifying field 3 to be a NUMERIC field of 6 digits and you didn't set any value. It's weird that you get NPE, should be NumberFormatException when it tries to parse the empty string.
Please file an issue on github.com/chochos/j8583 and I'll look into it (I'm the author of j8583).
In the meantime, try setting the value to 0. Or, if you don't need the field, just omit it from the template.

Related

Parse Blockly generated XML code to Java objects

I've to parse Blockly generated XML code. Generally i use Xstream parser for parsing XML. But XStream parser not working since this XML has child tags same name as Parent tag.
I found this library which converts Blockly xml code to Java objects. But this library fails for Complex Blockly XML code shown below. I tried to edit library to enable parsing for the below xml code. But its not working.
<?xml version="1.0" encoding="UTF-8"?>
<block type="event_click" id="Bp64nx|xcR*L:(K(`u78" x="146" y="81">
<field name="Event_Type">none</field>
<field name="do_on_page_load">TRUE</field>
<statement name="action">
<block type="database_yes_no" id="#0OCYIX:}#uT?0[UbS=r">
<value name="Check_Name">
<block type="database_check_field" id="Sl-IEwB~/hv?9mQYYBB]">
<field name="Enum_Name">StockType</field>
<field name="Enum_Value">Serialised</field>
</block>
</value>
<statement name="Yes">
<block type="action_toggle_field" id="}X:#xcfp,!+bk7MA.sgJ">
<field name="action">show</field>
<field name="id">4930</field>
<next>
<block type="action_toggle_field" id="h)QgD#prJCVcm;BMG$VR">
<field name="action">hide</field>
<field name="id">4932</field>
<next>
<block type="action_toggle_field" id="1V{g?Cdh2ww}ihWhtovG">
<field name="action">show</field>
<field name="id">4961</field>
</block>
</next>
</block>
</next>
</block>
</statement>
<statement name="No">
<block type="action_toggle_field" id="InDTOg;B2!go_rD;WIb~">
<field name="action">hide</field>
<field name="id">4930</field>
<next>
<block type="action_toggle_field" id="f{Ae_|^jEb{CR5$?9Ku.">
<field name="action">show</field>
<field name="id">4932</field>
<next>
<block type="action_toggle_field" id="#-^o/f|Iv0WIids+VcJv">
<field name="action">hide</field>
<field name="id">4961</field>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
I don't see much help on Blockly xml parsing.
Please let me know if there is a solution or library to parse Blockly generated XML code.
Thank you.
Stream-based XML parsers require you to maintain extra state, usually a stack. Simple if (tagName == 'block') {...} is not sufficient.
For your above example, the stack might look like:
block
statement
block
statement
block
next
block
next
block
field
Each item might have a pointer to the parsed object under construction, so you can add the child to it, and know what object to continue working on after an end tag.
While it uses XmlPullParser instead of a stream parser, you may want to look at com.google.blockly.model.BlockFactory.fromXml(..) in the blockly-android repo.

generate dynamic page in HTML from xml

I have several different XML files. I want to display them in HTML format using JSP file.
The structure of these files can be different. They may have different depth and tag's names.
I've read about XSLT but I found only examples with manually created xsl. (I can't do that because i will have many different xml files).
How can i produce my html?
EDIT:
Example of form:
<form name="Company">
<field name="name" required="true" type="inputText"/>
<field name="registrationDate" required="true" type="date"/>
<field name="isActive" required="false" type="boolean"/>
<field name="unregistrationDate" type="date"/>
<field name="type" type="comboBox">
<values>
<value>type1</value>
<value>type3</value>
<value>type3</value>
</values>
<defaultSelected>type2</defaultSelected>
</field>
</form>

In Jasper Reports, how to store the result of a sql query in a variable?

In Jasper Reports, how may I execute a sql query and store the result in a variable? This result should be accessed using $V{varName}.
EDIT: I have a subdataset defined like this:
<subDataset name="current_user" uuid="f8453e1d-8d55-4157-a8fd-aa04986e1cd5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="MySQL Local"/>
<parameter name="u" class="java.lang.Integer">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<queryString language="SQL">
<![CDATA[select first_name, last_name from users where id_user = $P{u}]]>
</queryString>
<field name="first_name" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="last_name" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
</subDataset>
I want the first and last name of a user, to be stored in a variable, and then this variable to be displayed in several fields (the variable is reused). How can I do that?
Your value come from sql query store in field. You can store that value in variable lie this.
First make variable and with same class of field which value you want to store in variable .
<variable name="variable" class="java.lang.String">
<initialValueExpression><![CDATA[$F{field1}]]></initialValueExpression>
</variable>
Where field1 is name of field which value you want to store in variable.

how to store in SOLR (mini) relational data

My data set is title, description and tags.
I would like to store and index in the SOLR the tag_name and their relative tag_id.
As can be understood, each record has one title, one description bt many tag names + tag ids.
I guess I can store the tags as "some-tag-[id]" but his seems wrong.
You can index tags and tags_id as multivalued fields and add in order.
The order is maintained so you can map them within the fields.
<field name="tags" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="tags_id" type="string" indexed="false" stored="true" multiValued="true"/>
Response -
<arr name="tags">
<str>tag1</str>
<str>tag2</str>
<str>tag3</str>
</arr>
<arr name="tags_id">
<str>id1</str>
<str>id2</str>
<str>id3</str>
</arr>

Data Import Handler in Solr

I am trying the Data Import Handler for MySQL Database.
I added the DIhandler in solrconfig.xml, created a data-config.xml according to my database scheme and also added a field in the schema.xml which was different. I am connecting with MySQL database
After i connect and I run the dataimport?command=full-import i get this response
"00C:\solr\conf\data-config.xmlfull-importidle1102011-03-05 15:01:04Indexing completed. Added/Updated: 0 documents. Deleted 0 documents.2011-03-05 15:01:042011-03-05 15:01:040:0:0.400This response format is experimental. It is likely to change in the future."
The xml files are in this http://pastebin.com/iKebKGSZ
<field column="manu" name="manu" />
<field column="id" name="id" />
<field column="weight" name="weight" />
<field column="price" name="price" />
<field column="popularity" name="popularity" />
<field column="instock" name="inStock" />
<field column="includes" name="includes" />
Are these fields also in your schema.xml?
I couldnt see them in the pastebin link. Make sure you have all fields in your schema as well.

Categories

Resources