how to give dataadaptor in jasper report - java

I have created a .jrxml file using iReport eclipse plugin. It takes json as an input. I have created jsonDataAdaptor inside the eclipse to export the report. Now I want to do the same using java, not iReport.
I have a .jrxml file and i am compiling the file using:
JasperCompileManager.compileReportToFile
In the .jrxml file I have created some fields for the json and have used in textField.
<field name="username" class="java.lang.String">
<fieldDescription><![CDATA[username]]></fieldDescription>
</field>
<field name="pwd" class="java.lang.String">
<fieldDescription><![CDATA[pwd]]></fieldDescription>
</field>
I am having the username and pwd's in the test.json that is placed in my local drive in the same path as the .jrxml file.
My dataAdapter(in the same folder as .jrxml file):
<?xml version="1.0" encoding="UTF-8" ?>
<jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl">
<name>jsonDataAdaptor</name>
<fileName>C:\test\test.json</fileName>
<useConnection>false</useConnection>
<timeZone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
dirty="false" DSTSavings="0" raw-offset="19800000"
xsi:type="java:sun.util.calendar.ZoneInfo">
<ID>Asia/Calcutta</ID>
<display-name>India Standard Time</display-name>
</timeZone>
<locale country="US" language="en" />
<selectExpression></selectExpression>
<datePattern></datePattern>
<numberPattern></numberPattern>
</jsonDataAdapter>
The problem is, when I am exporting the same into html I am getting values as null.

Here is the link for jasper datasource adapter.

Related

obfuscating with allatori obfuscates too much

I have the following config.xml file
<config>
<input>
<jar in="FVCellsPlugin-3.3.1-jcg.jar" out="obf-FVCellsPlugin-3.3.1-jcg.jar"/>
</input>
<keep-names>
<class template="class io.github.freakyville.fvcells.main.Main"/>
<class template="class regex:(?!io\.github\.freakyville).*\..*">
<field template="*"/>
<field template="static *"/>
<field template="public static *"/>
<method template="private+ *(**)"/>
<method template="private+ static *(**)"/>
</class>
<class template="private+ class regex:io\.github\.freakyville\.utilsupdated\..*"/>
</keep-names>
<property name="log-file" value="log.xml"/>
<property name="line-numbers" value="keep"/>
</config>
So I tried a few things without it working, all my code that i want obfuscated is in the package(or sub packages) io.github.freakyville(except io.github.freakyville.utilsupdated).
when the plugin is enabled I get an error java.lang.NoSuchMethodError: com.mongodb.client.model.geojson.c.iiiiiI(Ljava/lang/String;)Ljava/lang/String; which shows that it is obfuscating the class inside com.mongodb.client.model.geojson, When looking inside the jar I can see that it has obfuscated the geojson.c class https://gyazo.com/45c17157d5d7a213f14a9ecc2c12b4f6 which to me doesn't make sence as my regex (?!io\.github\.freakyville).*\..* should match that package/class path and then keep the package/class right?
Ah I figured it out, I missed the tag in the documentation(which ignores the classes matched in the obfuscating process). Adding my class templates to that and now it works

Indexing data from CSV file in Apache Solr

I have followed the tutorials given in below link
Indexing csv file in solr
I have configured solr server in my local and
But when i try to post csv file using the below command
java -Dtype=text/csv -Durl=http://localhost:8983/solr/jcg/update -jar post.jar books.csv
I am getting below error response in command prompt
Any one help why i am getting the error response
Error:
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">111</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.common.SolrException</str></lst><str name=
"msg">ERROR: [doc=0553573403] unknown field 'cat'</str><int name="code">400</int></lst>
</response>
The tutorial you're following is quite old, so if you want follow the tutorial there are two options:
the tutorial you're following misses the creation of Schema configuration in jcg collection. In this case you should fix your managed-schema file to jcg configuration taking care to add the following fields as suggested in the Tutorial, then reload the configuration (or restart Solr). At this point the "Indexing the Data" step should work correctly.
<uniqueKey>id</uniqueKey>
<!-- Fields added for books.csv load-->
<field name="cat" type="text_general" indexed="true" stored="true"/>
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="price" type="tdouble" indexed="true" stored="true"/>
<field name="inStock" type="boolean" indexed="true" stored="true"/>
<field name="author" type="text_general" indexed="true" stored="true"/>
You have correctly added schema and fields but not reloaded the configuration, but not reloaded the collection. So just reload the configuration (or restart Solr) and continue with the tutorial.
On the other hand, if you're using an earlier version of Solr (6.4) I suggest to delete jcg collection and create it again:
bin/solr delete -c jcg
bin/solr create -c jcg -d ./server/solr/configsets/sample_techproducts_configs

Spring boot+jasperReports images path error in resources

I have spring boot project with jasperReports library.
I have this structure
project
-src
-main
-java
-my.pakeg
-resources
-static
-jasper
-images
-logo.jpg
-rep1.jrxml
-rep2.jrxml
-rep3.jrxml
-templates
and in rep1.jrxml I include
<variable name="tax_logo_repo" class="java.lang.String">
<initialValueExpression><![CDATA["images/logo.jpg"]]></initialValueExpression>
</variable>
And I have error net.sf.jasperreports.engine.JRException: Byte data not found at: images/logo.jpg.
But if I move image from images folder to jasper folder
-resources
-static
-jasper
-images
-logo.jpg
-logo2.jpg
-rep1.jrxml
-rep2.jrxml
-rep3.jrxml
-templates
And change this path
<variable name="tax_logo_repo" class="java.lang.String">
<initialValueExpression><![CDATA["logo2.jpg"]]></initialValueExpression>
</variable>
All work fine. Why? I want have images in images folder. How can I do it?

Target file in Ant NetBeans project

My NetBeans project creates my.jar file in /dist/ directory. Trying to edit build.xml to copy this file to another location using ssh. But how to know what is target file name property?
<property name="username" value="aaa"/>
<property name="password" value="bbb"/>
<property name="ip" value="10.1.100.55"/>
<property name="dir" value="/opt/aaa/"/>
<scp file="${dist.jar.dir}${??target??}" todir="${username}:${password}#${ip}:${dir}" trust="true" />
Your Netbeans project has a nbproject/project.properties file, which gets included in build.xml (indirectly) and contains lots of useful variables - including the one that contains a file path to the built jar file. It should be called dist.jar.
<scp file="${dist.jar}" todir="${username}:${password}#${ip}:${dir}" trust="true" />
Check the actual properties file for more variable names, such as dist.dir, src.dir, etc.

Generate source files from XML

I have the XML file which starts like this:
<?xml version="1.0" encoding="UTF-8"?>
<interface name="AccountAPING" owner="BDP" version="1.0.0" date="now()" namespace="com.betfair.account.api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>Account API-NG</description>
...
afterward there are various blocks, such as:
<operation name="getDeveloperAppKeys" since="1.0.0">
<description>
Get all application keys owned by the given developer/vendor
</description>
<parameters>
<request/>
<simpleResponse type="list(DeveloperApp)">
<description>
A list of application keys owned by the given developer/vendor
</description>
</simpleResponse>
<exceptions>
<exception type="AccountAPINGException">
<description>Generic exception that is thrown if this operation fails for any reason.</description>
</exception>
</exceptions>
</parameters>
</operation>
........
<simpleType name="Status" type="string">
<validValues>
<value name="SUCCESS">
<description>Sucess status</description>
</value>
</validValues>
</simpleType>
........
<dataType name="TimeRange">
<description>TimeRange</description>
<parameter name="from" type="dateTime" mandatory="false">
<description>from, format: ISO 8601)</description>
</parameter>
<parameter name="to" type="dateTime" mandatory="false">
<description>to, format: ISO 8601</description>
</parameter>
</dataType>
How can I generate Java code from this using maven? I tried using "maven-jaxb2-plugin", but it can't parse this structure.
Please note
This is an XML file not not an xsd
I'm using Netbeans
First of all, you need the schema (xsd) that describes your xml sample. Without that schema you can not use Jaxb. You don't have a schema for the sample you shown xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" is not the schema for your xml.
You can use free on-line tools to generate schemas from xml, but you can't rely on this tools without review the automated schema.
To generate Java code from a schema file use XJC, see here. Open a command prompt to the folder where you put your xsd file, and then generate java code you'll just need to type:
$ xjc nameOfSchemaFile.xsd
xjc is included with Java SDK.

Categories